-
Notifications
You must be signed in to change notification settings - Fork 858
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
add service.instance.id provider #9062
add service.instance.id provider #9062
Conversation
e704c38
to
c5542b8
Compare
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 an open spec issue that suggests adding service.instance.id
generation to the SDK itself: open-telemetry/opentelemetry-specification#3136
I'm not sure whether we should add this here; maybe a prototype in the SDK and pushing the spec issue would be a better course of action?
cc @jack-berg
private static String k8sServiceInstanceId(Map<String, String> resource) { | ||
String podName = resource.get(ResourceAttributes.K8S_POD_NAME.getKey()); | ||
String containerName = resource.get(ResourceAttributes.K8S_CONTAINER_NAME.getKey()); | ||
return podName != null && containerName != null ? podName + "/" + containerName : null; | ||
} |
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.
The spec doesn't really say anything about using k8s attributes to construct the serviceId (also k8s attributes are usually added by the collector processors, these might simply not be accessible here)
|
||
@Override | ||
public boolean shouldApply(ConfigProperties config, Resource existing) { | ||
return !config | ||
.getMap(ServiceInstanceIdResource.RESOURCE_ATTRIBUTES) | ||
.containsKey(ResourceAttributes.SERVICE_INSTANCE_ID.getKey()); | ||
} |
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.
This shouldn't really be needed, the EnvironmentResource
always comes last and it can override that anyway.
Superceded by open-telemetry/opentelemetry-java#6226 |
service.instance.id is an important attribute to support Prometheus: https://opentelemetry.io/docs/specs/otel/compatibility/prometheus_and_openmetrics/#resource-attributes