Add OpenTelemetry metric exporter integration#3
Merged
Conversation
New opt-in integrations/otelmetric package implementing sdkmetric.Exporter.
It bridges OTel counters, gauges and histograms into the LogTide pipeline as
log entries (one per data point), inheriting the client's service name,
environment, tags and resource attributes — the same pattern as the existing
span exporter. The LogTide ingest endpoint accepts log entries only, so this
reuses the existing transport rather than speaking OTLP to a separate backend.
- one LogEntry per data point with metadata.metric {name, type, value/count
/sum/min/max/bucket_counts/explicit_bounds, attributes, timestamps}
- resource attributes and instrumentation scope propagated into metadata
- nil-client safe before Setup (Export/Flush/Shutdown no-op)
- examples/otelmetric demonstrating counter + histogram export
- README, CHANGELOG and CONFORMANCE (C29) updated
Closes #2
3e42699 to
0afe01b
Compare
When a data point carries an exemplar with trace context, the resulting entry is linked to that trace_id/span_id (via a scope, mirroring the span exporter), and the full exemplar list is recorded under metadata.metric.exemplars (value, time, trace_id, span_id, filtered_attributes). Exemplars are only populated when an exemplar filter is configured and a sampled span is active during measurement, so this is a no-op otherwise.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #2.
Summary
Adds a new opt-in
integrations/otelmetricpackage — an OpenTelemetry metrics exporter that mirrors the existing span exporter (integrations/otelexport, cited as prior art in the issue).It implements
sdkmetric.Exporterand bridges OTel counters, gauges and histograms into the existing LogTide pipeline as log entries (one per data point), so metrics inherit the same service name, environment, tags and resource attributes as logs and traces.Design decision: bridge to the LogTide pipeline, not real OTLP
The issue's prose asks to "integrate with the Hub/Scope model" while the bullets mention "OTLP MetricsExportRequest". These are different architectures. The LogTide ingest endpoint (
scheme://host/api/v1/ingest) accepts log entries only — there is no OTLP metrics endpoint — and a real OTLP client would require a separate backend, contradicting the requirement that metrics carry the same attributes as logs/traces. The cited prior art (otelexport) also bridges into the pipeline rather than speaking OTLP. So this exporter does the same.What's included
integrations/otelmetricimplementingsdkmetric.Exporter(Temporality,Aggregation,Export,ForceFlush,Shutdown)LogEntryper data point withmetadata.metric:name,type(counter/gauge/histogram), value fields (value/count+sum+min+max+bucket_counts+explicit_bounds),attributes, timestampsSetup(Export/Flush/Shutdown are no-ops)examples/otelmetricdemonstrating a counter + histogramotel/metric+otel/sdk/metricpromoted to direct dependenciesTesting
go build ./...,go vet ./...,gofmt, andgo test ./...all pass. Newotelmetric_test.gocovers nil-client safety, integration wiring, temporality/aggregation defaults, and a realExportof a hand-builtResourceMetrics(Sum + Gauge + Histogram) verified via a capturing transport.