Skip to main content

Telemetry Cheatsheet

Namespace:
  • Cognesy\\Telemetry\\
Minimal usage:
Core concepts:
  • TraceContext
  • SpanReference
  • Observation
  • MetricMeasurement
  • TelemetryContinuation
  • InstrumentationProfile
Application services:
  • Telemetry
  • TraceRegistry
  • CompositeTelemetryExporter
Exporter setup:
  • Telemetry takes new TraceRegistry() plus an exporter
  • use CompositeTelemetryExporter([...]) when you want to fan out to multiple backends
  • call flush() after the run to send buffered observations and metrics

Live Interop Suite

Run the live backend interop suite from the monorepo root:
Notes:
  • tests live under packages/telemetry/tests/Integration
  • the suite is opt-in and skips cleanly when disabled
  • backend contract tests cover direct exporter write/read interop
  • runtime smoke tests cover inference, streaming, agent, and AgentCtrl paths
  • inference, streaming, and agent runtime smoke coverage also require OPENAI_API_KEY
  • AgentCtrl smoke coverage also requires a usable codex CLI with working auth/config

Logfire

Basic setup:
Notes:
  • endpoint is the base OTLP URL, not the full /v1/traces path
  • LogfireExporter requires either LogfireConfig or a custom transport
  • practical examples:
    • examples/A03_Troubleshooting/TelemetryLogfire/run.php
    • examples/D05_AgentTroubleshooting/TelemetryLogfire/run.php
    • examples/D05_AgentTroubleshooting/SubagentTelemetryLogfire/run.php

Langfuse

Basic setup:
Notes:
  • Langfuse traces are sent to /api/public/otel/v1/traces
  • request-scoped traces fall back to request ids as session.id values
  • practical examples:
    • examples/A03_Troubleshooting/TelemetryLangfuse/run.php
    • examples/D05_AgentTroubleshooting/TelemetryLangfuse/run.php
    • examples/D05_AgentTroubleshooting/SubagentTelemetryLangfuse/run.php

Runtime wiring

For runtime packages, telemetry is usually attached to an event bus through RuntimeEventBridge and one or more projectors:
Runtime notes:
  • runtime packages own their local projectors and emit serialized data['telemetry'] envelopes
  • telemetry core rehydrates the envelope and correlates spans centrally
  • AgentCtrlTelemetryProjector correlates agent-ctrl by executionId
  • agent_ctrl.session_id is continuation metadata, not the primary trace key
  • request-scoped traces fall back to request ids as session.id values for Langfuse
  • use the Integration suite when you need live backend proof, not just local payload inspection
Adapter namespaces:
  • Cognesy\\Telemetry\\Adapters\\OTel
  • Cognesy\\Telemetry\\Adapters\\Logfire
  • Cognesy\\Telemetry\\Adapters\\Langfuse