-
Notifications
You must be signed in to change notification settings - Fork 206
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
base: main
Are you sure you want to change the base?
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 ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1644 +/- ##
============================================
- Coverage 68.77% 68.76% -0.02%
+ Complexity 2854 2847 -7
============================================
Files 425 426 +1
Lines 8699 8711 +12
============================================
+ Hits 5983 5990 +7
- Misses 2716 2721 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 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 ) |
$serviceName = Configuration::has(Variables::OTEL_SERVICE_NAME) | ||
? Configuration::getString(Variables::OTEL_SERVICE_NAME) | ||
: null; | ||
|
||
$attributes = [ | ||
ResourceAttributes::SERVICE_INSTANCE_ID => $serviceInstanceId, | ||
ResourceAttributes::SERVICE_NAME => $serviceName, |
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.
What about not null check from previous code?
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.
Good question. I think it's ok because null
attributes are dropped. There is a test for the scenario where service name is provided through OTEL_RESOURCE_ATTRIBUTES, which passes with this change (which I think would fail if it was using this null value)
Co-authored-by: Chris Lightfoot-Wild <github-clw@wild.me.uk>
Related: #1643