-
Notifications
You must be signed in to change notification settings - Fork 500
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
Time is not optional in DataPoints #2367
Time is not optional in DataPoints #2367
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2367 +/- ##
=====================================
Coverage 79.5% 79.5%
=====================================
Files 123 123
Lines 21492 21488 -4
=====================================
Hits 17096 17096
+ Misses 4396 4392 -4 ☔ View full report in Codecov by Sentry. |
@@ -97,9 +97,9 @@ pub struct DataPoint<T> { | |||
/// time series. | |||
pub attributes: Vec<KeyValue>, | |||
/// The time when the time series was started. | |||
pub start_time: Option<SystemTime>, | |||
pub start_time: SystemTime, |
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'd be good to mention in changelog as this is breaking anyone writing own exporters. I expect a lot more changes in this area, so it is probably better to club them all into one changelog entry.
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.
Start time is marked optional by spec.
@cijothomas Currently, the SDK would always populate it, but do you think there could be a scenario where we wouldn't populate the start time. With MetricProducer or something else?
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.
Yes, producer might not provide it. so keeping Option for startTime might be safer then?
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.
Yes.
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.
@fraillt Could you keep Option<startTime>
? Sorry I merged this already, so needs to be a separate PR.
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.
I was reading https://opentelemetry.io/docs/specs/otel/metrics/data-model/ and got impression that these fields can be in fact not optional...
Basically everything is required, except for Gauge
one field:
(optional) A timestamp (start_time_unix_nano) which best represents the first possible moment a measurement could be recorded. This is commonly set to the timestamp when a metric collection system started.
In the proto definition same field has comment (emphasis is mine):
// StartTimeUnixNano is optional but strongly encouraged, see the detailed comments above Metric.
Maybe I'm reading outdated/invalid documentation?
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.
(optional) A timestamp (start_time_unix_nano) which best represents the firs
^ This part is where startTime is mentioned to be optional. An external system interfacing via Producer to OTel may not have startTime.
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.
Just want to understand better... at the moment it's not possible that Gauge will have None
using SdkMeterProvider.
So basically, if you want to support Gauge
with optional start time, at minimum you would have to implement your own, MeterProvider
, InstrumentProvider
, and your own SyncInstrument
. Which also means that you need to implement your own collect implementation as well.
I understand that this is part of api
and user should be able to do so. I'm wondering if you know a single example where anyone actually does that ? (implement core functionality itself' instead of using SdkMeterProvider).
Or in other words, do you have any example that SdkMeterProvider
is not suitable and users write their own implementation of metrics ? (just curious)
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.
When we start supporting Producers concept, where users aggregate metrics elsewhere and bridge it to OTel, startTime can be missing.
The current sdk has no scenario for startTime being optional, but we just want to make sure our public API remains stable even when adding Producer support.
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.
LGTM!
Co-authored-by: Cijo Thomas <[email protected]>
Changes
Make
start_time
andtime
non optional inDataPoint<T>
(used forSum
andGauge
).Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes