Skip to content

OTel: Amplitude exporter for collector #7013

@khvn26

Description

@khvn26

As part of the Open Structured Event Pipeline work, we built a custom OTel Collector with a Go-based Amplitude exporter. The PoC lives in otel/ in the main Flagsmith repo (branch). It needs its own repo for proper versioning, CI/CD, and release management.

Goal

Create a standalone repo (Flagsmith/flagsmith-otel-collector or similar) that houses:

  • The custom Amplitude exporter as a standalone, importable Go module
  • The OCB builder manifest, including ADOT (AWS Distro for OpenTelemetry) components so customers on AWS get X-Ray, CloudWatch, etc. out of the box
  • A Dockerfile for the custom collector image
  • CI/CD with release-please for automated versioning + releases

The exporter module must be independently importable so that users can add it to their own Collector distributions via OCB:

exporters:
  # Add to any OCB manifest
  - gomod: github.com/Flagsmith/flagsmith-otel-collector/exporter/amplitudeexporter v0.1.0

Repo structure

flagsmith-otel-collector/
  exporter/amplitudeexporter/
    go.mod              # Standalone Go module
    config.go           # api_key, endpoint, user_id_attribute, user_id_prefix, events (allowlist)
    factory.go          # NewFactory(), standard OTel Collector exporter interface
    exporter.go         # consumeLogs() → mapLogs() → POST to Amplitude HTTP V2 API
    exporter_test.go    # Unit tests
  builder-config.yaml   # OCB manifest: ADOT + contrib + Amplitude exporter
  Dockerfile            # Multi-stage: Go 1.25 → distroless runtime
  README.md

Amplitude exporter features

  • Maps OTel LogRecords to Amplitude HTTP V2 API events
  • Configurable user_id_attribute + user_id_prefix for identity mapping
  • Reads amplitude.device_id and amplitude.session_id from log attributes for session stitching
  • Glob-based events allowlist for filtering (empty = export all)
  • Retry, timeout, and backoff via OTel Collector helpers
  • Validated e2e against real Amplitude (events visible in dashboard)

Repo setup

  • Create repo (e.g. Flagsmith/flagsmith-otel-collector)
  • Move otel/ contents from the main repo
  • Set up Go module path (github.com/Flagsmith/flagsmith-otel-collector)
  • Ensure the exporter's go.mod is independently importable
  • Update OCB manifest to include ADOT components (X-Ray exporter, CloudWatch exporter, ECS resource detector, etc.) alongside contrib and our Amplitude exporter
  • Add .goreleaser.yml or equivalent for cross-platform binary builds
  • Add release-please configuration for automated versioning (conventional commits)

CI/CD

  • GitHub Actions workflow: lint (golangci-lint) + test (go test) on PRs
  • Release workflow triggered by release-please:
    • Build binaries for linux/amd64, linux/arm64, darwin/amd64, darwin/arm64
    • Build and push Docker image (ghcr.io/flagsmith/flagsmith-otel-collector)
  • Dependabot or renovate for OTel dependency updates (important — OTel releases frequently)

Hardening (can be follow-up issues)

  • Batch size limits (Amplitude max 2000 events per request)
  • insert_id deduplication (currently TraceID+SpanID, needs UUID fallback for log-only records)
  • EU endpoint support (https://api.eu.amplitude.com/2/httpapi)
  • Integration test against Amplitude's API (with a test project key in CI secrets)
  • README with configuration reference, self-hosted deployment guide, and instructions for adding the exporter to custom Collector distributions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions