-
Notifications
You must be signed in to change notification settings - Fork 3.6k
receiver/prometheus: wire up direct pdata conversion mechanism #6421
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
Merged
bogdandrutu
merged 37 commits into
open-telemetry:main
from
Aneurysm9:receiver-prometheus-wireUp-roundTrip
Dec 8, 2021
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
1c4423a
receiver/prometheus: roundtrip Prometheus->Pdata direct conversion wi…
odeke-em 5cf4213
Retrofit top level package for pdata comparisons
odeke-em 959a3ed
Reuse for pdata metrics creators from PR #5231
odeke-em de159f6
Shed all in-code direct references to OpenCensus
odeke-em a90ea33
Merge remote-tracking branch 'origin/main' into receiver-prometheus-w…
Aneurysm9 20bf876
receiver/prometheus: fix tests
Aneurysm9 0874f0f
receiver/prometheus: buffer metrics in builder to avoid issues with o…
Aneurysm9 4739bcf
Merge remote-tracking branch 'origin/main' into receiver-prometheus-w…
Aneurysm9 1c85958
receiver/prometheus: restore prom->OC->pdata pipeline
Aneurysm9 65fd778
receiver/prometheus: add feature gate to control whether to use OpenC…
Aneurysm9 6770a1c
receiver/prometheus: localize metrics test helpers
Aneurysm9 9208e41
receiver/prometheus: store metrics in a map in metricbuilder to avoid…
Aneurysm9 8845e18
receiver/prometheus: run component tests against both OC and pdata ex…
Aneurysm9 e710275
receiver/prometheus: ensure OC metrics builder tests are deterministic
Aneurysm9 5a56ab7
receiver/prometheus: restore replace directive to ensure use of local…
Aneurysm9 f862b94
receiver/prometheus: fix lint issues
Aneurysm9 598f4a2
receiver/prometheus: fix lint issues
Aneurysm9 2112e47
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Aneurysm9 838f7a5
make porto
Aneurysm9 7e04b44
receiver/prometheus: run e2e tests in parallel to avoid doubling test…
Aneurysm9 d3ff42a
Revert "receiver/prometheus: run e2e tests in parallel to avoid doubl…
Aneurysm9 4fb78ab
receiver/prometheus: address PR feedback
Aneurysm9 f293579
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Aneurysm9 514e284
receiver/prometheus: ensure test helper can extract timestamp from me…
Aneurysm9 ac4dbd9
receiver/prometheus: tests should not be expecting empty label values
Aneurysm9 29dfb74
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Aneurysm9 ae0559b
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Aneurysm9 d0bd35d
make porto
Aneurysm9 4922d5c
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Aneurysm9 5f52842
receiver/prometheus: remove gauge histogram pdata adjustment tests
Aneurysm9 589a21d
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Aneurysm9 ad029fa
Merge remote-tracking branch 'a9/receiver-prometheus-wireUp-roundTrip…
Aneurysm9 24060cf
receiver/prometheus: remove unused gauge histogram data generator helper
Aneurysm9 4fce276
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Aneurysm9 9344131
Fix lint errors
Aneurysm9 5c67cc5
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Aneurysm9 9ed90fe
receiver/prometheus: Add comments detailing use of locks in metrics a…
Aneurysm9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
receiver/prometheusreceiver/internal/metricsutil_pdata_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package internal // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver/internal" | ||
|
|
||
| import "go.opentelemetry.io/collector/model/pdata" | ||
|
|
||
| type kv struct { | ||
| Key, Value string | ||
| } | ||
|
|
||
| func distPointPdata(ts pdata.Timestamp, bounds []float64, counts []uint64) *pdata.HistogramDataPoint { | ||
| hdp := pdata.NewHistogramDataPoint() | ||
| hdp.SetExplicitBounds(bounds) | ||
| hdp.SetBucketCounts(counts) | ||
| hdp.SetTimestamp(ts) | ||
| var sum float64 | ||
| var count uint64 | ||
| for i, bcount := range counts { | ||
| count += bcount | ||
| if i > 0 { | ||
| sum += float64(bcount) * bounds[i-1] | ||
| } | ||
| } | ||
| hdp.SetCount(count) | ||
| hdp.SetSum(sum) | ||
|
|
||
| return &hdp | ||
| } | ||
|
|
||
| func cumulativeDistMetricPdata(name string, kvp []*kv, startTs pdata.Timestamp, points ...*pdata.HistogramDataPoint) *pdata.Metric { | ||
| metric := pdata.NewMetric() | ||
| metric.SetName(name) | ||
| metric.SetDataType(pdata.MetricDataTypeHistogram) | ||
| histogram := metric.Histogram() | ||
| histogram.SetAggregationTemporality(pdata.MetricAggregationTemporalityCumulative) | ||
|
|
||
| destPointL := histogram.DataPoints() | ||
| // By default the AggregationTemporality is Cumulative until it'll be changed by the caller. | ||
| for _, point := range points { | ||
| destPoint := destPointL.AppendEmpty() | ||
| point.CopyTo(destPoint) | ||
| point.SetStartTimestamp(startTs) | ||
| attrs := destPoint.Attributes() | ||
| for _, kv := range kvp { | ||
| attrs.InsertString(kv.Key, kv.Value) | ||
| } | ||
| } | ||
| return &metric | ||
| } | ||
|
|
||
| func doublePointPdata(ts pdata.Timestamp, value float64) *pdata.NumberDataPoint { | ||
| ndp := pdata.NewNumberDataPoint() | ||
| ndp.SetTimestamp(ts) | ||
| ndp.SetDoubleVal(value) | ||
|
|
||
| return &ndp | ||
| } | ||
|
|
||
| func gaugeMetricPdata(name string, kvp []*kv, startTs pdata.Timestamp, points ...*pdata.NumberDataPoint) *pdata.Metric { | ||
| metric := pdata.NewMetric() | ||
| metric.SetName(name) | ||
| metric.SetDataType(pdata.MetricDataTypeGauge) | ||
|
|
||
| destPointL := metric.Gauge().DataPoints() | ||
| for _, point := range points { | ||
| destPoint := destPointL.AppendEmpty() | ||
| point.CopyTo(destPoint) | ||
| point.SetStartTimestamp(startTs) | ||
| attrs := destPoint.Attributes() | ||
| for _, kv := range kvp { | ||
| attrs.InsertString(kv.Key, kv.Value) | ||
| } | ||
| } | ||
| return &metric | ||
| } | ||
|
|
||
| func summaryPointPdata(ts pdata.Timestamp, count uint64, sum float64, quantiles, values []float64) *pdata.SummaryDataPoint { | ||
| sdp := pdata.NewSummaryDataPoint() | ||
| sdp.SetTimestamp(ts) | ||
| sdp.SetCount(count) | ||
| sdp.SetSum(sum) | ||
| qvL := sdp.QuantileValues() | ||
| for i := 0; i < len(quantiles); i++ { | ||
| qvi := qvL.AppendEmpty() | ||
| qvi.SetQuantile(quantiles[i]) | ||
| qvi.SetValue(values[i]) | ||
| } | ||
| return &sdp | ||
| } | ||
|
|
||
| func summaryMetricPdata(name string, kvp []*kv, startTs pdata.Timestamp, points ...*pdata.SummaryDataPoint) *pdata.Metric { | ||
| metric := pdata.NewMetric() | ||
| metric.SetName(name) | ||
| metric.SetDataType(pdata.MetricDataTypeSummary) | ||
|
|
||
| destPointL := metric.Summary().DataPoints() | ||
| for _, point := range points { | ||
| destPoint := destPointL.AppendEmpty() | ||
| point.CopyTo(destPoint) | ||
| point.SetStartTimestamp(startTs) | ||
| attrs := destPoint.Attributes() | ||
| for _, kv := range kvp { | ||
| attrs.InsertString(kv.Key, kv.Value) | ||
| } | ||
| } | ||
| return &metric | ||
| } | ||
|
|
||
| func sumMetricPdata(name string, kvp []*kv, startTs pdata.Timestamp, points ...*pdata.NumberDataPoint) *pdata.Metric { | ||
| metric := pdata.NewMetric() | ||
| metric.SetName(name) | ||
| metric.SetDataType(pdata.MetricDataTypeSum) | ||
| sum := metric.Sum() | ||
| sum.SetAggregationTemporality(pdata.MetricAggregationTemporalityCumulative) | ||
| sum.SetIsMonotonic(true) | ||
|
|
||
| destPointL := sum.DataPoints() | ||
| for _, point := range points { | ||
| destPoint := destPointL.AppendEmpty() | ||
| point.CopyTo(destPoint) | ||
| point.SetStartTimestamp(startTs) | ||
| attrs := destPoint.Attributes() | ||
| for _, kv := range kvp { | ||
| attrs.InsertString(kv.Key, kv.Value) | ||
| } | ||
| } | ||
| return &metric | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is probably simpler just to use
featuregate.IsEnabled(pdataPipelineGate.ID)where it is needed, rather than store it here. Is there a way to set feature gates during a test?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is only a global feature gate registry, so it can't necessarily be used in tests. The feature gate registry also has a lock, so we recommend that the feature status is checked once and stored if it is needed repeatedly. There is no mechanism for operators to change feature gate statuses during program runtime, so it should be safe to read this once and re-use it.