Configuration

On this page

There is no config file, environment-variable schema, or settings object in this module — "configuration" means the constructor arguments to the tracer's exporters, plus the two Tracer methods that turn tracing on and off. This page collects every configurable option found in the source, in one place.

Enabling tracing

OptionTypeDefaultEffect
(implicit) register any exporter——Tracer.enabled becomes True as soon as at least one exporter is registered and the tracer hasn't been explicitly disable()d.
get_tracer().enable()——Sets the internal enabled flag; still requires ≥1 exporter for Tracer.enabled to read True.
get_tracer().disable() / disable_tracing()——Turns tracing into a no-op; keeps exporters registered for later.

ConsoleExporter options

OptionTypeDefaultEffect
streamTextIOsys.stdoutWhere lines are written.
verboseboolFalseAlso print input / output / metadata per span, unlimited length.

See ConsoleExporter for the exact output format.

JSONExporter options

OptionTypeDefaultEffect
pathOptional[str | Path]NoneIf set, spans append as JSONL to this file. If unset, spans accumulate in memory (read via .spans / .to_json()).

See JSONExporter for truncation behavior (spans go through Span.to_dict(), which truncates input/output beyond 2000 characters).

LangSmithExporter options

OptionTypeDefaultEffect
api_keyOptional[str]NoneFalls back to LANGCHAIN_API_KEY / LANGSMITH_API_KEY env vars (via the langsmith client itself) if omitted.
project_namestr"default"LangSmith project runs are logged into.
**client_kwargs——Forwarded verbatim to langsmith.Client(...); see the langsmith package's own docs for what it accepts — that's outside this module's source.

See LangSmithExporter for the full Span → LangSmith Run field mapping.

Per-span options

Passed to Tracer.span(...) or trace(...):

OptionTypeDefaultEffect
namestr—Span label (required).
typestr"generic"A SpanType value or custom string.
inputAnyNoneSet once at span creation.
metadataOptional[Dict[str, Any]]NoneInitial metadata dict.
model, providerOptional[str]NoneFor LLM spans.

What is not configurable

Reading the source, these are fixed and cannot currently be changed via any parameter:

  • The _safe_repr truncation limit used by Span.to_dict() is hard-coded to 2000 characters.
  • The worker-thread join timeout in Tracer.shutdown() is hard-coded to 5 seconds.
  • Tracer.flush(timeout=...) accepts a timeout argument but does not actually enforce it (see the warning on that page) — there is currently no way to bound how long flush() blocks.

Next: Cookbook for end-to-end configuration recipes.

Related pages