Skip to content

Latest commit

 

History

History
78 lines (52 loc) · 1.55 KB

File metadata and controls

78 lines (52 loc) · 1.55 KB

Dynatrace OTEL Metrics Exporter

A Go-based OpenTelemetry metrics exporter that sends metrics to Dynatrace via the Metrics Ingestion API.

Features

  • Exports OTEL metrics (counters, gauges, histograms) to Dynatrace
  • Converts OTEL data to Dynatrace's line protocol format
  • Supports authentication via API tokens
  • Configurable endpoints and timeouts

Installation

go get github.com/akahenry/dynatrace-otel-exporter

Usage

Configuration

cfg := config.NewConfig("https://your-env.live.dynatrace.com/api/v2/metrics/ingest", "your-api-token")

Setup with OTEL SDK

import (
    "github.com/akahenry/dynatrace-otel-exporter/config"
    "github.com/akahenry/dynatrace-otel-exporter/dynatrace"
    sdkmetric "go.opentelemetry.io/otel/sdk/metric"
)

cfg := config.NewConfig(endpoint, token)
exporter := dynatrace.NewExporter(cfg)

meterProvider := sdkmetric.NewMeterProvider(
    sdkmetric.WithReader(sdkmetric.NewPeriodicReader(exporter)),
)
otel.SetMeterProvider(meterProvider)

Example

See cmd/main.go for a complete example.

Run the example:

go run cmd/main.go

Dynatrace API

This exporter uses the Dynatrace Metrics Ingestion API with the line protocol format.

  • Counters are sent as count,delta=value
  • Gauges as gauge,value
  • Histograms as gauge,min=min,max=max,sum=sum,count=count

Development

Run tests:

go test ./...

Build:

go build ./...

License

Apache 2.0