Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python tracing libraries record spans that show how a request moves through an application and the services it calls. An SDK creates each span with timing and context before an exporter sends it to a backend such as an OpenTelemetry collector. These libraries let developers find slow calls and failures in web services and AI agent runs.
Popularity
opentelemetry-sdk has the most monthly downloads in this comparison, at 342.4M.
def _initialize_tracer_provider(disabled=False):
"""
Instantiate a tracer provider and set it as the global tracer provider.
Note that this function ALWAYS updates the global tracer provider, regardless of the current
state. It is the caller's responsibility to ensure that the tracer provider is initialized
only once, and update the _INITIALIZED flag accordingly.
"""
processors = _get_span_processors(disabled=disabled)
if not processors:
provider.set(trace.NoOpTracerProvider())
return
# Demote the "Failed to detach context" log raised by the OpenTelemetry logger to DEBUG # level so that it does not show up in the user's console. This warning may indicate # some incorrect context handling, but in many cases just false positive that does not # cause any issue in the generated trace. # Note that we need to apply it permanently rather than just the scope of prediction call, # because the exception can happen for streaming case, where the error log might be # generated when the iterator is consumed and we don't know when it will happen. suppress_warning("opentelemetry.context", "Failed to detach context")
# These Otel warnings are occasionally raised in a valid case, e.g. we timeout a trace # but some spans are still active. We suppress them because they are not actionable. suppress_warning("opentelemetry.sdk.trace", "Setting attribute on ended span")
suppress_warning("opentelemetry.sdk.trace", "Calling end() on an ended span")
# When using the global tracer provider mode (MLFLOW_USE_DEFAULT_TRACER_PROVIDER=false), # check if a TracerProvider is already set (e.g., set with `set_tracer_provider` API for # Uvicorn, FastAPI, etc.). If so, add MLflow's span processors to the existing provider # instead of replacing it. This enables unified tracing where both external and MLflow spans # are captured in the same trace. if not MLFLOW_USE_DEFAULT_TRACER_PROVIDER.get():
existing_provider = trace.get_tracer_provider()
if isinstance(existing_provider, TracerProvider):
_logger.debug(
"An existing TracerProvider is detected. Adding MLflow's span processors "
"to the existing provider for unified tracing."
)
try:
existing_processors = set(existing_provider._active_span_processor._span_processors)
for processor in processors:
if not any(isinstance(p, type(processor)) for p in existing_processors):
existing_provider.add_span_processor(processor)
return
except Exception as e:
_logger.debug(
f"An error occurred while adding span processors to the existing provider: {e}."
" Overriding the existing provider with MLflow trace provider.",
exc_info=True,
)
# NB: If otel resource env vars are set explicitly, don't create an empty resource # so that they are propagated to otel spans. otel_service_name = os.environ.get("OTEL_SERVICE_NAME")
otel_resource_attributes = os.environ.get("OTEL_RESOURCE_ATTRIBUTES")
resource = None
sdk_attributes = {
"telemetry.sdk.language": "python",
"telemetry.sdk.name": "mlflow",
"telemetry.sdk.version": mlflow.__version__,
}
if not otel_service_name and not otel_resource_attributes:
# Setting an empty resource to avoid triggering resource aggregation, which causes # an issue in LiteLLM tracing: https://github.com/mlflow/mlflow/issues/16296 # Add telemetry resource: https://opentelemetry.io/docs/specs/semconv/resource/#telemetry-sdk resource = Resource(sdk_attributes)
else:
# Update the env var to let otel initialize the resource with MLflow's SDK attributes attributes = {**_parse_otel_resource_attributes(otel_resource_attributes), **sdk_attributes}
os.environ["OTEL_RESOURCE_ATTRIBUTES"] = ",".join([
f"{k}={v}" for k, v in attributes.items()
])
if MLFLOW_TRACE_USE_ISOLATED_RANDOM_ID_GENERATOR.get():
tracer_provider = TracerProvider(
resource=resource,
sampler=_get_trace_sampler(),
id_generator=_IsolatedRandomIdGenerator(),
)
else:
tracer_provider = TracerProvider(
resource=resource,
sampler=_get_trace_sampler(),
)
for processor in processors:
tracer_provider.add_span_processor(processor)
provider.set(tracer_provider)
Sentry SDK
Captures application errors and tracing spans with Python framework integrations.
Downloads / mo
157.0M
Stars
2.2K
Last release
2.75.0
License
MIT
Strengths
Instruments supported frameworks automatically.Supported HTTP and database operations become spans through enabled integrations.
Adds custom nested spans.Wrap application operations in spans inside an active transaction.
Limitations
Custom spans need a transaction.Create a transaction when the framework integration does not create one.
Tracing needs sampling configuration.Set traces_sample_rate for the share of traces sent to Sentry.
def _persist_run_single(self, run: Run) -> None:
"""Persist a run."""
if run.extra.get("__disabled"):
return
try:
run.extra["runtime"] = get_runtime_environment()
run.tags = self._get_tags(run)
_patch_missing_metadata(self, run)
if run.ls_client is not self.client:
run.ls_client = self.client
run.post()
except Exception as e:
# Errors are swallowed by the thread executor so we need to log them here log_error_once("post", e)
raise
ddtrace
Adds manual and automatic tracing to Python applications for Datadog.
Downloads / mo
48.7M
Stars
655
Last release
4.17.0
License
BSD-3-Clause
Strengths
Wraps selected code blocks.Use the tracer context manager around an operation that needs a span.
Propagates context across async tasks.New tasks inherit the active trace context by default.
Limitations
Spans belong to their execution.Pass and activate the context when continuing a trace across execution boundaries.
Automatic tracing must start early.Import ddtrace.auto before application imports when using that initialization route.
async def main():
async with AsyncClient() as client:
logfire.instrument_httpx(client, capture_all=True)
deps = Deps(client=client)
result = await weather_agent.run(
'What is the weather like in London and in Wiltshire?', deps=deps
)
print('Response:', result.output)
MLflow Tracing
Instruments code for MLflow tracing with a minimal set of dependencies.
@functools.wraps(lambda_handler)
def decorate(event, context, **kwargs):
with self.provider.in_subsegment(name=f"## {lambda_handler_name}") as subsegment:
try:
logger.debug("Calling lambda handler")
response = lambda_handler(event, context, **kwargs)
logger.debug("Received lambda handler response successfully")
self._add_response_as_metadata(
method_name=lambda_handler_name,
data=response,
subsegment=subsegment,
capture_response=capture_response,
)
except Exception as err:
logger.exception(f"Exception received from {lambda_handler_name}")
self._add_full_exception_as_metadata(
method_name=lambda_handler_name,
error=err,
subsegment=subsegment,
capture_error=capture_error,
)
raise
finally:
cold_start = _is_cold_start()
logger.debug("Annotating cold start")
subsegment.put_annotation(key="ColdStart", value=cold_start)
if self.service:
subsegment.put_annotation(key="Service", value=self.service)
return response
FAQ
opentelemetry-sdk suits tracing exported through standard OTLP to compatible backends. Sentry SDK suits applications that track errors and spans together. Langfuse and LangSmith suit tracing LLM applications and agents.
Langfuse is a Python SDK for LLM observability and tracing, with datasets, experiments, evaluation, and prompt management.
LangSmith is a client library that connects to the LangSmith observability and evaluation platform.
Logfire creates structured logs and spans using OpenTelemetry. It sends data to its cloud by default. Its configuration can point to another OTLP backend instead.
opentelemetry-sdk creates spans and exports them through OTLP to compatible collectors and backends. Sentry SDK captures errors and spans for Sentry, with automatic instrumentation for supported frameworks.
ddtrace adds manual and automatic tracing to Python applications for Datadog. Automatic tracing must start early in the process.
For coding agents
Found your tracing library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.