Claude Code Integration (Telemetry Setup)
This document describes the architecture for collecting telemetry from Claude Code using OpenTelemetry and storing it directly in Amazon S3 or Google Cloud Storage. This approach allows for the inclu…
This document describes the architecture for collecting telemetry from Claude Code using OpenTelemetry and storing it directly in Amazon S3 or Google Cloud Storage. This approach allows for the inclusion of additional data, such as cost and usage metrics, which are not included if using the standard analytics APIs.
Claude Code versions supported: Console, Teams, Enterprise, Vertex, AWS Bedrock and self-hosted.
Once you've completed the setup as described below, send the path for your S3/GCS bucket to your Customer Success Manager.
This solution uses:
- Claude Code telemetry support
- OpenTelemetry Collector Contrib
- Amazon S3 OR Google Cloud Storage as storage backends
Architecture (AWS Option):
Claude Code
↓ OTLP
OpenTelemetry Collector
↓ awss3exporter
Amazon S3Architecture (GCP Option):
Claude Code
↓ OTLP
OpenTelemetry Collector
↓ googlecloudstorageexporter
Google Cloud StorageOnly a single, centrally managed OTEL Collector is required. Then, by configuring a set of environment variables on each developer machine, Claude Code can be directed to that collector endpoint. All developer machines will send their telemetry data to the same collector. These environment variables can be distributed and managed through your MDM solution
Components
Claude Code Telemetry
Follow Claude Code recommended monitoring and telemetry documentation:
- https://docs.anthropic.com/en/docs/claude-code/monitoring-usage
- Enable metrics collection where applicable (these will be used by TargetBoard).
These are the recommended minimal configuration requirements:
# Events/logs only (no metrics)
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
#optional - enable logs and traces as well
export OTEL_LOGS_EXPORTER=otlp
export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://<your otel collector address>:4317OpenTelemetry Collector
Any OpenTelemetry Collector distribution that can export telemetry data to Amazon S3/Google GCS in formats such as Parquet or CSV is suitable for this architecture.
In this document, the focus is on the OpenTelemetry Collector Contrib distribution together with AWS S3 exporter (awss3exporter) or Google GCS exporter (googlecloudstorageexporter) as these provides a simple and direct integration path.
Documentation Links:
The OpenTelemetry Collector acts as the telemetry gateway which recieves OTLP telemetry, batch processes data and exports telemetry to S3/GCS.
Different IT departments and infrastructure teams may choose different deployment approaches for the OpenTelemetry Collector depending on their internal standards, cloud providers, orchestration platforms, networking requirements, and operational preferences.
It is recommended to review the deployment options documented in the OpenTelemetry Collector Contrib documentation and choose the approach that best fits your organization’s operational model and security requirements.
Storage & Access Configuration
Both Amazon S3 and Google Could Storage store the telemetry data as objects.
Targetboard uses Airbyte to connect to your storage to extract the data to TargetBoard servers.
In order to collect telemetry data from your object storage through Airbyte, appropriate IAM permissions must be configured.
Follow the relevant guidance for either S3 or GCS to connect to Airbyte for data collection.
Sample Installation (Using S3 Storage)
- Login to your AWS account and create an S3 bucket.
- Recommended settings: Block public access, Enable server-side encryption, Enable lifecycle policies.
- Example lifecycle policy: Retain raw telemetry for 90 days; transition older data to Glacier.
Example:
aws s3 mb s3://claude-code-otel-prod- Configure IAM permissions. This is required to upload objects.
Example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:AbortMultipartUpload"
],
"Resource": "arn:aws:s3:::claude-code-otel-prod/*"
}
]
}- Configure IAM permissions for Airbyte to read and extract data from the S3 bucket.
Example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::claude-code-otel-prod",
"arn:aws:s3:::claude-code-otel-prod/*"
]
}
]
}For security best practices, attach this policy to an IAM role specifically for Airbyte/TargetBoard’s access. Refer to the Airbyte S3 connector documentation for full setup instructions.
- Pull the OpenTelemetry Collector Contrib Docker image:
docker pull otel/opentelemetry-collector-contrib:latest- Then create
otel-collector-config.yaml, for example:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
batch: {}
exporters:
awss3:
s3uploader:
region: us-east-1
s3_bucket: claude-code-otel-prod
s3_prefix: claude-code/
marshaler: otlp_json
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [awss3]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [awss3]
logs:
receivers: [otlp]
processors: [batch]
exporters: [awss3]- Run the collector.
Example:
docker run --rm \
-p 4317:4317 \
-p 4318:4318 \
-v $(pwd)/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml \
otel/opentelemetry-collector-contrib:latestThe collector now accepts OTLP telemetry on:
4317(gRPC)4318(HTTP)
- Configure Claude Code to export telemetry to the collector.
Example environment variables:
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_SERVICE_NAME=claude-code
export OTEL_TRACES_EXPORTER=otlp
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://<the address of your otel collector>:4317
How did we do?
BitBucket Integration
Claude Code Integration