Skip to content

Add OpenTelemetry metric exporter integration#3

Merged
Polliog merged 4 commits into
mainfrom
feat/otel-metric-exporter
Jun 20, 2026
Merged

Add OpenTelemetry metric exporter integration#3
Polliog merged 4 commits into
mainfrom
feat/otel-metric-exporter

Conversation

@Polliog

@Polliog Polliog commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Closes #2.

Summary

Adds a new opt-in integrations/otelmetric package — an OpenTelemetry metrics exporter that mirrors the existing span exporter (integrations/otelexport, cited as prior art in the issue).

It implements sdkmetric.Exporter and 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/otelmetric implementing sdkmetric.Exporter (Temporality, Aggregation, Export, ForceFlush, Shutdown)
  • One LogEntry per data point with metadata.metric: name, type (counter/gauge/histogram), value fields (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 are no-ops)
  • examples/otelmetric demonstrating a counter + histogram
  • README, CHANGELOG (1.0.0) and CONFORMANCE (C29) updated
  • otel/metric + otel/sdk/metric promoted to direct dependencies

Testing

go build ./..., go vet ./..., gofmt, and go test ./... all pass. New otelmetric_test.go covers nil-client safety, integration wiring, temporality/aggregation defaults, and a real Export of a hand-built ResourceMetrics (Sum + Gauge + Histogram) verified via a capturing transport.

Polliog added 3 commits June 19, 2026 22:23
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
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.
@Polliog Polliog merged commit 7eeae63 into main Jun 20, 2026
4 checks passed
@Polliog Polliog deleted the feat/otel-metric-exporter branch June 20, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: OpenTelemetry metrics exporter

1 participant