generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from JetBrains/fix-226
Use OTEL_RESOURCE_ATTRIBUTES env var to get the resource id
- Loading branch information
Showing
11 changed files
with
68 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package me.rafaelldi.aspire.util | ||
|
||
import me.rafaelldi.aspire.generated.ResourceModel | ||
import me.rafaelldi.aspire.generated.SessionModel | ||
|
||
private const val OTEL_RESOURCE_ATTRIBUTES = "OTEL_RESOURCE_ATTRIBUTES" | ||
private const val SERVICE_INSTANCE_ID = "service.instance.id" | ||
|
||
fun SessionModel.getServiceInstanceId(): String? { | ||
val resourceAttributes = envs?.firstOrNull { it.key.equals(OTEL_RESOURCE_ATTRIBUTES, true) }?.value | ||
?: return null | ||
val serviceInstanceId = resourceAttributes.split(",").firstOrNull { it.startsWith(SERVICE_INSTANCE_ID) } | ||
?: return null | ||
|
||
return serviceInstanceId.removePrefix("service.instance.id=") | ||
} | ||
|
||
fun ResourceModel.getServiceInstanceId(): String? { | ||
val resourceAttributes = environment.firstOrNull { it.key.equals(OTEL_RESOURCE_ATTRIBUTES, true) }?.value | ||
?: return null | ||
val serviceInstanceId = resourceAttributes.split(",").firstOrNull { it.startsWith(SERVICE_INSTANCE_ID) } | ||
?: return null | ||
|
||
return serviceInstanceId.removePrefix("service.instance.id=") | ||
} |