-
Notifications
You must be signed in to change notification settings - Fork 1.2k
resource: add WithService detector option #7642
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
base: main
Are you sure you want to change the base?
resource: add WithService detector option #7642
Conversation
I was looking at implementing resource detection in otelconf and was finding that all the detectors were implemented in a similar way except for the service detector. Added the resource options in this PR for feedback. Will add tests if the go approvers/maintainers support this approach. Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7642 +/- ##
=======================================
- Coverage 86.1% 86.1% -0.1%
=======================================
Files 298 298
Lines 21694 21703 +9
=======================================
Hits 18692 18692
- Misses 2626 2635 +9
Partials 376 376
🚀 New features to boost your workflow:
|
|
This approach looks good to me. Adding tests would be awesome (there are no tests for the rest of the config unfortunately). |
|
|
||
| // WithServiceID adds an attribute with the uid of the service to the configured Resource. | ||
| func WithServiceID() Option { | ||
| return WithDetectors(defaultServiceInstanceIDDetector{}) |
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.
We currently have this behind an experimental feature gate in the SDK:
opentelemetry-go/sdk/resource/resource.go
Lines 242 to 243 in 729bd6e
| if x.Resource.Enabled() { | |
| defaultDetectors = append([]Detector{defaultServiceInstanceIDDetector{}}, defaultDetectors...) |
It looks like service.instance.id is still marked as being in development, so i'm not sure we can add a public API for the detector yet: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/service.md#service-attributes
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.
There is a public API for WithContainerID and that is still in development https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/container.md, should the api be removed?
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 would not have added it. I don't think we can remove it now, though.
I was looking at implementing resource detection in otelconf and was finding that all the detectors were implemented in a similar way except for the service detector. Added the resource options in this PR for feedback. Will add tests if the go approvers/maintainers support this approach.