-
Notifications
You must be signed in to change notification settings - Fork 213
rework ServiceInfoFactory priorities #1644
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
rework ServiceInfoFactory priorities #1644
Conversation
- default/all: load detectors from registry last - env-provided detectors: load in same order as default/all, then from registry in requested order
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1644 +/- ##
============================================
- Coverage 68.24% 68.20% -0.04%
+ Complexity 2919 2912 -7
============================================
Files 435 436 +1
Lines 8876 8890 +14
============================================
+ Hits 6057 6063 +6
- Misses 2819 2827 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 5 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
The way I’m reading https://github.com/open-telemetry/opentelemetry-specification/blob/v1.45.0/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable is that the Environment detector always has to be last, even after other registry-provided custom detectors, as part of the default detector. I could be wrong though. Edit: it also sounds like it’s mandatory. |
@smaddock great question. Do you mean this part of spec?
I think that does imply that environment detection should be last(ish). But I also think the spec has painted us into a corner here:
So, what to do? I agree with @GrzegorzDrozd issue, The options I see are:
I think that shared-nothing runtimes are still in the majority of PHP usage, and so our current offering for service.instance.id is not going to be useful for the majority. For reference, the current guidance for service.instance.id is https://github.com/open-telemetry/semantic-conventions/blob/v1.34.0/docs/registry/attributes/service.md |
Ah, I see the circular definition now. I might map that out visually for my own sake, but for the purposes of this PR, this is the part I keep coming back to:
What if we had a config/env setting that toggles between:
|
But to be most useful it would have to be provided by the developer - in my case I am using machine-id + sha of deployed git commit - that way I can have multiple persistent instances/machines + deployed version and it changes every time new code is deployed. Plus this has to be provided by dev as soon as possible (at least detector name) because once factories are created in autoload there is no way to change that. putenv('OTEL_PHP_DETECTORS=env,host,process,static-service-id'); and then after autoload is required i am just registering: Registry::registerResourceDetector('static-service-id', new StaticServiceId(GIT_COMMIT_ID)); |
@brettmc It looks like it will solve my issue - I will test this branch early next week. |
Any resource attribute should have mechanisms for users/developers to create overrides. Environment variables or manually setting the attributes as mentioned in #1643 (comment) should always override them. My thoughts above were around what methods of setting the |
to avoid always generating service.instance.id (which is useless for fpm/apache), split it into its own detector, ServiceInstance, and don't use it by default. If it is enabled, ensure it runs before registry-provided detectors.
I've updated the PR, splitting off a new ServiceInstance detector, and noting the spec deviation:
Since the portion of the spec that's tripping us up here has development stability, I'll create an issue to see if we can relax that wording. (edit: open-telemetry/opentelemetry-specification#4570 ) |
Co-authored-by: Chris Lightfoot-Wild <[email protected]>
Related: #1643