Collecting Claude Code usage logs across an organization with OpenTelemetry and Cloudflare
At Gemcook, Claude Code is rolled out company-wide, and the team wants to know how much it is actually used. The author built a system that collects Claude Code usage logs through its OpenTelemetry[1] support and stores them in Cloudflare R2. The author chose this over ccusage, a tool that reads logs only on each person's own device, because after setup members need to do nothing.
Each api_request event contains the time, the user's email when logged in with OAuth, the session ID, the model, token counts, cache tokens, the estimated cost in USD, and the request duration. The cost is an API-rate estimate, so it does not match the actual bill for a subscription plan. Data is sent in the http/json form of OTLP[2], so a Cloudflare Workers[3] handler receives it directly without an OTel Collector. The Worker saves the raw JSON to R2 before any formatting, and access is protected by a token in the Authorization header and a WAF[4].
Settings are distributed through server-managed settings from the admin console, so members only need to approve a dialog that appears. The author advises telling members in advance what is collected and who can see it, and warns that rejecting the dialog closes Claude Code. Aggregation and visualization of the data are planned for a separate article.
Sources
-
JPZenn JA
OpenTelemetry×Cloudflareで組織のClaude Code利用ログを収集する


