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

Default resource not included in v0.32.0 compared to v0.31.0 #3271

Closed
jsign opened this issue Oct 11, 2022 · 3 comments · Fixed by #3285
Closed

Default resource not included in v0.32.0 compared to v0.31.0 #3271

jsign opened this issue Oct 11, 2022 · 3 comments · Fixed by #3285
Assignees
Labels
bug Something isn't working pkg:exporter:prometheus Related to the Prometheus exporter package

Comments

@jsign
Copy link

jsign commented Oct 11, 2022

Description

Between versions v0.31.0 and v0.32.0, the attributes from the default resource changed their behavior.

Environment

  • OS: Linux
  • Architecture: amd64
  • Go Version: 1.10
  • opentelemetry-go version:v0.31.0 -> v0.32.0

Steps To Reproduce

  • git checkout metric/v0.31.0
  • cd example/prometheus && go run main.go
  • See the output of loalhost:2222/metrics

Do the same with metric/v0.32.0 and compare the third bullet step output.

Expected behavior

The v0.31.0 version outputs:

# HELP ex_com_one 
# TYPE ex_com_one gauge
ex_com_one{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0"} 1
# HELP ex_com_three 
# TYPE ex_com_three counter
ex_com_three{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0"} 12
# HELP ex_com_two 
# TYPE ex_com_two histogram
ex_com_two_bucket{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0",le="1"} 0
ex_com_two_bucket{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0",le="2"} 0
ex_com_two_bucket{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0",le="5"} 1
ex_com_two_bucket{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0",le="10"} 1
ex_com_two_bucket{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0",le="20"} 1
ex_com_two_bucket{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0",le="50"} 1
ex_com_two_bucket{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0",le="+Inf"} 1
ex_com_two_sum{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0"} 2
ex_com_two_count{A="1",B="2",C="3",ex_com_lemons="10",service_name="unknown_service:main",telemetry_sdk_language="go",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.8.0"} 1

So we see the service_name, telemetry_sdk_language, and other default attributes from the default resource.

When running in v0.32.0:

# HELP bar a fun little gauge
# TYPE bar counter
bar{A="B",C="D"} 75
# HELP baz a very nice histogram
# TYPE baz histogram
baz_bucket{A="B",C="D",le="0"} 0
baz_bucket{A="B",C="D",le="5"} 0
baz_bucket{A="B",C="D",le="10"} 1
baz_bucket{A="B",C="D",le="25"} 1
baz_bucket{A="B",C="D",le="50"} 0
baz_bucket{A="B",C="D",le="75"} 0
baz_bucket{A="B",C="D",le="100"} 0
baz_bucket{A="B",C="D",le="250"} 2
baz_bucket{A="B",C="D",le="500"} 0
baz_bucket{A="B",C="D",le="1000"} 0
baz_bucket{A="B",C="D",le="+Inf"} 4
baz_sum{A="B",C="D"} 236
baz_count{A="B",C="D"} 4
# HELP foo a simple counter
# TYPE foo counter
foo{A="B",C="D"} 5

We don't see the attributes of the default resource.

I'm unsure if this is a bug or an undocumented change. If isn't a bug, which is the right way to add the original default resource?

@jsign jsign added the bug Something isn't working label Oct 11, 2022
@MrAlias
Copy link
Contributor

MrAlias commented Oct 11, 2022

The old way of adding those labels to every metric was indeed a bug. It is specifically called out as something that MUST NOT be done in the specification:

In SDK Prometheus (pull) exporters, resource attributes SHOULD be converted to a single target_info metric; otherwise, they MUST be dropped, and MUST NOT be attached as labels to other metric families. The target_info metric MUST be an info-typed metric whose labels MUST include the resource attributes, and MUST NOT include any other labels. There MUST be at most one target_info metric exposed on an SDK Prometheus endpoint.

It seems like a good addition to add a target_info metric to expose the resource information in the exporter.

@MrAlias MrAlias added the pkg:exporter:prometheus Related to the Prometheus exporter package label Oct 11, 2022
@MrAlias MrAlias added this to the Metric SDK: Beta milestone Oct 11, 2022
@MrAlias MrAlias added the help wanted Extra attention is needed label Oct 11, 2022
@fatsheep9146
Copy link
Contributor

@MrAlias Could I take this issue?

@Aneurysm9 Aneurysm9 removed the help wanted Extra attention is needed label Oct 14, 2022
@fatsheep9146
Copy link
Contributor

@Aneurysm9
I have talked with @paivagustavo in slack and found that he has already completed the coding of this pr, since this is duplicate of #3166.
Could you assign this work to @paivagustavo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pkg:exporter:prometheus Related to the Prometheus exporter package
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants