Skip to content

SideSeat Class

The SideSeat class is the main entry point for the Python SDK. It manages OpenTelemetry setup, framework instrumentation, and exporters.

class SideSeat:
def __init__(
self,
endpoint: str | None = None,
project_id: str | None = None,
api_key: str | None = None,
framework: str | None = None,
auto_instrument: bool = True,
service_name: str | None = None,
service_version: str | None = None,
enable_traces: bool = True,
enable_metrics: bool = True,
enable_logs: bool = False,
capture_content: bool = True,
encode_binary: bool = True,
disabled: bool = False,
debug: bool = False,
) -> None: ...

Immutable configuration object.

client = SideSeat()
print(client.config.endpoint)
print(client.config.project_id)

Access to the underlying telemetry client for debug exporters.

client = SideSeat()
client.telemetry.setup_console_exporter()
client.telemetry.setup_file_exporter("traces.jsonl")

The OpenTelemetry TracerProvider instance managing trace collection.

client = SideSeat()
provider = client.tracer_provider
# Force flush all pending spans
provider.force_flush()

Whether telemetry is disabled.

client = SideSeat()
if client.is_disabled:
print("Telemetry is disabled")

Create a custom span for tracing.

Parameters:

  • name (str): Span name

Returns: ContextManager[Span]

client = SideSeat()
with client.span("my-operation") as span:
span.set_attribute("user_id", "123")
result = process_request()
# Errors are automatically recorded with stack trace

Get an OpenTelemetry tracer.

Parameters:

  • name (str): Tracer name

Returns: Tracer

client = SideSeat()
tracer = client.get_tracer("my-module")
with tracer.start_as_current_span("operation"):
# ... work ...
pass

Export pending spans immediately.

Parameters:

  • timeout_millis (int): Timeout in milliseconds. Default: 30000

Returns: bool

client = SideSeat()
# ... do work ...
success = client.force_flush(timeout_millis=5000)

Test server connectivity.

Parameters:

  • timeout (float): Timeout in seconds. Default: 5.0

Returns: bool

client = SideSeat()
if client.validate_connection():
print("Server is reachable")

Gracefully shutdown all exporters, flushing pending spans.

Parameters:

  • timeout_millis (int): Timeout in milliseconds. Default: 30000

Returns: None

client = SideSeat()
# ... do work ...
client.shutdown()

Use the context manager for automatic shutdown:

with SideSeat() as client:
# Your code runs with tracing enabled
run_my_agent()
# Traces flushed and shutdown automatically
from sideseat import SideSeat
client = SideSeat()
# Your code runs with tracing enabled
# ...
# Optional: explicit shutdown
client.shutdown()
from sideseat import SideSeat, Frameworks
client = SideSeat(framework=Frameworks.Strands)
client = SideSeat(
endpoint="http://localhost:5388",
project_id="my-project",
service_name="my-agent",
service_version="1.0.0",
)
client = SideSeat()
client.telemetry.setup_console_exporter() # Print spans
client.telemetry.setup_file_exporter("traces.jsonl") # Write to file
# For testing/CI
client = SideSeat(disabled=True)
# Or: SIDESEAT_DISABLED=true

The SideSeat class is thread-safe:

  • Multiple threads can create spans concurrently
  • shutdown() can be called from any thread
  • Exporters use internal locking
import threading
client = SideSeat()
def worker():
with client.span("worker"):
# ... work ...
pass
threads = [threading.Thread(target=worker) for _ in range(10)]
for t in threads:
t.start()
for t in threads:
t.join()
client.shutdown()