-
Notifications
You must be signed in to change notification settings - Fork 731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(resources): implements service.instance.id
#4608
feat(resources): implements service.instance.id
#4608
Conversation
ef5ba1f
to
059622b
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #4608 +/- ##
==========================================
- Coverage 92.83% 90.77% -2.06%
==========================================
Files 329 90 -239
Lines 9528 1930 -7598
Branches 2053 417 -1636
==========================================
- Hits 8845 1752 -7093
+ Misses 683 178 -505
|
Thanks for this!
I kinda think it should be on the default Resource ( opentelemetry-js/packages/opentelemetry-resources/src/Resource.ts Lines 52 to 62 in c046867
I think it is a bit odd that one would only get I don't think the extra
It would only be called once per |
ah good to hear it doesn't cause such a perf impact! |
Thanks for slogging through those. |
059622b
to
010970c
Compare
Implementation and PR description updates. I will focus on the tests now 😄 |
010970c
to
e96cfed
Compare
f6b4645
to
fde7eee
Compare
6eb66ea
to
745add0
Compare
service.instance.id
service.instance.id
Short summary of what we discussed in the SIG Meeting today 🙂
Implementing the resource detector and adding the env var behavior in NodeSDK can be done in seperate PRs to speed up the review process. 🚀 Separately from that:
|
148d48f
to
19c7189
Compare
Latest changes (and some questions):
Looking for some help: I added a few tests for a few cases with value coming fro env var VS should get set based on the experimental flag and one of the tests is failing but I don't quite get why. |
605cd62
to
670d528
Compare
while working on the following PR I realize it makes more sense to have all the logic of the env var on the other one, so I remove those from here. This PR focus on the creation of the service instance ID detector. It currently is not called anywhere, but we have a test showcasing that it works as expected if the user initializes their NodeSDK with it. The following PR (#4626) will add the |
Follow up from open-telemetry#4608 Adds the resource detector ServiceInstanceIDDetector on the NodeSDK constructor. It only gets added by default on any of those conditions: - the value `serviceinstance` is part of the list `OTEL_NODE_RESOURCE_DETECTORS` - `OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID` is set to `true`
Follow up from open-telemetry#4608 Adds the resource detector ServiceInstanceIDDetector on the NodeSDK constructor. It only gets added by default on any of those conditions: - the value `serviceinstance` is part of the list `OTEL_NODE_RESOURCE_DETECTORS` - `OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID` is set to `true`
Follow up from open-telemetry#4608 Adds the resource detector ServiceInstanceIDDetector on the NodeSDK constructor. It only gets added by default on any of those conditions: - the value `serviceinstance` is part of the list `OTEL_NODE_RESOURCE_DETECTORS` - `OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID` is set to `true`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good 🙂
We can drop the Detector
and use DetectorSync
only. Other than that, only comments about marking things as @experimental
.
Thanks for sticking with us through the review-process 🙂
packages/opentelemetry-resources/src/platform/node/ServiceInstanceIDDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/node/ServiceInstanceIDDetectorSync.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/browser/ServiceInstanceIDDetector.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/browser/ServiceInstanceIDDetectorSync.ts
Outdated
Show resolved
Hide resolved
670d528
to
72505da
Compare
@pichlermarc let me know when you want to merge and I can rebase, otherwise as soon as I rebase it's already out of date again 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll wait a bit with merging to give @trentm another chance to take a look as he initially reviewed the PR. 🙂
(Approvers: feel free to rebase/merge if you come across this and I have not done it yet 🙂 - I'm OOO until Monday)
packages/opentelemetry-resources/src/platform/node/ServiceInstanceIDDetectorSync.ts
Outdated
Show resolved
Hide resolved
packages/opentelemetry-resources/src/platform/browser/ServiceInstanceIDDetectorSync.ts
Outdated
Show resolved
Hide resolved
Implements `service.instance.id` Signed-off-by: maryliag <marylia.gutierrez@grafana.com>
use an experimental environment variable to set the default value of `service.instance.id` as default
Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
create a function to add experimental default values (currently only service instance id, but others can be added in the future), with the value being set on the node case, but not on the browser case. Signed-off-by: maryliag <marylia.gutierrez@grafana.com>
use a resource detector for service instance id
remove the Detector and use the DetectorSync instead. Also mark things as experimental. Signed-off-by: maryliag <marylia.gutierrez@grafana.com>
…anceIDDetectorSync.ts Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
be68dac
to
78c31e9
Compare
FYI: A currently open otel spec issue (by some OTel Java implementors) asking about whether the SDK should handle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Dealer's choice in my OCD naming nit.
@@ -59,6 +59,7 @@ import { | |||
processDetector, | |||
hostDetector, | |||
Resource, | |||
serviceInstanceIDDetectorSync, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OCD nit: In other class names "id" has been capitalized as "Id" rather than "ID":
% rg -I 'export class' | rg ID
% rg -I 'export class' | rg Id
export class TraceIdRatioBasedSampler implements Sampler {
export class RandomIdGenerator implements IdGenerator {
export class RandomIdGenerator implements IdGenerator {
export class TraceIdRatioBasedSampler implements Sampler {
export class RandomIdGenerator implements IdGenerator {
export class RandomIdGenerator implements IdGenerator {
Though, given OSDetectorSync
consistency is difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OCD crisis adverted! 😄 Changed to Id
it was not picking up the case change on previous commit
Follow up from open-telemetry#4608 Adds the resource detector ServiceInstanceIDDetector on the NodeSDK constructor. It only gets added by default on any of those conditions: - the value `serviceinstance` is part of the list `OTEL_NODE_RESOURCE_DETECTORS` - `OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID` is set to `true`
Follow up from open-telemetry#4608 Adds the resource detector ServiceInstanceIDDetector on the NodeSDK constructor. It only gets added by default on any of those conditions: - the value `serviceinstance` is part of the list `OTEL_NODE_RESOURCE_DETECTORS` - `OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID` is set to `true`
Follow up from open-telemetry#4608 Adds the resource detector ServiceInstanceIDDetector on the NodeSDK constructor. It only gets added by default on any of those conditions: - the value `serviceinstance` is part of the list `OTEL_NODE_RESOURCE_DETECTORS` - `OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID` is set to `true`
Follow up from open-telemetry#4608 Adds the resource detector ServiceInstanceIDDetector on the NodeSDK constructor. It only gets added by default on any of those conditions: - the value `serviceinstance` is part of the list `OTEL_NODE_RESOURCE_DETECTORS` - `OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID` is set to `true`
Follow up from open-telemetry#4608 Adds the resource detector ServiceInstanceIDDetector on the NodeSDK constructor. It only gets added by default on any of those conditions: - the value `serviceinstance` is part of the list `OTEL_NODE_RESOURCE_DETECTORS` - `OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID` is set to `true`
* feat(sdk-node): add serviceInstanceIDDetector to NodeSDK Follow up from #4608 Adds the resource detector ServiceInstanceIDDetector on the NodeSDK constructor. It only gets added by default on any of those conditions: - the value `serviceinstance` is part of the list `OTEL_NODE_RESOURCE_DETECTORS` - `OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID` is set to `true` * remove OTEL_NODE_EXPERIMENTAL_DEFAULT_SERVICE_INSTANCE_ID Signed-off-by: maryliag <marylia.gutierrez@grafana.com> * update readme on how to use `OTEL_NODE_RESOURCE_DETECTORS` * feedback from review * Update experimental/packages/opentelemetry-sdk-node/README.md Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com> * feedback from review --------- Signed-off-by: maryliag <marylia.gutierrez@grafana.com> Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
Which problem is this PR solving?
Implements service.instance.id
Short description of the changes
From the Semantic Convention on Service, we have the values of
service.name
as required, asservice.instance.id
,service.version
andservice.namespace
as recommended.We are not able to set the value of version and namespace by ourselves, but following the semantic convention for service.instance.id, the value can be generated using a randomUUID (we have a similar implementation of this in other SDKs, such as the Java one).
This commit adds a value for
service.instance.id
by default, which can still be overwritten by the environment variable or cloud provider.This commit also updates some deprecated strings and add missing
sdk.shutdown
to allsdk.start
on the sdk test file.How Has This Been Tested?
sdk.test
Checklist: