{"slug": "cline-monitoring-with-opentelemetry-tokens-and-cost", "title": "Cline Monitoring with OpenTelemetry: Tokens and Cost", "summary": "SigNoz announced support for monitoring Cline, an open-source AI coding agent for VS Code, using OpenTelemetry to track token spend and cost by model and developer. The integration, requiring Cline v4.1.16 or later and environment variable configuration, emits metrics such as cline.tokens.input.total and cline.cache.read.tokens.total under the service name 'cline' for visualization in SigNoz's Logs and Metrics Explorers.", "body_md": "## What is Cline Monitoring?\n\n[Cline](https://cline.bot) is an open-source AI coding agent for VS Code that plans and executes multi-step work: it reads files, edits code, runs shell commands, and calls MCP servers on your behalf. Cline's own account page shows what you spent in total. What it does not show is where the spend went: which model, which repository, which developer, and how much of every request was context resent rather than new work.\n\nCline ships an [OpenTelemetry](https://opentelemetry.io/) exporter inside the VS Code extension, so this needs no plugin or wrapper. It emits events and metrics under the service name `cline`\n\n. With Cline monitoring in SigNoz you can see token spend and cost broken down by model and by developer, how effective the prompt cache is, which tools the agent reaches for and which fail, request latency and time to first token, and every provider API error with its message.\n\n## Prerequisites\n\n- SigNoz setup (choose one):\n[SigNoz Cloud account](https://signoz.io/teams/)with an active ingestion key- Self-hosted SigNoz instance\n\n- VS Code with the\n[Cline extension](https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev)installed (v4.1.16 or later) - A model provider configured in Cline\n\n## Monitor Cline with OpenTelemetry\n\nCline reads its exporter configuration from `CLINE_OTEL_*`\n\nenvironment variables at extension activation, so the whole setup is environment variables plus a restart. No Cline account tier is required.\n\n**Step 1:** Export the configuration in a shell.\n\n```\n# Required. The default bundle emits no task events or metrics at all.\nexport CLINE_BUNDLE_OVERRIDE=legacy\n \nexport CLINE_OTEL_TELEMETRY_ENABLED=true\nexport CLINE_OTEL_METRICS_EXPORTER=otlp\nexport CLINE_OTEL_LOGS_EXPORTER=otlp\nexport CLINE_OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf\nexport CLINE_OTEL_EXPORTER_OTLP_ENDPOINT=\"https://ingest.<region>.signoz.cloud:443\"\nexport CLINE_OTEL_EXPORTER_OTLP_HEADERS=\"signoz-ingestion-key=<your-ingestion-key>\"\n```\n\n**Verify these values:**\n\n`<region>`\n\n: Your[SigNoz Cloud region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint).`<your-ingestion-key>`\n\n: Your SigNoz[ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/).\n\n**Step 2:** Launch VS Code from that same shell.\n\n```\ncode\n```\n\nThe extension host inherits the environment of the VS Code process, so launching from Finder, the Dock, or a Start menu shortcut picks up nothing. To make the configuration permanent, put the exports in your shell profile and always start VS Code from a terminal, or set them through your MDM or workspace tooling.\n\n**Step 3:** Send a prompt in Cline that uses a tool, such as asking it to read a file and edit it.\n\nCline reads the configuration once at activation, so any change to these variables needs a full restart of VS Code rather than a window reload.\n\n## View Cline Logs in SigNoz\n\nCline exports events over the OpenTelemetry logs protocol rather than as traces. Allow a few seconds after your first prompt, then open the [Logs Explorer](https://signoz.io/docs/userguide/logs_query_builder/) and filter on `service.name = 'cline'`\n\n.\n\nOpening a record shows its attributes. A `task.tokens`\n\nevent carries the token counts and the computed cost for one model request.\n\n## View Cline Metrics in SigNoz\n\nAlongside the events, Cline publishes a `cline.*`\n\nmetric family under the same service name. Open the [Metrics Explorer](https://signoz.io/docs/metrics-management/metrics-explorer/), search for `cline`\n\n, and group by `model`\n\nto split any of them per model.\n\n| Metric | Type | What it measures |\n|---|---|---|\n`cline.tokens.input.total` , `cline.tokens.output.total` | Counter | Cumulative prompt and completion tokens |\n`cline.tokens.input.per_response` , `cline.tokens.output.per_response` | Histogram | Token distribution per model response |\n`cline.cache.read.tokens.total` , `cline.cache.write.tokens.total` | Counter | Prompt-cache reads and writes |\n`cline.cache.read.tokens.per_event` , `cline.cache.write.tokens.per_event` | Histogram | Cache volume per request |\n`cline.cost.total` | Counter | Cumulative cost in USD |\n`cline.cost.per_event` | Histogram | Cost distribution per request |\n`cline.api.duration.seconds` | Histogram | Full model request duration |\n`cline.api.ttft.seconds` | Histogram | Time to first token |\n`cline.tool.calls.total` , `cline.tool.calls.per_task` | Counter, Histogram | Tool invocations, and how many a task takes |\n`cline.turns.total` , `cline.turns.per_task` | Counter, Histogram | Model round trips, and how many a task takes |\n`cline.ai_output.accepted.lines_added.total` , `lines_changed.total` , `lines_deleted.total` | Counter | Lines of accepted agent output |\n\nEvery metric carries `model`\n\n, `provider`\n\n, `extension_variant`\n\n, and `ulid`\n\n, so the same per-model and per-task breakdowns available on the events work here too. Each histogram arrives in SigNoz as five series (`.bucket`\n\n, `.count`\n\n, `.sum`\n\n, `.min`\n\n, `.max`\n\n), so search for `cline.api.ttft.seconds.bucket`\n\nrather than the base name when building a percentile panel.\n\n## Attributes Worth Knowing\n\nThe event name arrives as the **log body**, not as an attribute, so queries filter with `body = 'task.tokens'`\n\nrather than on a name field. Four more details decide whether your queries are correct.\n\nEvery event produced by one task shares it. Cline emits no traces, so there is no trace or span ID to group on and`ulid`\n\nis the task correlation key.`ulid`\n\nis the only way to reconstruct a task.**Cache reads are counted separately from input.**`cacheReadTokens`\n\nis not included in`tokensIn`\n\n. Adding the two together double counts the context.**The model key is not consistent.**`task.tokens`\n\nand`task.conversation_turn`\n\nuse`model`\n\n, while`task.tool_used`\n\nuses`modelId`\n\n. A filter written for the token events silently drops every tool event.**Absent values arrive as the string**`\"undefined\"`\n\n.`requestId`\n\n,`errorStatus`\n\n, and`isNativeToolCall`\n\nuse the literal text rather than being omitted, so exclude that string explicitly when filtering.\n\nThe events worth building on are `task.tokens`\n\n(`tokensIn`\n\n, `tokensOut`\n\n, `cacheReadTokens`\n\n, `cacheWriteTokens`\n\n, `totalCost`\n\n, `model`\n\n, `provider`\n\n), `task.tool_used`\n\n(`tool`\n\n, `success`\n\n, `autoApproved`\n\n), `task.conversation_turn`\n\n(`mode`\n\n, `source`\n\n), and `task.provider_api_error`\n\n(`errorType`\n\n, `errorClass`\n\n, `errorMessage`\n\n, `failurePhase`\n\n).\n\n## Track Token Usage and Cost\n\nCost is the reason most teams instrument a coding agent, and Cline reports it per model request on the `task.tokens`\n\nevent. Two things about that number are worth knowing before you build on it.\n\n**Cost is computed on the client.** Cline multiplies token counts by its own per-model price table rather than reading a figure back from the provider. That means `totalCost`\n\nreads `0`\n\nfor a model that is free to you, including Cline's own bundled provider, and the zero is arithmetically correct rather than a broken export. Configure a directly priced provider under **Settings > API Provider** to get meaningful cost.\n\n**Most of your input tokens are resent context.** Cline replays the system prompt and workspace context on every turn, so a one-word prompt can carry eight thousand input tokens. Read `cacheReadTokens`\n\nnext to `tokensIn`\n\n: a cache-read figure close to the input total means the provider cache is absorbing that repetition, and a low one means you are paying full price for it every turn.\n\nBoth aggregate cleanly straight from the events, so a token or cost panel is accurate from the very first task:\n\n```\nservice.name = 'cline' AND body = 'task.tokens'\n```\n\n## Cline Monitoring Dashboard\n\nThe [Cline dashboard](https://signoz.io/docs/dashboards/dashboard-templates/cline-dashboard/) turns these events and metrics into token spend by model, cost over time, prompt-cache effectiveness, tool mix and failures, latency, and provider API errors.\n\n## Troubleshooting Cline Monitoring\n\n### Every export fails with UNAUTHENTICATED\n\nThe protocol is set to `grpc`\n\n. Cline passes your headers to the gRPC exporter in a field the OpenTelemetry SDK does not read for gRPC, so the ingestion key never leaves the machine. Set `CLINE_OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf`\n\nand restart VS Code.\n\n### Telemetry is enabled but nothing arrives\n\nConfirm the value is exactly `true`\n\n. `CLINE_OTEL_TELEMETRY_ENABLED=1`\n\ndoes not work on this path, even though `1`\n\nis accepted elsewhere in the extension, because the runtime configuration compares against the string `true`\n\n.\n\nThen confirm VS Code inherited the environment. Launching from the Dock or Finder gives the extension host an environment without your exports. Start VS Code with `code`\n\nfrom the shell where you set them.\n\n### Lifecycle events arrive but no task, token, or tool events\n\n`CLINE_BUNDLE_OVERRIDE=legacy`\n\nis missing. Lifecycle events such as `user.extension_activated`\n\nare emitted on a path that both bundles share, so a partially working export is the expected symptom. Set the variable and restart VS Code.\n\n### The diagnostic log always says count=0\n\nIgnore it. With `TEL_DEBUG_DIAGNOSTICS=true`\n\n, every successful export prints `count=0`\n\nregardless of how many records it carried. Verify in SigNoz instead of trusting that number.\n\n### Exports intermittently return Unauthorized\n\nA share of batches can be rejected under sustained load with a key that succeeds on the requests either side of them. Records in a rejected batch are lost, so treat a missing event as possibly dropped rather than never emitted.\n\n### Nothing is emitted from the Cline CLI\n\nThis cannot be fixed by configuration. The OpenTelemetry exporter exists only in the VS Code extension, and the Cline CLI contains no OTLP support at all. Use the extension to collect telemetry.\n\n## Setup OpenTelemetry Collector (Optional)\n\n### What is the OpenTelemetry Collector?\n\nThink of the OTel Collector as a middleman between your app and SigNoz. Instead of your application sending data directly to SigNoz, it sends everything to the Collector first, which then forwards it along.\n\n### Why use it?\n\n**Cleaning up data**- Filter out noisy events you don't care about, or remove sensitive info before it leaves your machines.** Keeping your app lightweight**- Let the Collector handle batching, retries, and compression instead of your application code.** Adding context automatically**- The Collector can tag your data with useful info like which team or environment it came from.** Future flexibility**- Want to send data to multiple backends later? The Collector makes that easy without changing your setup.\n\nSee [Switch from direct export to Collector](https://signoz.io/docs/opentelemetry-collection-agents/opentelemetry-collector/switch-to-collector/) for step-by-step instructions to convert your setup.\n\nFor more details, see [Why use the OpenTelemetry Collector?](https://signoz.io/docs/opentelemetry-collection-agents/opentelemetry-collector/why-to-use-collector/) and the [Collector configuration guide](https://signoz.io/docs/opentelemetry-collection-agents/opentelemetry-collector/configuration/).\n\n## Related integrations\n\nInstrument the other AI coding agents your team runs, using the same OpenTelemetry pipeline:\n\n[Monitor Claude Code with OpenTelemetry](https://signoz.io/docs/claude-code-monitoring/)[Monitor OpenAI Codex with OpenTelemetry](https://signoz.io/docs/codex-monitoring/)[Cursor IDE observability with OpenTelemetry](https://signoz.io/docs/cursor-observability/)[OpenCode observability with OpenTelemetry](https://signoz.io/docs/opencode-observability/)\n\nBrowse [all LLM observability integrations](https://signoz.io/docs/llm-observability/) to instrument the rest of your stack.", "url": "https://wpnews.pro/news/cline-monitoring-with-opentelemetry-tokens-and-cost", "canonical_source": "https://signoz.io/docs/cline-monitoring", "published_at": "2026-08-31 00:00:00+00:00", "updated_at": "2026-09-01 05:22:48.071813+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "ai-agents", "mlops"], "entities": ["Cline", "SigNoz", "VS Code", "OpenTelemetry"], "alternates": {"html": "https://wpnews.pro/news/cline-monitoring-with-opentelemetry-tokens-and-cost", "markdown": "https://wpnews.pro/news/cline-monitoring-with-opentelemetry-tokens-and-cost.md", "text": "https://wpnews.pro/news/cline-monitoring-with-opentelemetry-tokens-and-cost.txt", "jsonld": "https://wpnews.pro/news/cline-monitoring-with-opentelemetry-tokens-and-cost.jsonld"}}