OpenTelemetry integration
All Chargebee client libraries — Node.js, Java, Python, PHP, Ruby, .NET, and Go — can emit standardized request spans into your observability stack via OpenTelemetry.
Telemetry is optional. OpenTelemetry is not bundled with Chargebee SDKs. Install and configure OTel in your application, implement a small telemetry adapter, and pass it when configuring the client.
How it works
When a telemetry adapter is configured:
- Span start — Before each API call, the SDK calls
onRequestStartwith a request context (span name, resource, operation, and start attributes). Your adapter typically creates an OTel client span and injects W3Ctraceparent/tracestateheaders on the outgoing request. - Span end — After the response (or error), the SDK calls
onRequestEndwith a result object (HTTP status, duration, error details, and end attributes). Your adapter records final attributes, sets span status, and ends the span. - One span per SDK call — Retries reuse the same span; they do not create a new root trace.
- Fail-safe — Telemetry errors never break the API call.
Spans are named chargebee.{resource}.{operation} — for example chargebee.subscription.create. The span name, attribute keys, and error mapping are identical across all SDK languages.
Span attributes
The SDK builds attributes following stable OpenTelemetry HTTP semantic conventions plus Chargebee-specific chargebee.* keys. Forward them as-is to your exporter.
Recorded at span start:
| Attribute | Description |
|---|---|
url.full | Request URL (without sensitive query params) |
http.request.method | HTTP method |
server.address | Chargebee API hostname |
chargebee.site | Your Chargebee site name |
chargebee.api_version | v1 or v2 |
chargebee.resource | API resource (e.g. subscription) |
chargebee.operation | API operation (e.g. create) |
chargebee.sdk.name | SDK identifier (e.g. chargebee-java, chargebee-node) |
chargebee.sdk.version | Installed SDK version |
http.request.header.chargebee-* | Outgoing chargebee-* request headers (except chargebee-request-origin-*, which carries PII and is excluded) |
Recorded at span end:
| Attribute | Description |
|---|---|
http.response.status_code | HTTP status code |
error.type | Chargebee error type on 4xx/5xx (when available) |
chargebee.error.code | Chargebee error code |
chargebee.error.type | Chargebee error classification |
chargebee.error.param | API parameter associated with the error |
Examples
Configure OpenTelemetry in your application (OTLP exporter, service name, and so on), then pass a telemetry adapter when initializing the Chargebee client. Use the Library dropdown at the top of the page to switch between language-specific examples below.
Next steps
- Browse Client Libraries for installation and quick-start guides per language.
- Configure an OTLP exporter in your OpenTelemetry SDK.
- Spans are exported by your OpenTelemetry setup — refer to the OpenTelemetry documentation for exporter configuration.