# Production-oriented Collector reference for Tempo, Loki, and Prometheus.
# Verify that your Collector distribution contains every configured component,
# replace backend endpoints/security for your deployment, and never add raw
# content or high-cardinality execution identifiers to metric labels.
# Guide: examples/README.md; design: docs/reference/05-otel-pipeline-and-collector.md.
extensions:
  health_check:
    endpoint: 0.0.0.0:13133

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

processors:
  memory_limiter:
    check_interval: 1s
    limit_mib: 1024
    spike_limit_mib: 256

  batch:
    timeout: 2s
    send_batch_size: 1024
    send_batch_max_size: 2048

  resource/observme:
    attributes:
      - key: telemetry.source
        value: observme
        action: upsert
      - key: service.name
        value: observme-pi-extension
        action: insert
      - key: service.namespace
        value: pi
        action: upsert

  resource/drop_high_cardinality_metric_attrs:
    attributes:
      - key: pi.workflow.id
        action: delete
      - key: pi.workflow.root_agent_id
        action: delete
      - key: pi.agent.id
        action: delete
      - key: pi.agent.parent_id
        action: delete
      - key: pi.agent.root_id
        action: delete
      # Display names and capabilities remain available to Tempo and Loki, but
      # are removed before Prometheus resource-to-label conversion.
      - key: pi.agent.display_name
        action: delete
      - key: pi.agent.capability
        action: delete
      - key: pi.agent.child.display_name
        action: delete
      - key: pi.agent.child.capability
        action: delete
      - key: pi.agent.run.id
        action: delete
      - key: pi.agent.spawn.id
        action: delete
      - key: pi.agent.spawn.tool_call_id
        action: delete
      - key: pi.agent.child.id
        action: delete
      - key: pi.session.id
        action: delete

  # Drops accidental content attributes from logs. Intentional LLM content capture
  # is emitted as already-redacted log bodies and opt-in span attributes.
  attributes/drop_content_attributes:
    actions:
      - key: gen_ai.input.messages
        action: delete
      - key: gen_ai.output.messages
        action: delete
      - key: pi.llm.prompt.redacted
        action: delete
      - key: pi.llm.response.redacted
        action: delete
      - key: pi.llm.thinking.redacted
        action: delete
      - key: pi.tool.arguments.redacted
        action: delete
      - key: pi.tool.result.redacted
        action: delete

exporters:
  otlp/tempo:
    endpoint: tempo:4317
    tls:
      insecure: true
    sending_queue:
      enabled: true
    retry_on_failure:
      enabled: true

  otlphttp/loki:
    endpoint: http://loki:3100/otlp
    sending_queue:
      enabled: true
    retry_on_failure:
      enabled: true

  prometheus:
    endpoint: 0.0.0.0:8889
    # Exporter-wide stale-series/cardinality cleanup for gauges, counters, and
    # histograms. Five minutes exceeds ObservMe's default one-minute active-agent
    # lease; lease-aware PromQL, not expiration, determines liveness.
    metric_expiration: 5m
    resource_to_telemetry_conversion:
      enabled: true

  debug:
    verbosity: basic

service:
  extensions: [health_check]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, resource/observme, batch]
      exporters: [otlp/tempo]

    metrics:
      receivers: [otlp]
      processors: [memory_limiter, resource/observme, resource/drop_high_cardinality_metric_attrs, batch]
      exporters: [prometheus]

    logs:
      receivers: [otlp]
      processors: [memory_limiter, resource/observme, attributes/drop_content_attributes, batch]
      exporters: [otlphttp/loki]
