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

Don't drop instance and job labels from the Prometheus receiver #2964

Closed
wants to merge 8 commits into from
Closed

Don't drop instance and job labels from the Prometheus receiver #2964

wants to merge 8 commits into from

Conversation

rakyll
Copy link
Contributor

@rakyll rakyll commented Apr 20, 2021

Fixes #575
Fixes #2499
Fixes #2363
Fixes open-telemetry/prometheus-interoperability-spec#37
Fixes open-telemetry/prometheus-interoperability-spec#39
Fixes open-telemetry/prometheus-interoperability-spec#44

Passing compliance tests:

$ go test --tags=compliance -run "TestRemoteWrite/otelcollector/Job.+" -v ./
=== RUN TestRemoteWrite
=== RUN TestRemoteWrite/otelcollector
=== RUN TestRemoteWrite/otelcollector/JobLabel
=== PAUSE TestRemoteWrite/otelcollector/JobLabel
=== CONT TestRemoteWrite/otelcollector/JobLabel
--- PASS: TestRemoteWrite (10.02s)
--- PASS: TestRemoteWrite/otelcollector (0.00s)
--- PASS: TestRemoteWrite/otelcollector/JobLabel (10.02s)
PASS
ok github.com/prometheus/compliance/remote_write 10.382s
$ go test --tags=compliance -run "TestRemoteWrite/otelcollector/Instance.+" -v ./
=== RUN TestRemoteWrite
=== RUN TestRemoteWrite/otelcollector
=== RUN TestRemoteWrite/otelcollector/InstanceLabel
=== PAUSE TestRemoteWrite/otelcollector/InstanceLabel
=== CONT TestRemoteWrite/otelcollector/InstanceLabel
--- PASS: TestRemoteWrite (10.01s)
--- PASS: TestRemoteWrite/otelcollector (0.00s)
--- PASS: TestRemoteWrite/otelcollector/InstanceLabel (10.01s)
PASS
ok github.com/prometheus/compliance/remote_write 10.291s
$ go test --tags=compliance -run "TestRemoteWrite/otelcollector/RepeatedLabels.+" -v ./
=== RUN TestRemoteWrite
=== RUN TestRemoteWrite/otelcollector
--- PASS: TestRemoteWrite (0.00s)
--- PASS: TestRemoteWrite/otelcollector (0.00s)
testing: warning: no tests to run
PASS

Fixes #575
Fixes #2499
Fixes  #2363
Fixes  open-telemetry/prometheus-interoperability-spec#37
Fixes  open-telemetry/prometheus-interoperability-spec#39

Passing compliance tests:

$ go test --tags=compliance  -run  "TestRemoteWrite/otelcollector/Job.+" -v ./
=== RUN   TestRemoteWrite
=== RUN   TestRemoteWrite/otelcollector
=== RUN   TestRemoteWrite/otelcollector/JobLabel
=== PAUSE TestRemoteWrite/otelcollector/JobLabel
=== CONT  TestRemoteWrite/otelcollector/JobLabel
--- PASS: TestRemoteWrite (10.02s)
    --- PASS: TestRemoteWrite/otelcollector (0.00s)
        --- PASS: TestRemoteWrite/otelcollector/JobLabel (10.02s)
PASS
ok  	github.com/prometheus/compliance/remote_write	10.382s
$  go test --tags=compliance  -run  "TestRemoteWrite/otelcollector/Instance.+" -v ./
=== RUN   TestRemoteWrite
=== RUN   TestRemoteWrite/otelcollector
=== RUN   TestRemoteWrite/otelcollector/InstanceLabel
=== PAUSE TestRemoteWrite/otelcollector/InstanceLabel
=== CONT  TestRemoteWrite/otelcollector/InstanceLabel
--- PASS: TestRemoteWrite (10.01s)
    --- PASS: TestRemoteWrite/otelcollector (0.00s)
        --- PASS: TestRemoteWrite/otelcollector/InstanceLabel (10.01s)
PASS
ok  	github.com/prometheus/compliance/remote_write	10.291s
@rakyll rakyll requested a review from a team April 20, 2021 03:31
@rakyll
Copy link
Contributor Author

rakyll commented Apr 20, 2021

cc @odeke-em

Copy link
Member

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite the awesome PR!! Thank you @rakyll , LGTM!

@rakyll
Copy link
Contributor Author

rakyll commented Apr 20, 2021

Will fix the tests soon.

@rakyll
Copy link
Contributor Author

rakyll commented Apr 20, 2021

The failing test (TestEndToEndSummarySupport) has a hard dependency on the receiver and byte to byte comparing the output. Is there a way we can remove this test and add something a bit more self contained @odeke-em?

@odeke-em
Copy link
Member

Please t.Skipf("@odeke-em please take a look") it and then we'll be gucci to go.

@rakyll
Copy link
Contributor Author

rakyll commented Apr 20, 2021

It seems like the pull based Prometheus exporter is not exposing the job and instance labels and it seems like it's a problem itself.

@codecov
Copy link

codecov bot commented Apr 20, 2021

Codecov Report

Merging #2964 (339944a) into main (0a2ea1b) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2964      +/-   ##
==========================================
- Coverage   91.63%   91.54%   -0.09%     
==========================================
  Files         312      312              
  Lines       15445    15443       -2     
==========================================
- Hits        14153    14138      -15     
- Misses        883      897      +14     
+ Partials      409      408       -1     
Impacted Files Coverage Δ
...iver/prometheusreceiver/internal/metricsbuilder.go 100.00% <100.00%> (ø)
exporter/prometheusexporter/accumulator.go 92.53% <0.00%> (-6.47%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a2ea1b...339944a. Read the comment docs.

@rakyll
Copy link
Contributor Author

rakyll commented Apr 20, 2021

I can't see why build-and-test is failed and can't reproduce it myself locally. Can someone paste the log?

@alolita
Copy link
Member

alolita commented Apr 20, 2021

Nicely done @rakyll ty!

@rakyll
Copy link
Contributor Author

rakyll commented Apr 20, 2021

cc @bogdandrutu @tigrannajaryan Can you review this? It's required for the stability.

@@ -40,6 +40,10 @@ func TestEndToEndSummarySupport(t *testing.T) {
t.Skip("This test can take a couple of seconds")
}

// TODO(odeke-em): Fix this, see https://github.com/open-telemetry/opentelemetry-collector/pull/2964
// for context.
t.Skipf("Not supporting instances and jobs, skipping for now. @odeke-em to take a look.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Skipf("Not supporting instances and jobs, skipping for now. @odeke-em to take a look.")
t.Skip("Not supporting instances and jobs, skipping for now. @odeke-em to take a look.")

This doesn't appear to be using the formatting template to inject values, so t.Skip() should suffice.

@tigrannajaryan
Copy link
Member

I don't know enough about this receiver to understand the change fully. @bogdandrutu @jrcamp maybe you can help review?

@@ -263,12 +270,17 @@ func verifyTarget1(t *testing.T, td *testData, mds []internaldata.MetricsData) {
Name: "go_threads",
Description: "Number of OS threads created",
Type: metricspb.MetricDescriptor_GAUGE_DOUBLE,
LabelKeys: []*metricspb.LabelKey{{Key: "instance"}, {Key: "job"}},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should instance and job be part of the resource instead of labels?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, working on it and will send another version.

@Aneurysm9
Copy link
Member

How does this relate to #2683?

@rakyll
Copy link
Contributor Author

rakyll commented Apr 21, 2021

Moving this PR to #2979. This issue requires an exporter change which populates the "instance" and "job" from resource attributes.

@rakyll rakyll closed this Apr 21, 2021
@rakyll
Copy link
Contributor Author

rakyll commented Apr 21, 2021

@Aneurysm9, just seeing your last comment, #2683 is related to this but it seems like #2897 was doing the right thing to turn these labels into resource attributes. What was missing was to take them from the resource attributes and produce Prometheus labels in the exporters which #2979 is doing.

@rakyll rakyll mentioned this pull request May 7, 2021
bogdandrutu pushed a commit that referenced this pull request May 7, 2021
This change was a part of #2964 but it's closed now. Having typed
arguments make it easier to massage the arguments before comparing.
Contributing this change for future maintainers.
dashpole pushed a commit to dashpole/opentelemetry-collector that referenced this pull request Jun 14, 2021
This change was a part of open-telemetry#2964 but it's closed now. Having typed
arguments make it easier to massage the arguments before comparing.
Contributing this change for future maintainers.
ankitnayan pushed a commit to SigNoz/opentelemetry-collector that referenced this pull request Jul 27, 2021
This change was a part of open-telemetry#2964 but it's closed now. Having typed
arguments make it easier to massage the arguments before comparing.
Contributing this change for future maintainers.
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment