Skip to content

feat(tracing): provider-agnostic exporters with first-class PostHog support - #970

Closed
Spherrrical wants to merge 1 commit into
musa/agent-skills-supportfrom
musa/posthog-observability-export
Closed

feat(tracing): provider-agnostic exporters with first-class PostHog support#970
Spherrrical wants to merge 1 commit into
musa/agent-skills-supportfrom
musa/posthog-observability-export

Conversation

@Spherrrical

Copy link
Copy Markdown
Collaborator

Summary

Adds a provider-agnostic telemetry export layer to brightstaff, driven by a new tracing.exporters config list, and ships PostHog as the first first-class integration. Users point at their PostHog URL + project token and every LLM call is streamed as a $ai_generation event — as simple as LiteLLM's posthog callback.

tracing:
  random_sampling: 100
  exporters:
    - type: posthog
      url: https://us.i.posthog.com
      api_key: $POSTHOG_API_KEY
      distinct_id_header: x-user-id   # optional; else anonymous

Changes

  • Config: new tracing.exporters[] (schema + Exporter/PosthogExporter in common), extensible to other backends via an internally-tagged enum.
  • PostHog exporter: new SpanExporter (posthog_exporter.rs) that filters LLM spans, maps attributes to $ai_* properties (model, provider, latency, tokens, http status, trace ids), and POSTs a /batch/ payload via reqwest. Failures are logged and dropped, never blocking requests.
  • Wiring: init_tracer now composes multiple batch exporters (OTLP + each PostHog exporter); enable gate decoupled so PostHog works without opentracing_grpc_endpoint.
  • distinct_id: resolved from a configurable request header into AppState, stamped on the span as plano.distinct_id; anonymous fallback (\$process_person_profile=false).
  • Span enrichment: now records llm.provider. capture_messages opt-in sends the truncated user preview as $ai_input.
  • Docs/tests: tracing guide + full reference config updated; Rust config + span-mapping tests and a CLI schema test added.

Note: stacked on musa/agent-skills-support (PR #954) to keep this diff scoped to the PostHog work.

@Spherrrical
Spherrrical deleted the musa/posthog-observability-export branch June 22, 2026 20:14
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