# OpenTelemetry Collector pipeline for the shop namespace.
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
  prometheus:
    config:
      scrape_configs:
        - job_name: shop-services
          scrape_interval: 15s
          static_configs:
            - targets: [192.0.2.11:9090, 192.0.2.12:9090]
  filelog:
    include: [/var/log/pods/shop_*/*/*.log]
    start_at: end
    operators:
      - type: container
        id: parse-cri
      - type: json_parser
        parse_from: body
        timestamp:
          parse_from: attributes.ts
          layout_type: strptime
          layout: '%Y-%m-%dT%H:%M:%S.%LZ'
        severity:
          parse_from: attributes.level

processors:
  batch:
    timeout: 5s
    send_batch_size: 8192
    send_batch_max_size: 16384
  memory_limiter:
    check_interval: 1s
    limit_mib: 512
    spike_limit_mib: 128
  resourcedetection:
    detectors: [env, system]
    timeout: 2s
  attributes/redact:
    actions:
      - key: enduser.id
        action: hash
      - key: http.request.header.authorization
        action: delete
  transform/semconv:
    error_mode: ignore
    trace_statements:
      - context: span
        statements:
          - set(attributes["http.request.method"], attributes["http.method"]) where attributes["http.method"] != nil
          - delete_key(attributes, "http.method")

exporters:
  otlphttp/traces:
    endpoint: https://telemetry.example.com/v1/traces
    compression: gzip
    retry_on_failure:
      enabled: true
      initial_interval: 5s
      max_elapsed_time: 300s
    sending_queue:
      enabled: true
      queue_size: 5000
  prometheusremotewrite:
    endpoint: https://metrics.example.com/api/v1/write
    resource_to_telemetry_conversion:
      enabled: true
  debug:
    verbosity: basic

extensions:
  health_check:
    endpoint: 0.0.0.0:13133

service:
  extensions: [health_check]
  pipelines:
    traces:
      receivers: [otlp]
      processors: [memory_limiter, resourcedetection, attributes/redact, transform/semconv, batch]
      exporters: [otlphttp/traces]
    metrics:
      receivers: [otlp, prometheus]
      processors: [memory_limiter, resourcedetection, batch]
      exporters: [prometheusremotewrite]
    logs:
      receivers: [otlp, filelog]
      processors: [memory_limiter, attributes/redact, batch]
      exporters: [otlphttp/traces, debug]
  telemetry:
    logs:
      level: info
    metrics:
      level: detailed
