add service.instance.id provider#9062
Conversation
e704c38 to
c5542b8
Compare
mateuszrzeszutek
left a comment
There was a problem hiding this comment.
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.
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.
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