feat(codecs): support encoding native Vector metrics in OTLP serializer#25738
Conversation
Adds metric -> OTLP conversion to the OTLP codec's serializer, covering Counter, Gauge, AggregatedHistogram, and AggregatedSummary values via direct prost encoding. Unsupported metric types (Set, Distribution, Sketch) return an error naming the variant. The metric -> OTLP -> metric round trip is deterministic; the reverse direction remains lossy by design (e.g. ExponentialHistogram flattens to AggregatedHistogram).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e9b90ea1a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ik/OPA-5715/implement-otlp-metric-encoder
…P metric encoder Fold the metric namespace into the OTLP metric name (joined with `.`) so namespaced series such as `vector.requests` and `app.requests` keep distinct OTLP identities instead of collapsing to `requests`. Reject pre-epoch metric timestamps instead of casting a negative `i64` nanosecond count into a far-future `u64`; the encoder now returns a descriptive error so the event is dropped rather than emitted with a corrupt timestamp.
…ik/OPA-5715/implement-otlp-metric-encoder
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa8df168a1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
… and fixed other codex issues
…ik/OPA-5715/implement-otlp-metric-encoder
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d548decc43
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5ccc161e79
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7ee8b3dc9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2af64d1066
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
bruceg
left a comment
There was a problem hiding this comment.
This looks broadly appropriate but I am concerned about some of the inefficiencies caused by intermediate owned values (Vec, clones and structs).
…ik/OPA-5715/implement-otlp-metric-encoder
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc23a5351d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ik/OPA-5715/implement-otlp-metric-encoder
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aec7ac7995
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
bruceg
left a comment
There was a problem hiding this comment.
The behavior and calculations look correct so I'm approving as such. There seems to be a lot of room for optimization that we should return to, though, in the form of excess temporaries and copies and repeat operations on the same data.
…ik/OPA-5715/implement-otlp-metric-encoder
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c8be33058
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ik/OPA-5715/implement-otlp-metric-encoder
…ik/OPA-5715/implement-otlp-metric-encoder
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9bbbd8169
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ik/OPA-5715/implement-otlp-metric-encoder
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d36187fc75
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7533cd5632
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
This looks great overall.
I examined the lifecycle of an event from OTEL to Vector to OTEL. Original:
resource.attributes: service.name = "python-hist-summary"
scope: name="py-hist-summary" version="1.0"
metric: name="python.test.histogram" unit="ms"
histogram:
aggregationTemporality: 2
dataPoint:
attributes: route = "/api"
timeUnixNano: 1784658526721324800
count: 10
sum: 42.5
explicitBounds: [1, 5, 10]
bucketCounts: [2, 3, 4, 1]
Final:
{
"resource": { "service.name": "python-hist-summary" },
"scope": { "name": "py-hist-summary", "version": "1.0" },
"metric": { "name": "python.test.histogram", "unit": null },
"histogram": {
"aggregationTemporality": 2,
"dataPoints": [{
"attributes": [ { "route": "/api" } ],
"timeUnixNano": "1784658526721324800",
"count": "10",
"sum": 42.5,
"explicitBounds": [1, 5, 10],
"bucketCounts": ["2", "3", "4", "1"]
}]
}
}Note that unit (from name="python.test.histogram" unit="ms") is missing. I suspect if the original OTEL event had description that would also be missing. But preserving those isn't trivial and not a blocker for this PR.
Throw error if event timestamp is somehow out of u64 range. Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
add metric type to input types accepted by OtlpSerializer Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
@pront main reason we can't preserve those is they're not currently captured in a MetricEvent, we would have to update that struct or do something interesting with tags |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15c22f6c36
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Summary
Vector configuration
How did you test this PR?
Tested using this config:
Change Type
Is this a breaking change?
Does this PR include user facing changes?
no-changeloglabel to this PR.References
Notes
@vectordotdev/vectorto reach out to us regarding this PR.pre-pushhook, please see this template.make fmtmake check-clippy(if there are failures it's possible some of them can be fixed withmake clippy-fix)make testgit merge origin masterandgit push.Cargo.lock), pleaserun
make build-licensesto regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.