SDK Initialization Options
Documentation of the initialization options for the SDKs.
Most configuration options can be set via environment variables or via the SDK’s initialization options.
The SDK initialization options always take precedence over the environment variables.
See below for the list of options.
Application Name
You can customize the application name that will be logged with the traces. This is useful to identify if you have multiple services with OpenLLMetry installed.
Resource Attributes
You can further add any custom attributes to the OpenTelemetry resource. This is useful to add information about the environment where the application is running, such as the environment name, the application version, etc.
Base URL
This defines the OpenTelemetry endpoint to connect to. It defaults to https://api.traceloop.com
If you prefix it with http
or https
, it will use the OTLP/HTTP protocol.
Otherwise, it will use the OTLP/GRPC protocol.
For configuring this to different observability platform, check out our integrations section.
The OpenTelemetry standard defines that the actual endpoint should always end
with /v1/traces
. Thus, if you specify a base URL, we always append
/v1/traces
to it. This is similar to how OTLP_EXPORTER_OTLP_ENDPOINT
works
in all OpenTelemetry SDKs.
API Key
If set, this is sent as a bearer token on the Authorization header.
Traceloop, for example, use this to authenticate incoming traces and requests.
If this is not set, and the base URL is set to https://api.traceloop.com
,
the SDK will generate a new API key automatically with the Traceloop
dashboard.
Headers
If set, this is sent as-is as HTTP headers. This is useful for custom authentication protocols that some observability platforms require.
The format follows the W3C Correlation-Context format, i.e.
key1=value1,key2=value2
. If you need spaces, use %20
.
This is similar to how OTEL_EXPORTER_OTLP_HEADERS
works in all OpenTelemetry SDKs.
Custom Traces Exporter
If, for some reason, you cannot use the OTLP/HTTP or OTLP/GRPC exporter that is provided with the SDK, you can set a custom exporter (for example, to Jaeger, Zipkin, or others)
If this is set, Base URL, API key and headers configurations are ignored.
Disable Batch
By default, the SDK batches spans using the OpenTelemetry batch span processor. When working locally, sometime you may wish to disable this behavior. You can do that with this flag.
Disable Tracing of Prompt Content
By default, OpenLLMetry logs prompts, completions, and embeddings to span attributes.
However, you may want to disable this logging for privacy reasons, as they may contain highly sensitive data from your users. You may also simply want to reduce the size of your traces.
Control Logging
You can control the logging level of the SDK. By default, the SDK logs at the WARN level.
Enrich Collected Metrics and Traces
By default, the SDK enriches collected metrics and traces with additional information such as the OpenAI token usage for streaming requests. This may affect latency on the first request, as it needs to fetch the embeddings.
Traceloop Sync
By default, if you’re sending traces to Traceloop, then the Traceloop SDK’s sync functionality is also active. To disable it or change any defaults, see the example below. The values listed are the default values, so you don’t need to set them unless you want to change the defaults.
Instrumentations
By default, the SDK automatically detects which models and frameworks you are using and instruments them for you. You can override this and specify specific frameworks and models you want to instrument. This, for example, allow you to specify that you want to log calls to OpenAI, but not Anthropic, or vice-versa.
Was this page helpful?