How do I add attributes to the target
info metric without adding them to spans?
This code will add attributes to both the target
info metric and all the spans:
AutoConfiguredOpenTelemetrySdk.builder
.addResourceCustomizer((resource, _) =>
resource.merge(Resource.create(Attributes.of(
AttributeKey.stringKey("version.workflow"), classOf[Workflow].getPackage.getImplementationVersion,
AttributeKey.stringKey("version.stream"), classOf[Stream].getPackage.getImplementationVersion,
AttributeKey.stringKey("version.kafka"), org.apache.kafka.common.utils.AppInfoParser.getVersion,
))
)
)
.build()
How do I add these attributes to just the target
info metric and to spans?
Use addMeterProviderCustomizer
instead of addResourceCustomizer
.
Like so:
AutoConfiguredOpenTelemetrySdk.builder
.addMeterProviderCustomizer((meterProviderBuilder, _) =>
meterProviderBuilder.addResource(Resource.create(Attributes.of(
AttributeKey.stringKey("version.workflow"), classOf[Workflow].getPackage.getImplementationVersion,
AttributeKey.stringKey("version.stream"), classOf[Stream].getPackage.getImplementationVersion,
AttributeKey.stringKey("version.kafka"), org.apache.kafka.common.utils.AppInfoParser.getVersion,
))
)
)
.build()