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. Use the cloud default or your self-hosted proxy URL. |
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. |
genai_semconv |
bool \| None |
None |
When True, additively emit OTel GenAI attributes (gen_ai.input.messages / gen_ai.output.messages / gen_ai.system_instructions) derived from OpenInference messages. Defaults to the COALEX_GENAI_SEMCONV env var, or False when unset. See Semantic conventions. (Python SDK) |
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). - Optionally wraps in a
GenAISemconvExporter(whengenai_semconv=True) that addsgen_ai.*message attributes at export time. - 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¶
Cloud deployment¶
Local development¶
Debugging export issues¶
Filtering non-AI spans¶
Declaring your agent¶
By default the platform learns about your agent from its traces — it appears in the dashboard once it sends telemetry. That is enough to observe it, but not enough to talk to it: the Console needs to know where the agent lives before an operator can start a session with it.
Pass declare and the agent registers itself at startup:
import coalex
from coalex import AgentInventory
coalex.register(
endpoint="https://your-org.coalex.ai",
api_key="your-api-key",
service_name="my-agent",
declare=AgentInventory(
endpoint="https://my-agent.internal/chat",
tools=["lookup_portfolio", "wire_funds"],
resume_url="https://my-agent.internal/chat/resume",
),
)
The agent name defaults to service_name, so the agent you declare and the agent your traces are
attributed to are the same one.
What you can declare, and what you cannot¶
An agent declares where it lives and what tools it has. It cannot declare whether those tools are governed, or who may approve them:
| Who decides | What |
|---|---|
| Your agent, here | endpoint, resume URL, tool names |
| Your organisation, in the dashboard | which tools require approval, and which role may approve |
That separation is deliberate. If an agent could declare governed: false about its own tools, the
thing being governed would be the author of its own governance — which is not governance at all,
and not something you could defend to an auditor. Sending a policy field is rejected with a 422
rather than silently ignored.
Declared tools start ungoverned and the agent starts hidden from the Console until somebody in your organisation makes those calls. Declaring yourself is not the same as being chosen.
Notes¶
- Declaring is best-effort. If the platform is unreachable at startup, the SDK logs a warning and carries on — your agent still starts and still traces, and the declaration is retried the next time it boots. A governance registration failing is never a reason for your agent to be down.
- 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,
genai_semconv: bool | None = None,
declare: AgentInventory | None = None,
) -> 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
|
genai_semconv
|
bool | None
|
If True, additively emit OTel GenAI attributes
( |
None
|
declare
|
AgentInventory | None
|
Optionally tell the platform where this agent lives and what tools it has
(COA-1969), so it appears in the Console without anyone registering it by hand.
Best-effort: a failure is logged and startup continues. Omit it and |
None
|
Source code in coalex/__init__.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |