Config for OTLP Resource attributes #3159
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a config method for attributes that are set on the Resource shared by all metrics published from the OtlpMeterRegistry. Of note, this allows configuring the
service.name
to identify your service, but is generic enough to allow configuration of arbitrary attributes.The use cases for this largely overlaps with how we expect Micrometer common tags are used, and it is a shame I could not come up with a way to better connect these now. There is precedent for this approach in e.g. the StackdriverMeterRegistry. But it potentially creates inconsistency or duplicated work when using multiple registries.
For example, if you want to include metadata (tags) about the deployment environment and service name, you would typically configure common tags:
This approach works with this OTLP registry as well, but the common tags are applied as attributes to all metrics data points, instead of the resource. What difference this may have in a metrics backend is not clear.
I called out
service.name
before because it is defined in the Resource semantic conventions, and so it may be given special treatment. But by using the OTLP-specific configuration of resource attributes, these tags will not be configured on other registries if a composite registry were being used, even though it is highly likely the types of attributes set on a resource should be common tags in other registries. Taking the above example, you want the info about environment and service name available in your metrics backend regardless of which registry you are using.This supports either setting the key-value list in a specified environment variable or through the standard config's
get
method. See https://opentelemetry.io/docs/reference/specification/sdk-environment-variables/#general-sdk-configurationResolves gh-3146