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

Prometheus exporter: omit empty target_info metric #4177

Closed
dashpole opened this issue Oct 2, 2023 · 6 comments
Closed

Prometheus exporter: omit empty target_info metric #4177

dashpole opened this issue Oct 2, 2023 · 6 comments
Labels
contribfest These small and isolated issues are suitable for Kubecon Contribfest needs:code-contribution This feature/bug is ready to implement pkg:exporter-prometheus spec-feature This is a request to implement a new feature which is already specified by the OTel specification type:feature A feature with no sub-issues to address

Comments

@dashpole
Copy link
Contributor

dashpole commented Oct 2, 2023

Description

target_info should now only be generated when scope attributes and resource attributes are non-empty.

From open-telemetry/opentelemetry-specification#3660:

Prometheus exporters SHOULD generate an Info-typed
metric named otel_scope_info for each Instrumentation Scope with non-empty
scope attributes.

In SDK Prometheus (pull) exporters, resource attributes SHOULD be converted to
a single target_info metric
if the resource is not empty;

@pichlermarc pichlermarc added spec-feature This is a request to implement a new feature which is already specified by the OTel specification pkg:exporter-prometheus type:feature A feature with no sub-issues to address needs:code-contribution This feature/bug is ready to implement and removed feature-request labels Oct 3, 2023
@dyladan dyladan added the contribfest These small and isolated issues are suitable for Kubecon Contribfest label Nov 8, 2023
@olunusib
Copy link

olunusib commented Nov 8, 2023

Picking this up

@olunusib
Copy link

olunusib commented Nov 8, 2023

It seems this change doesn't need to be done in this repo @dashpole

@dashpole dashpole changed the title Prometheus exporter: omit empty otel_scope_info and otel_target_info metrics Prometheus exporter: omit empty otel_scope_info and target_info metrics Nov 8, 2023
@dashpole dashpole changed the title Prometheus exporter: omit empty otel_scope_info and target_info metrics Prometheus exporter: omit empty target_info metric Nov 8, 2023
@dashpole
Copy link
Contributor Author

dashpole commented Nov 8, 2023

I believe we emit target_info even if there are no resource attributes:

protected _serializeResource(resource: IResource): string {
const name = 'target_info';
const help = `# HELP ${name} Target metadata`;
const type = `# TYPE ${name} gauge`;
const results = stringify(name, resource.attributes, 1).trim();
return `${help}\n${type}\n${results}\n`;
}

@dashpole
Copy link
Contributor Author

dashpole commented Nov 8, 2023

I've updated the description to be more accurate, as otel_scope_info changes are not needed here.

@olunusib
Copy link

olunusib commented Nov 9, 2023

I believe we emit target_info even if there are no resource attributes:

From the code below, the default resource is always used if no resource is specified (or an empty one is passed in) so we'd never have an empty resource.

constructor(options?: MeterProviderOptions) {
const resource = Resource.default().merge(
options?.resource ?? Resource.empty()
);
this._sharedState = new MeterProviderSharedState(resource);
if (options?.views != null && options.views.length > 0) {
for (const view of options.views) {
this._sharedState.viewRegistry.addView(view);
}
}
}

If we choose not to emit target_info when the default resource is used, it could break the existing API, and I cannot predict the extent of the impact.

@dashpole
Copy link
Contributor Author

Thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribfest These small and isolated issues are suitable for Kubecon Contribfest needs:code-contribution This feature/bug is ready to implement pkg:exporter-prometheus spec-feature This is a request to implement a new feature which is already specified by the OTel specification type:feature A feature with no sub-issues to address
Projects
None yet
Development

No branches or pull requests

4 participants