Skip to content

Add OpenTelemetry Logs Ingestion Support - #404

Open
a-khaledf wants to merge 2 commits into
mainfrom
khaled/feat/ingest-otel
Open

a-khaledf wants to merge 2 commits into
mainfrom
khaled/feat/ingest-otel

Conversation

@a-khaledf

Copy link
Copy Markdown

Summary

This PR adds support for ingesting logs via the OpenTelemetry /v1/logs endpoint, controllable via the AXIOM_OTEL_ENABLED environment variable or the SetOtelEnabled client option.

Changes

New Features

  • IngestOtel function: New method on Client and DatasetsService that sends events to the /v1/logs endpoint in proper OTLP (OpenTelemetry Protocol) JSON format
  • SetOtelEnabled client option: Programmatically enable OTel-based ingestion
  • AXIOM_OTEL_ENABLED environment variable: Set to "true" or "1" to enable OTel ingestion globally
  • Automatic routing: When OTel is enabled, IngestEvents automatically delegates to IngestOtel

Implementation Details

  • Events are converted to OTLP log format using go.opentelemetry.io/collector/pdata/plog
  • Requests are sent to /v1/logs with X-Axiom-Dataset header specifying the target dataset
  • Content-Type is application/json with zstd compression
  • Event fields are mapped to OTLP log record attributes
  • The _time field is used for the OTLP timestamp if present

Files Changed

  • internal/config/config.go - Added otelEnabled field and getter/setter
  • internal/config/option.go - Added SetOtelEnabled config option
  • axiom/client_options.go - Added SetOtelEnabled client option
  • axiom/client.go - Added IngestOtel alias and mediaTypeOTelLogs constant
  • axiom/datasets.go - Added IngestOtel function and eventsToOTLP helper
  • axiom/datasets_test.go - Added tests for IngestOtel and OTel-enabled IngestEvents
  • internal/config/config_test.go - Added tests for OTel config options

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.

1 participant