-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
receiver/prometheus: use actual interval startTimeMs for cumulative types #3694
receiver/prometheus: use actual interval startTimeMs for cumulative types #3694
Conversation
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
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.
Please rebase, this PR contains changes already merged
4cd3b20
to
7355a6a
Compare
Rebase done, please take a look @bogdandrutu! |
7355a6a
to
b36a526
Compare
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
Please review @Aneurysm9 @rakyll @dashpole @punya |
b36a526
to
24ceec5
Compare
@@ -166,7 +166,7 @@ func (tr *transaction) initTransaction(ls labels.Labels) error { | |||
tr.instance = instance | |||
} | |||
tr.node, tr.resource = createNodeAndResource(job, instance, mc.SharedLabels().Get(model.SchemeLabel)) | |||
tr.metricBuilder = newMetricBuilder(mc, tr.useStartTimeMetric, tr.startTimeMetricRegex, tr.logger, tr.stalenessStore) | |||
tr.metricBuilder = newMetricBuilder(mc, tr.useStartTimeMetric, tr.startTimeMetricRegex, tr.logger, tr.stalenessStore, tr.startTimeMs) |
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 looks like an Appender is created when the config is loaded: https://github.com/prometheus/prometheus/blob/5cc30b716e23c98863093c0ed39315c1fe7c103e/scrape/manager.go#L257. That would mean that this start time is the start time of the first metric that the collector sees, which is approximately the start time of the collector. That seems like it would be incorrect in many cases. Is there something i'm missing?
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.
Nope, for every Scrape, a new storage.Appender is requested, not when the collector is started. This means that
even a new transaction is created per scrape and at the end either .Commit() or .Rollback() is invoked. This isn't a problem.
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.
Got it, thanks. Is the storage.Appender created after the scrape finishes, or before the scrape is started? We just need to make sure the start time isn't before the metric's timestamp
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.
Another option for the moment is to leave the starttime unset (0) which is conforming with our specs, then fix this the correct timestamp later. This is to unblock the progress.
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.
Got it, thanks. Is the storage.Appender created after the scrape finishes, or before the scrape is started? We just need to make sure the start time isn't before the metric's timestamp
@dashpole we infer that startTime for the very first time that's passed into (*transaction).Append so it will ALWAYS be the first timestamp. initTransaction is lazily loaded and .startTimeMs will ALWAYS be set after the first .Append.
opentelemetry-collector/receiver/prometheusreceiver/internal/transaction.go
Lines 116 to 118 in f804c9c
if tr.startTimeMs < 0 { | |
tr.startTimeMs = t | |
} |
opentelemetry-collector/receiver/prometheusreceiver/internal/transaction.go
Lines 136 to 140 in f804c9c
if tr.isNew { | |
if err := tr.initTransaction(ls); err != nil { | |
return 0, err | |
} | |
} |
@dashpole to answer your question about Prometheus (but it is irrelevant to this code) the storage.Appender is created before the scrape begins per https://github.com/prometheus/prometheus/blob/1a430e5f894d6575478bcef52d25bfbe7134947e/scrape/scrape.go#L1182-L1237 or visually
Another option for the moment is to leave the starttime unset (0) which is conforming with our specs, then fix this the correct timestamp later. This is to unblock the progress.
@bogdandrutu thanks for raising this, I didn't know about using 0 conforming with specs. No, we are already good, the intervalStartTime is inferred from the very first start time when (*transaction).Append so we are all set.
…ypes With this change, we now infer the actual interval startTime for cumulative types from the original starttime interval reinforcing what the OpenTelemetry Proto recommendations say in https://github.com/open-telemetry/opentelemetry-proto/blob/bc8ee79d8e01faf3310af2987268e94285f354da/opentelemetry/proto/metrics/v1/metrics.proto#L132-L140 Fixes open-telemetry#3691
24ceec5
to
f7cee29
Compare
Thank you for the review @dashpole and @bogdandrutu! |
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
Wire up and use the direct Prometheus->Pdata conversion end to end. With this change the receiver will no longer need OpenCensus. This change will involve more follow-ups that just migrate over the tests, because we don't want a super bloated/massive PR. Fixes open-telemetry#3691 Depends on PR open-telemetry#3694 Depends on PR open-telemetry#3695
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR #3674 Requires PR #3694 Updates #3691
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
Wire up and use the direct Prometheus->Pdata conversion end to end. With this change the receiver will no longer need OpenCensus. This change will involve more follow-ups that just migrate over the tests, because we don't want a super bloated/massive PR. Fixes open-telemetry#3691 Depends on PR open-telemetry#3694 Depends on PR open-telemetry#3695
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
Wire up and use the direct Prometheus->Pdata conversion end to end. With this change the receiver will no longer need OpenCensus. This change will involve more follow-ups that just migrate over the tests, because we don't want a super bloated/massive PR. Fixes open-telemetry#3691 Depends on PR open-telemetry#3694 Depends on PR open-telemetry#3695
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
Wire up and use the direct Prometheus->Pdata conversion end to end. With this change the receiver will no longer need OpenCensus. This change will involve more follow-ups that just migrate over the tests, because we don't want a super bloated/massive PR. Fixes open-telemetry#3691 Depends on PR open-telemetry#3694 Depends on PR open-telemetry#3695
This change wires together the logic to convert the pdata converters into a method ToMetricPdata that appends converted metrics. The next change or two, will then hook everything up directly and will allow us to delete all the prior code!! Updates #3137 Updates PR open-telemetry#3674 Requires PR open-telemetry#3694 Updates open-telemetry#3691
Wire up and use the direct Prometheus->Pdata conversion end to end. With this change the receiver will no longer need OpenCensus. This change will involve more follow-ups that just migrate over the tests, because we don't want a super bloated/massive PR. Fixes open-telemetry#3691 Depends on PR open-telemetry#3694 Depends on PR open-telemetry#3695
…thout OpenCensus Wire up and use the direct Prometheus->Pdata conversion end to end. With this change the receiver will no longer need OpenCensus. This change will involve more follow-ups that just migrate over the tests, because we don't want a super bloated/massive PR. Fixes #4892 Depends on PR open-telemetry/opentelemetry-collector#3694 Depends on PR open-telemetry/opentelemetry-collector#3695
* receiver/prometheus: roundtrip Prometheus->Pdata direct conversion without OpenCensus Wire up and use the direct Prometheus->Pdata conversion end to end. With this change the receiver will no longer need OpenCensus. This change will involve more follow-ups that just migrate over the tests, because we don't want a super bloated/massive PR. Fixes #4892 Depends on PR open-telemetry/opentelemetry-collector#3694 Depends on PR open-telemetry/opentelemetry-collector#3695 * Retrofit top level package for pdata comparisons * Reuse for pdata metrics creators from PR #5231 * Shed all in-code direct references to OpenCensus * receiver/prometheus: fix tests Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: buffer metrics in builder to avoid issues with out-of-order exposition Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: restore prom->OC->pdata pipeline Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: add feature gate to control whether to use OpenCensus or pdata directly Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: localize metrics test helpers Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: store metrics in a map in metricbuilder to avoid issues with out-of-order exposition data Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: run component tests against both OC and pdata export paths Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: ensure OC metrics builder tests are deterministic Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: restore replace directive to ensure use of local copy of opencensus translator during development Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: fix lint issues Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: fix lint issues Signed-off-by: Anthony J Mirabella <[email protected]> * make porto Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: run e2e tests in parallel to avoid doubling test suite runtime Signed-off-by: Anthony J Mirabella <[email protected]> * Revert "receiver/prometheus: run e2e tests in parallel to avoid doubling test suite runtime" This reverts commit 7e04b44. * receiver/prometheus: address PR feedback Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: ensure test helper can extract timestamp from metrics of any type Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: tests should not be expecting empty label values Signed-off-by: Anthony J Mirabella <[email protected]> * make porto Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: remove gauge histogram pdata adjustment tests Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: remove unused gauge histogram data generator helper Signed-off-by: Anthony J Mirabella <[email protected]> * Fix lint errors Signed-off-by: Anthony J Mirabella <[email protected]> * receiver/prometheus: Add comments detailing use of locks in metrics adjuster. Signed-off-by: Anthony J Mirabella <[email protected]> Co-authored-by: Emmanuel T Odeke <[email protected]>
With this change, we now infer the actual interval startTime
for cumulative types from the original starttime interval reinforcing
what the OpenTelemetry Proto recommendations say in
https://github.com/open-telemetry/opentelemetry-proto/blob/bc8ee79d8e01faf3310af2987268e94285f354da/opentelemetry/proto/metrics/v1/metrics.proto#L132-L140
Fixes #3691