register()¶
Configure the Coalex OTLP exporter. Call once at application startup before any other Coalex SDK calls.
Signature¶
interface RegisterOptions {
endpoint?: string; // default: "https://traces.azure.coalex.ai"
apiKey?: string; // default: "dev"
serviceName?: string; // default: "coalex-sdk-typescript"
filterNonAiSpans?: boolean; // default: false
suppressExportErrors?: boolean; // default: true
}
function register(options?: RegisterOptions): void
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
endpoint |
str |
"https://traces.azure.coalex.ai" |
Coalex proxy HTTP endpoint. Optional — the default points to the Azure-hosted cloud. Only override for on-prem, GCP deployments, or local development. |
api_key |
str |
"dev" |
API key for proxy authentication. Use "dev" for local development with docker compose. |
service_name |
str |
"coalex-sdk-python" |
OpenTelemetry service name. Appears in the Coalex dashboard as the service identifier. |
filter_non_ai_spans |
bool |
False |
When True, only AI/LLM spans are exported. HTTP, DB, and other non-AI spans are dropped before export. |
suppress_export_errors |
bool |
True |
When True, export errors are logged but do not raise exceptions. Set to False for debugging connectivity issues. |
All parameters are keyword-only (enforced by *).
Returns¶
None. The function configures global state as a side effect.
What it does¶
Calling register() performs the following setup:
- Creates an OpenTelemetry
Resourcewithservice.nameset toservice_name. - Creates an
OTLPSpanExporterpointing at{endpoint}/v1/traceswith anAuthorization: Bearer {api_key}header. - Wraps the exporter in a
SafeOTLPSpanExporter(suppresses transient network errors whensuppress_export_errors=True). - Optionally wraps in a
FilteringSpanExporter(whenfilter_non_ai_spans=True). - Creates a
TracerProviderwith aCoalexAttributePropagator(copiescoalex.*attributes from parent to child spans) and aBatchSpanProcessor. - Sets the
TracerProvideras the global OpenTelemetry tracer provider viatrace.set_tracer_provider().
Call once only
register() sets the global TracerProvider. Calling it multiple times replaces the provider, which can cause spans to be dropped. Always call it once at the top of your application entrypoint.
Examples¶
Production (Azure — default)¶
No endpoint needed. The SDK connects to traces.azure.coalex.ai by default.
On-prem or GCP deployment¶
Only set endpoint when using a self-hosted proxy or a non-default cloud region.
Local development¶
Debugging export issues¶
Filtering non-AI spans¶
Notes¶
- The SDK always sends traces through the proxy (via load balancer) so that authentication is validated in the request path. Never point
endpointdirectly at the collector. - The
api_keyis sent as aBearertoken in theAuthorizationheader on every OTLP export request. - The
BatchSpanProcessorbuffers spans and exports them in batches asynchronously, soregister()returns immediately. - If you need to use a custom
TracerProvider(e.g., with additional processors or exporters), configure it yourself and pass it toauto_instrument(tracer_provider=...)instead of callingregister().
API Reference¶
coalex.register ¶
register(
*,
endpoint: str = "https://traces.azure.coalex.ai",
api_key: str = "dev",
service_name: str = "coalex-sdk-python",
filter_non_ai_spans: bool = False,
suppress_export_errors: bool = True,
) -> None
Configure the Coalex OTLP exporter.
Call once at application startup. Sets the global TracerProvider with a BatchSpanProcessor exporting OTLP/HTTP to the Coalex proxy.
The SDK always sends through the proxy (via LB) so that auth validation is in the path. Never send directly to the collector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint
|
str
|
Coalex proxy HTTP endpoint (default: cloud). |
'https://traces.azure.coalex.ai'
|
api_key
|
str
|
API key for proxy authentication (default: "dev" for local). |
'dev'
|
service_name
|
str
|
Service name for OTLP resource (default: "coalex-sdk-python"). |
'coalex-sdk-python'
|
filter_non_ai_spans
|
bool
|
If True, only export AI/LLM spans (default: False). |
False
|
suppress_export_errors
|
bool
|
If True, suppress export errors gracefully (default: True). |
True
|