Skip to main content

Laminar.initialize(…)

Initialize Laminar tracing and auto-instrumentation. Parameters:
NameTypeDefaultDescription
project_api_keystrNoneProject API key (defaults to LMNR_PROJECT_API_KEY)
base_urlstrhttps://api.lmnr.aiBase URL
base_http_urlstrNoneOTLP HTTP base URL
http_portint443OTLP HTTP port
grpc_portint8443OTLP gRPC port
instrumentsset[Instruments]NoneEnable only these instruments
disabled_instrumentsset[Instruments]NoneDisable these instruments
disable_batchboolFalseDisable batching span processor
max_export_batch_sizeint | NoneNoneBatch size (defaults to 64 when None)
export_timeout_secondsint | NoneNoneExport timeout (defaults to 30 when None)
set_global_tracer_providerboolTrueSet global OTEL tracer provider
otel_logger_levelintlogging.ERROROTEL logger level
session_recording_optionsSessionRecordingOptionsNoneBrowser session recording options
force_httpboolFalseForce OTLP HTTP exporter
metadatadict[str, AttributeValue]NoneGlobal trace metadata
Returns: None

Instruments

Enum of available auto-instrumentations.
from lmnr import Laminar, Instruments

# Enable only specific instruments
Laminar.initialize(
    instruments={Instruments.OPENAI, Instruments.ANTHROPIC}
)

# Disable specific instruments
Laminar.initialize(
    disabled_instruments={Instruments.LANGCHAIN}
)
Available instruments: OPENAI, ANTHROPIC, BEDROCK, COHERE, GOOGLE_GENAI, GROQ, MISTRAL, OLLAMA, TOGETHER, VERTEXAI, LANGCHAIN, LANGGRAPH, LLAMA_INDEX, HAYSTACK, CREWAI, PINECONE, QDRANT, CHROMA, MILVUS, WEAVIATE, LANCEDB, MARQO, PLAYWRIGHT, PATCHRIGHT, BROWSER_USE, BROWSER_USE_SESSION, SKYVERN, CLAUDE_AGENT, KERNEL, MCP, and more.

Daytona sandbox logs (streaming)

Laminar can capture streaming command logs from Daytona sandboxes. These log records are stored in the logs table and can be queried in the SQL Editor (there is no dedicated logs UI yet).
import asyncio

from daytona import AsyncDaytona, SessionExecuteRequest
from lmnr import Laminar, observe

Laminar.initialize()

@observe()
async def run_sandbox_command():
    daytona = AsyncDaytona()
    sandbox = await daytona.create()

    session_id = "streaming-session"
    await sandbox.process.create_session(session_id)

    await sandbox.process.execute_session_command(
        session_id,
        SessionExecuteRequest(
            command=(
                'for i in {1..5}; do echo "Processing iteration $i of 5 - '
                'This is a longer test message to verify streaming output handling '
                'with substantial text content"; '
                'echo "Error at iteration $i: This is a simulated error message '
                'with extended details for testing purposes" >&2; sleep 1; done'
            ),
            run_async=True,
        ),
    )

    print("Continuing execution while command runs in background...")
    await asyncio.sleep(10)
    print("Other operations completed!")

    await sandbox.delete()

if __name__ == "__main__":
    asyncio.run(run_sandbox_command())
Example query:
SELECT time, severity_text, body, attributes
FROM logs
WHERE time > now() - INTERVAL 1 DAY
ORDER BY time DESC

SessionRecordingOptions

Browser session recording configuration.
from lmnr import SessionRecordingOptions, MaskInputOptions

options = SessionRecordingOptions(
    mask_input_options=MaskInputOptions(...)
)

Laminar.initialize(session_recording_options=options)