Code examples
Copy-pasteable scripts that send OpenTelemetry GenAI spans to Coralogix AI Center using the new semantic conventions. Each example uses the OTEL standard OTLP exporter — no Coralogix-specific SDK required.
Pick your framework or language below — each tile opens a complete, runnable example with install steps, environment variables, the script, and the span attributes you should expect to see.
Use the domain selector at the top of this page to set your Coralogix region. The collector config below updates automatically to use the matching domain.
Prerequisites: deploy an OpenTelemetry Collector
All examples export traces to a local OpenTelemetry Collector over OTLP/gRPC. The collector handles authentication, batching, and retry — keeping credentials out of your application code. Deploy it once, then run any of the examples below against it.
Save the following as otel-collector-config.yaml:
receivers:
otlp:
protocols:
grpc:
endpoint: "0.0.0.0:4317"
exporters:
coralogix:
domain: ""
private_key: "${CORALOGIX_PRIVATE_KEY}"
application_name: "my-genai-app"
subsystem_name: "my-service"
application_name_attributes:
- "cx.application.name"
subsystem_name_attributes:
- "cx.subsystem.name"
timeout: 30s
service:
pipelines:
traces:
receivers: [otlp]
exporters: [coralogix]
Run the collector:
export CORALOGIX_PRIVATE_KEY="<YOUR_CX_API_KEY>"
docker run --rm -p 4317:4317 \
-v $(pwd)/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml \
-e CORALOGIX_PRIVATE_KEY \
otel/opentelemetry-collector-contrib:latest
Tip
See OpenTelemetry integration for AI Center for more collector deployment options.
Auto-instrumented SDKs
Drop-in instrumentation — install an instrumentor (or use an SDK that emits GenAI spans natively) and traces flow with little or no code change.
Manual instrumentation
For languages or providers without an instrumentor — build GenAI spans by hand with the OTel SDK. The span attributes are identical across languages.
Comparison
| Example | Language | Instrumentation | Semconv |
|---|---|---|---|
| OpenAI Agents SDK | Python | OTel contrib (auto) | New (opt-in) |
| Anthropic / Claude | Python | OpenLLMetry (auto) | Legacy (migrating) |
| AWS Bedrock | Python | OTel contrib (auto) | New (opt-in) |
| Google GenAI | Python | OTel contrib (auto) | New (opt-in) |
| OpenLLMetry + OpenAI | Python | Traceloop SDK (auto) | Legacy |
| .NET — Microsoft.Extensions.AI | C# | Microsoft.Extensions.AI (auto) | New (native) |
| Python manual | Python | Manual spans + raw HTTP | New |
| Java manual | Java | Manual spans | New |
| Go manual | Go | Manual spans + net/http | New |
Next steps
Look up which open-source library to use for your provider in Compatibility matrix.