Skip to content
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

Config for OTLP Resource attributes #3159

Merged

Conversation

shakuzen
Copy link
Member

@shakuzen shakuzen commented May 11, 2022

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:

meterRegistry.commonTags("env", "prod", "service", "checkout");

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-configuration

Resolves gh-3146

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 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.
@shakuzen shakuzen added enhancement A general enhancement registry: otlp OpenTelemetry Protocol (OTLP) registry-related labels May 11, 2022
@shakuzen shakuzen added this to the 1.9.0 milestone May 11, 2022
Since there is a specified environment variable to set resource attributes, we can support that. And since it defines a format for key-value pairs, we can use that for loading the map from the `get` method.
@jonatan-ivanov jonatan-ivanov linked an issue May 11, 2022 that may be closed by this pull request
@jonatan-ivanov jonatan-ivanov merged commit 7c2ba86 into micrometer-metrics:1.9.x May 11, 2022
@shakuzen shakuzen deleted the otlp-resource-attributes branch May 12, 2022 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement registry: otlp OpenTelemetry Protocol (OTLP) registry-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OTLP resource service name is always unknown
2 participants