Introducing the Better Auth Chargebee plugin: Use it to handle subscriptions, billing, and auth seamlessly.
Chargebeechargebee API

OpenTelemetry integration

All Chargebee client librariesNode.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:

  1. Span start — Before each API call, the SDK calls onRequestStart with a request context (span name, resource, operation, and start attributes). Your adapter typically creates an OTel client span and injects W3C traceparent / tracestate headers on the outgoing request.
  2. Span end — After the response (or error), the SDK calls onRequestEnd with a result object (HTTP status, duration, error details, and end attributes). Your adapter records final attributes, sets span status, and ends the span.
  3. One span per SDK call — Retries reuse the same span; they do not create a new root trace.
  4. 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:

AttributeDescription
url.fullRequest URL (without sensitive query params)
http.request.methodHTTP method
server.addressChargebee API hostname
chargebee.siteYour Chargebee site name
chargebee.api_versionv1 or v2
chargebee.resourceAPI resource (e.g. subscription)
chargebee.operationAPI operation (e.g. create)
chargebee.sdk.nameSDK identifier (e.g. chargebee-java, chargebee-node)
chargebee.sdk.versionInstalled SDK version
http.request.header.chargebee-*Outgoing chargebee-* request headers (except chargebee-request-origin-*, which carries PII and is excluded)

Recorded at span end:

AttributeDescription
http.response.status_codeHTTP status code
error.typeChargebee error type on 4xx/5xx (when available)
chargebee.error.codeChargebee error code
chargebee.error.typeChargebee error classification
chargebee.error.paramAPI 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.