-
Notifications
You must be signed in to change notification settings - Fork 840
feat(config): add service resource detector support for declarative config #5003
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?
Changes from all commits
5c26f00
8232012
8329ae4
506d816
8232d48
6ed3425
99753f9
8ba91d8
516aecc
9cfdcce
103ff08
7f51034
6a6f6df
2306b93
72c9db8
4de33e5
9e41d24
f63e2d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |||
|
|
||||
| import fnmatch | ||||
| import logging | ||||
| import os | ||||
| import uuid | ||||
| from typing import Callable, Optional | ||||
| from urllib import parse | ||||
|
|
||||
|
|
@@ -28,6 +30,8 @@ | |||
| from opentelemetry.sdk._configuration.models import Resource as ResourceConfig | ||||
| from opentelemetry.sdk.resources import ( | ||||
| _DEFAULT_RESOURCE, | ||||
| OTEL_SERVICE_NAME, | ||||
| SERVICE_INSTANCE_ID, | ||||
| SERVICE_NAME, | ||||
| ProcessResourceDetector, | ||||
| Resource, | ||||
|
|
@@ -150,6 +154,14 @@ def _run_detectors( | |||
| is updated in-place; later detectors overwrite earlier ones for the | ||||
| same key. | ||||
| """ | ||||
| if detector_config.service is not None: | ||||
| attrs: dict[str, object] = { | ||||
| SERVICE_INSTANCE_ID: str(uuid.uuid4()), | ||||
| } | ||||
| service_name = os.environ.get(OTEL_SERVICE_NAME) | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this work along with the OTELResourceDetector? opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py Line 360 in e301732
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||
| if service_name: | ||||
| attrs[SERVICE_NAME] = service_name | ||||
| detected_attrs.update(attrs) | ||||
| if detector_config.process is not None: | ||||
| detected_attrs.update(ProcessResourceDetector().detect().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.
I can't remember if this is in the spec already. Feel free to resolve if it is or doesn't need more discussion
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, this is in the spec. The semantic conventions for
service.instance.idspecify it should be a unique identifier for each instance, with a UUID being the recommended value. The opentelemetry-configuration schema also describes theservicedetector as populatingservice.instance.id.