opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

[Exporter.Prometheus] Possibility to disable otel_scope attributes

Open Kielek opened this issue 1 year ago • 5 comments

Fixes #3972

Changes

Add instrument scope info and version to Prometheus exporter as per https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1

Scope info is automatically added to the Prometheus exporters.

Before this change:

# TYPE MyFruitCounter_total counter
MyFruitCounter_total{color="red",name="apple"} 66 1702578315791
MyFruitCounter_total{color="yellow",name="lemon"} 77 1702578315791
MyFruitCounter_total{color="green",name="apple"} 22 1702578315791

# EOF

After (with no Accept header):

# TYPE otel_scope_info info
# HELP otel_scope_info Scope metadata
otel_scope_info{otel_scope_name="MyCompany.MyProduct.MyLibrary"} 1
# TYPE MyFruitCounter_total counter
MyFruitCounter_total{otel_scope_name="MyCompany.MyProduct.MyLibrary",otel_scope_version="1.0",color="red",name="apple"} 102 1702577575197
MyFruitCounter_total{otel_scope_name="MyCompany.MyProduct.MyLibrary",otel_scope_version="1.0",color="yellow",name="lemon"} 119 1702577575197
MyFruitCounter_total{otel_scope_name="MyCompany.MyProduct.MyLibrary",otel_scope_version="1.0",color="green",name="apple"} 34 1702577575197
# EOF

After (when passing Accept: application/openmetrics-text:

# TYPE otel_scope_info info
# HELP otel_scope_info Scope metadata
otel_scope_info{otel_scope_name="MyCompany.MyProduct.MyLibrary"} 1
# TYPE MyFruitCounter_total counter
MyFruitCounter_total{otel_scope_name="MyCompany.MyProduct.MyLibrary",otel_scope_version="1.0",color="red",name="apple"} 4692 1702577811.302
MyFruitCounter_total{otel_scope_name="MyCompany.MyProduct.MyLibrary",otel_scope_version="1.0",color="yellow",name="lemon"} 5474 1702577811.302
MyFruitCounter_total{otel_scope_name="MyCompany.MyProduct.MyLibrary",otel_scope_version="1.0",color="green",name="apple"} 1564 1702577811.302
# EOF

Merge requirement checklist

  • [x] CONTRIBUTING guidelines followed (nullable enabled, static analysis, etc.)
  • [x] Unit tests added/updated
  • [x] Appropriate CHANGELOG.md files updated for non-trivial changes
  • [ ] Changes in public API reviewed (if applicable)

Hi guys, It’s cool, of course, that you added this a feature, but looks like that manuals describes the ability for the exporter to disable this feature

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#instrumentation-scope-1

Prometheus exporters SHOULD provide a configuration option to disable the otel_scope_info metric and otel_scope_ labels.

Originally posted by @ezhdn in https://github.com/open-telemetry/opentelemetry-dotnet/issues/5086#issuecomment-2192642249

Kielek avatar Jun 27 '24 04:06 Kielek

@ezhdn, @robertcoltheart, would you like to contribute to this?

Kielek avatar Jun 27 '24 04:06 Kielek

I'll think about it, depends on time, but looks interesting

ezhdn avatar Jul 02 '24 11:07 ezhdn

Are there any updates? I'm losing my mind on this

LucaTheHacker avatar Mar 24 '25 00:03 LucaTheHacker

@LucaTheHacker, would you like to contribute to fix this problem?

Kielek avatar Mar 24 '25 05:03 Kielek

@Kielek surely I can.

I'll send a PR soon!

LucaTheHacker avatar Mar 24 '25 23:03 LucaTheHacker