클로드 코드 모니터링

hackernews | | 💼 비즈니스
#claude #claude code #opentelemetry #tip #모니터링 #비용 추적 #원격 측정 #otel #사용량 추적 #클로드 코드
원문 출처: hackernews · Genesis Park에서 요약 및 분석

요약

Claude Code는 조직 전체의 사용량, 비용 및 도구 활동을 추적하기 위해 OpenTelemetry(OTel)을 통해 원격 측정 데이터를 내보낼 수 있습니다. 시스템은 환경 변수를 설정하여 'OTLP', 'Prometheus' 등의 메트릭 내보내기 exporter를 선택하고, 그룹(gRPC) 프로토콜을 사용하여 수집기 엔드포인트를 구성하는 방식으로 작동합니다. 관리자는 중앙 제어를 위해 관리형 설정 파일을 통해 모든 사용자에 대한 원격 측정 설정을 구성할 수 있으며, 이를 통해 인증 및 내보내기 간격과 같은 구체적인 변수를 관리할 수 있습니다.

본문

Track Claude Code usage, costs, and tool activity across your organization by exporting telemetry data through OpenTelemetry (OTel). Claude Code exports metrics as time series data via the standard metrics protocol, and events via the logs/events protocol. Configure your metrics and logs backends to match your monitoring requirements. Quick start Configure OpenTelemetry using environment variables: The default export intervals are 60 seconds for metrics and 5 seconds for logs. During setup, you may want to use shorter intervals for debugging purposes. Remember to reset these for production use. For full configuration options, see the OpenTelemetry specification. Administrator configuration Administrators can configure OpenTelemetry settings for all users through the managed settings file. This allows for centralized control of telemetry settings across an organization. See the settings precedence for more information about how settings are applied. Example managed settings configuration: Managed settings can be distributed via MDM (Mobile Device Management) or other device management solutions. Environment variables defined in the managed settings file have high precedence and cannot be overridden by users. Configuration details Common configuration variables | Environment Variable | Description | Example Values | |---| CLAUDE_CODE_ENABLE_TELEMETRY | Enables telemetry collection (required) | 1 | OTEL_METRICS_EXPORTER | Metrics exporter types, comma-separated. Use none to disable | console , otlp , prometheus , none | OTEL_LOGS_EXPORTER | Logs/events exporter types, comma-separated. Use none to disable | console , otlp , none | OTEL_EXPORTER_OTLP_PROTOCOL | Protocol for OTLP exporter, applies to all signals | grpc , http/json , http/protobuf | OTEL_EXPORTER_OTLP_ENDPOINT | OTLP collector endpoint for all signals | http://localhost:4317 | OTEL_EXPORTER_OTLP_METRICS_PROTOCOL | Protocol for metrics, overrides general setting | grpc , http/json , http/protobuf | OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | OTLP metrics endpoint, overrides general setting | http://localhost:4318/v1/metrics | OTEL_EXPORTER_OTLP_LOGS_PROTOCOL | Protocol for logs, overrides general setting | grpc , http/json , http/protobuf | OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | OTLP logs endpoint, overrides general setting | http://localhost:4318/v1/logs | OTEL_EXPORTER_OTLP_HEADERS | Authentication headers for OTLP | Authorization=Bearer token | OTEL_EXPORTER_OTLP_METRICS_CLIENT_KEY | Client key for mTLS authentication | Path to client key file | OTEL_EXPORTER_OTLP_METRICS_CLIENT_CERTIFICATE | Client certificate for mTLS authentication | Path to client cert file | OTEL_METRIC_EXPORT_INTERVAL | Export interval in milliseconds (default: 60000) | 5000 , 60000 | OTEL_LOGS_EXPORT_INTERVAL | Logs export interval in milliseconds (default: 5000) | 1000 , 10000 | OTEL_LOG_USER_PROMPTS | Enable logging of user prompt content (default: disabled) | 1 to enable | OTEL_LOG_TOOL_DETAILS | Enable logging of tool parameters and input arguments in tool events: Bash commands, MCP server and tool names, skill names, and tool input (default: disabled) | 1 to enable | OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | Metrics temporality preference (default: delta ). Set to cumulative if your backend expects cumulative temporality | delta , cumulative | CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS | Interval for refreshing dynamic headers (default: 1740000ms / 29 minutes) | 900000 | Metrics cardinality control The following environment variables control which attributes are included in metrics to manage cardinality: | Environment Variable | Description | Default Value | Example to Disable | |---| OTEL_METRICS_INCLUDE_SESSION_ID | Include session.id attribute in metrics | true | false | OTEL_METRICS_INCLUDE_VERSION | Include app.version attribute in metrics | false | true | OTEL_METRICS_INCLUDE_ACCOUNT_UUID | Include user.account_uuid and user.account_id attributes in metrics | true | false | These variables help control the cardinality of metrics, which affects storage requirements and query performance in your metrics backend. Lower cardinality generally means better performance and lower storage costs but less granular data for analysis. For enterprise environments that require dynamic authentication, you can configure a script to generate headers dynamically: Settings configuration Add to your .claude/settings.json : Script requirements The script must output valid JSON with string key-value pairs representing HTTP headers: Refresh behavior The headers helper script runs at startup and periodically thereafter to support token refresh. By default, the script runs every 29 minutes. Customize the interval with the CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MS environment variable. Multi-team organization support Organizations with multiple teams or departments can add custom attributes to distinguish between different groups using the OTEL_RESOURCE_ATTRIBUTES environment variable

Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.

공유

관련 저널 읽기

전체 보기 →