Skip to main content
LangSmith 배포의 다양한 서비스는 로그, 메트릭, 트레이스 형태의 텔레메트리 데이터를 생성합니다. Kubernetes 클러스터에 이미 텔레메트리 수집기를 설정해 두었거나, 애플리케이션을 모니터링하기 위해 수집기를 배포하려고 할 수 있습니다. 이 페이지에서는 LangSmith에서 텔레메트리 데이터를 수집하기 위해 OTel Collector를 구성하는 방법을 설명합니다. 아래에서 다루는 모든 개념은 FluentdFluentBit와 같은 다른 수집기에도 적용할 수 있습니다.
이 섹션은 Kubernetes 배포에만 적용됩니다.

Receivers

Logs

다음은 도메인별 컨테이너가 아닌 컨테이너의 로그를 제외하고 자체 파드에서 로그를 읽는 Sidecar 수집기의 예시입니다. Sidecar 구성은 모든 컨테이너의 파일시스템에 접근해야 하기 때문에 유용합니다. DaemonSet도 사용할 수 있습니다.
filelog:
  exclude:
    - "**/otc-container/*.log"
  include:
    - /var/log/pods/${POD_NAMESPACE}_${POD_NAME}_${POD_UID}/*/*.log
  include_file_name: false
  include_file_path: true
  operators:
    - id: container-parser
      type: container
  retry_on_failure:
    enabled: true
  start_at: end
env:
  - name: POD_NAME
    valueFrom:
      fieldRef:
        fieldPath: metadata.name
  - name: POD_NAMESPACE
    valueFrom:
      fieldRef:
        fieldPath: metadata.namespace
  - name: POD_UID
    valueFrom:
      fieldRef:
        fieldPath: metadata.uid
volumes:
  - name: varlogpods
    hostPath:
      path: /var/log/pods
volumeMounts:
  - name: varlogpods
    mountPath: /var/log/pods
    readOnly: true
이 구성은 해당 네임스페이스의 파드에 대한 ‘get’, ‘list’, ‘watch’ 권한이 필요합니다.

Metrics

메트릭은 Prometheus 엔드포인트를 사용하여 스크랩할 수 있습니다. 메트릭을 가져올 때 쿼리 중복을 방지하기 위해 단일 인스턴스 Gateway 수집기를 사용할 수 있습니다. 다음 구성은 기본적으로 명명된 모든 LangSmith 서비스를 스크랩합니다:
prometheus:
  config:
    scrape_configs:
      - job_name: langsmith-services
        metrics_path: /metrics
        scrape_interval: 15s
        # Only scrape endpoints in the LangSmith namespace
        kubernetes_sd_configs:
          - role: endpoints
            namespaces:
              names: [<langsmith-namespace>]
        relabel_configs:
          # Only scrape services with the name langsmith-.*
          - source_labels: [__meta_kubernetes_service_name]
            regex: "langsmith-.*"
            action: keep
          # Only scrape ports with the following names
          - source_labels: [__meta_kubernetes_endpoint_port_name]
            regex: "(backend|platform|playground|redis-metrics|postgres-metrics|metrics)"
            action: keep
          # Promote useful metadata into regular labels
          - source_labels: [__meta_kubernetes_service_name]
            target_label: k8s_service
          - source_labels: [__meta_kubernetes_pod_name]
            target_label: k8s_pod
          # Replace the default "host:port" as Prom's instance label
          - source_labels: [__address__]
            target_label: instance
이 구성은 해당 네임스페이스의 파드, 서비스, 엔드포인트에 대한 ‘get’, ‘list’, ‘watch’ 권한이 필요합니다.

Traces

트레이스의 경우 OTLP 수신기를 활성화해야 합니다. 다음 구성을 사용하여 포트 4318에서 HTTP 트레이스를 수신하고, 포트 4317에서 GRPC를 수신할 수 있습니다:
otlp:
  protocols:
    grpc:
      endpoint: 0.0.0.0:4317
    http:
      endpoint: 0.0.0.0:4318

Processors

권장 OTEL Processors

OTel 수집기를 사용할 때 다음 프로세서를 권장합니다:
  • Batch Processor: 데이터를 익스포터로 전송하기 전에 배치로 그룹화합니다.
  • Memory Limiter: 수집기가 과도한 메모리를 사용하여 충돌하는 것을 방지합니다. 소프트 제한에 도달하면 수집기가 새 데이터 수신을 중지합니다.
  • Kubernetes Attributes Processor: 파드 이름과 같은 Kubernetes 메타데이터를 텔레메트리 데이터에 추가합니다.

Exporters

익스포터는 원하는 외부 엔드포인트를 가리키기만 하면 됩니다. 다음 구성을 사용하면 로그, 메트릭, 트레이스에 대해 각각 별도의 엔드포인트를 구성할 수 있습니다:
otlphttp/logs:
  endpoint: <your_logs_endpoint>
otlphttp/metrics:
  endpoint: <your_metrics_endpoint>
otlphttp/traces:
  endpoint: <your_traces_endpoint>
OTel Collector는 Datadog 엔드포인트로 직접 내보내기도 지원합니다.

수집기 구성 예시: Logs Sidecar

mode: sidecar
image: otel/opentelemetry-collector-contrib
config:
  receivers:
    filelog:
      exclude:
        - "**/otc-container/*.log"
      include:
        - /var/log/pods/${POD_NAMESPACE}_${POD_NAME}_${POD_UID}/*/*.log
      include_file_name: false
      include_file_path: true
      operators:
        - id: container-parser
          type: container
      retry_on_failure:
        enabled: true
      start_at: end
  processors:
    batch:
      send_batch_size: 8192
      timeout: 10s
    memory_limiter:
      check_interval: 1m
      limit_percentage: 90
      spike_limit_percentage: 80
  exporters:
    otlphttp/logs:
      endpoint: <your-endpoint>
  service:
    pipelines:
      logs/langsmith:
        receivers: [filelog]
        processors: [batch, memory_limiter]
        exporters: [otlphttp/logs]
env:
  - name: POD_NAME
    valueFrom:
      fieldRef:
        fieldPath: metadata.name
  - name: POD_NAMESPACE
    valueFrom:
      fieldRef:
        fieldPath: metadata.namespace
  - name: POD_UID
    valueFrom:
      fieldRef:
        fieldPath: metadata.uid
volumes:
  - name: varlogpods
    hostPath:
      path: /var/log/pods
volumeMounts:
  - name: varlogpods
    mountPath: /var/log/pods
    readOnly: true

수집기 구성 예시: Metrics and Traces Gateway

mode: deployment
image: otel/opentelemetry-collector-contrib
config:
  receivers:
    prometheus:
      config:
        scrape_configs:
          - job_name: langsmith-services
            metrics_path: /metrics
            scrape_interval: 15s
            # Only scrape endpoints in the LangSmith namespace
            kubernetes_sd_configs:
              - role: endpoints
                namespaces:
                  names: [<langsmith-namespace>]
            relabel_configs:
              # Only scrape services with the name langsmith-.*
              - source_labels: [__meta_kubernetes_service_name]
                regex: "langsmith-.*"
                action: keep
              # Only scrape ports with the following names
              - source_labels: [__meta_kubernetes_endpoint_port_name]
                regex: "(backend|platform|playground|redis-metrics|postgres-metrics|metrics)"
                action: keep
              # Promote useful metadata into regular labels
              - source_labels: [__meta_kubernetes_service_name]
                target_label: k8s_service
              - source_labels: [__meta_kubernetes_pod_name]
                target_label: k8s_pod
              # Replace the default "host:port" as Prom's instance label
              - source_labels: [__address__]
                target_label: instance
    otlp:
      protocols:
        grpc:
          endpoint: 0.0.0.0:4317
        http:
          endpoint: 0.0.0.0:4318
  processors:
    batch:
      send_batch_size: 8192
      timeout: 10s
    memory_limiter:
      check_interval: 1m
      limit_percentage: 90
      spike_limit_percentage: 80
  exporters:
    otlphttp/metrics:
      endpoint: <metrics_endpoint>
    otlphttp/traces:
      endpoint: <traces_endpoint>
  service:
    pipelines:
      metrics/langsmith:
        receivers: [prometheus]
        processors: [batch, memory_limiter]
        exporters: [otlphttp/metrics]
      traces/langsmith:
        receivers: [otlp]
        processors: [batch, memory_limiter]
        exporters: [otlphttp/traces]

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I