-
Notifications
You must be signed in to change notification settings - Fork 9.6k
OTLP receiver: Generate target_info
samples between the earliest and latest samples per resource
#16737
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
base: main
Are you sure you want to change the base?
Conversation
target_info
samples between the earliest and latest samples per resource
a9795be
to
3d4a41a
Compare
1bc16ac
to
13d83d2
Compare
13d83d2
to
26e5dcb
Compare
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.
Pull Request Overview
Adds support for generating multiple target_info
samples between the earliest and latest OTLP metric samples for each resource, spaced at half the lookback delta.
- Introduce
LookbackDelta
configuration throughout handlers and API. - Track earliest and latest timestamps per resource in the OTLP-to-remote-write converter.
- Generate a
target_info
time series sample at everylookbackDelta/2
interval plus the final timestamp. - Update tests to cover the multi-sample
target_info
behavior and bump changelog.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
web/web.go | Pass LookbackDelta into NewAPI |
web/api/v1/errors_test.go | Add lookbackDelta parameter to test helper invocation |
web/api/v1/api.go | Wire lookbackDelta through to OTLP write handler |
storage/remote/write_handler.go | Extend OTLPOptions and exporter to carry lookbackDelta |
storage/remote/otlptranslator/prometheusremotewrite/metrics_to_prw.go | Add earliest/latest timestamp tracking in converter |
storage/remote/otlptranslator/prometheusremotewrite/helper.go | Implement multi-sample logic in addResourceTargetInfo |
storage/remote/otlptranslator/prometheusremotewrite/metrics_to_prw_test.go | New test for spaced target_info samples |
CHANGELOG.md | Document the bugfix |
Comments suppressed due to low confidence (3)
storage/remote/otlptranslator/prometheusremotewrite/metrics_to_prw.go:55
- [nitpick] Comment should start with the field name
LookbackDelta
to follow Go doc conventions, e.g.// LookbackDelta is the PromQL engine lookback delta used for target_info spacing.
// Lookback delta is the PromQL engine lookback delta.
storage/remote/otlptranslator/prometheusremotewrite/helper.go:658
- [nitpick] The variable name
ts
is ambiguous (could be confused with timestamp). Consider renaming toseries
ortargetSeries
for clarity.
ts, _ := converter.getOrCreateTimeSeries(labels)
storage/remote/otlptranslator/prometheusremotewrite/helper.go:438
- The calls to
min
andmax
rely on helper functions that aren’t shown here. Ensure thatmin(a,b)
andmax(a,b)
are defined forpcommon.Timestamp
, otherwise these will fail to compile.
minTimestamp = min(minTimestamp, ts)
e19cbd6
to
4567c6d
Compare
…latest samples per resource Modify the OTLP receiver to generate target_info samples between the earliest and latest samples per resource instead of only one for the latest timestamp. The samples are spaced lookback delta/2 apart. Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
4567c6d
to
d5761d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe 8000 this comment to others. Learn more.
Why do we need a sample coinciding with the latest timestamp?
Having one at the earliest timestamp and then one at half the lookback delta until we reach or exceed the latest timestamp should be enough, shouldn't it?
@beorn7 My algorithm doesn't exceed the latest timestamp, it ends exactly at the latest timestamp. Is there any benefit to modify it, so it instead potentially exceeds the latest timestamp? I don't see it at least. |
What I mean is to not add a sample that exceed the latest timestamp, but also don't add any sample that doesn't match the lookbackdelta/2 repeating pattern. Just add one at the beginning of the range, and then every lookbackdelta/2 duration, until you have added the last sample before the end of the range. |
@beorn7 Isn't the problem with this approach that you can miss the latest |
Oh yes, you are right. Now I got it. (Maybe it should be explained in a way so that even people like me will understand it. :) So this looks plausible to me, then. I'll leave the codelevel review to the OTLP receiver experts. |
@beorn7 Hahahaha! :) I can update the PR description to be explicit about this, thanks for the feedback! |
Modify the OTLP receiver to generate
target_info
samples starting at the earliest and ending at the latest samples per resource, instead of only one for the latest timestamp. Between those samples, one sample is generated every lookback delta/2 timestamps. The idea behind generatingtarget_info
samples spaced lookback delta/2 apart is to ensure thattarget_info
is found for every connected time series sample generated from the same request.The motivation behind this fix is that I realized when debugging strange
info
PromQL function behaviour that the reason was thattarget_info
started one minute later than the time series it was being joined with (byinfo
). See Grafana Mimir issue for reference.