Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
[NO-TICKET] Update Laminar Usage (#5322)
Aaron Perez39fc16ae69b4
diff --git a/.env.example b/.env.exampleindex 8871a2dff..3405d14b4 100644--- a/.env.example+++ b/.env.example@@ -110,6 +110,13 @@ PORT=8000# ANALYTICS_ID: Distinct analytics ID (a UUID is generated if left blank).ANALYTICS_ID="anonymous"+# LAMINAR+# Skyvern's backend runs on port 8000 by default. Consider updating your self-hosted laminar to env vars to avoid conflicts+# LMNR_HTTP_PORT=8010+# LMNR_GRPC_PORT=8011+# LMNR_BASE_URL=http://localhost+# LMNR_PROJECT_API_KEY=<your-laminar-project-api-key>+# 1Password Integration# OP_SERVICE_ACCOUNT_TOKEN: API token for 1Password integrationOP_SERVICE_ACCOUNT_TOKEN=""diff --git a/docs/debugging/observability-with-laminar.mdx b/docs/debugging/observability-with-laminar.mdxindex 1d0e876e5..173682126 100644--- a/docs/debugging/observability-with-laminar.mdx+++ b/docs/debugging/observability-with-laminar.mdx@@ -184,9 +184,18 @@ If you're running Skyvern on your own infrastructure, add these to your server'sLMNR_PROJECT_API_KEY=your-laminar-api-key```-Skyvern's server includes a built-in `LaminarTrace` integration that initializes Laminar with the LiteLLM callback, capturing every LLM call, token count, and cost. It disables the automatic Skyvern/Patchright instrumentors (to avoid conflicts) and uses Laminar's `@observe` decorator on internal methods instead.+Skyvern's server initializes Laminar at startup, which auto-instruments LiteLLM to capture every LLM call, token count, and cost. No manual callback setup is needed.-No code changes needed — once the env var is set, traces appear in your Laminar project automatically.+If you're running a self-hosted Laminar instance, also set the base URL and ports:++```bash .env+LMNR_PROJECT_API_KEY=your-laminar-api-key+LMNR_BASE_URL=http://localhost+LMNR_GRPC_PORT=8011+LMNR_HTTP_PORT=8010+```++No code changes needed — once the env vars are set, traces appear in your Laminar project automatically.---diff --git a/fern/observability/overview.mdx b/fern/observability/overview.mdxindex ebb3dc7ef..b51488404 100644--- a/fern/observability/overview.mdx+++ b/fern/observability/overview.mdx@@ -18,24 +18,18 @@ Copy of this guide is available in the [Laminar documentation](https://docs.lmnr## Quickstart-To trace Skyvern workflows with Laminar, **initialize Laminar and configure LiteLLM callbacks at the top of your project**. This will automatically capture all LLM calls, browser session recordings, and workflow execution details.+To trace Skyvern workflows with Laminar, **initialize Laminar at the top of your project**. This will automatically instrument LiteLLM and capture all LLM calls, browser session recordings, and workflow execution details. No manual callback setup is needed.-```python {3-4} {8-12} {14-15}+```python {3} {7-8}from skyvern import Skyvernimport asyncio-import litellm-from lmnr import Laminar, LaminarLiteLLMCallback, Instruments+from lmnr import Laminarfrom dotenv import load_dotenvload_dotenv()-# Initialize Laminar-# This will automatically trace all Skyvern functions-# Disable OpenAI to avoid double instrumentation of LLM calls-Laminar.initialize(disabled_instruments=set([Instruments.OPENAI]))--# Configure LiteLLM to trace all LLM calls made by Skyvern-litellm.callbacks = [LaminarLiteLLMCallback()]+# Initialize Laminar — automatically instruments LiteLLM+Laminar.initialize()skyvern = Skyvern(api_key="YOUR_API_KEY")@@ -49,6 +43,10 @@ if __name__ == "__main__":asyncio.run(main())```+<Warning>+`LaminarLiteLLMCallback` and manually setting `litellm.callbacks` are deprecated. `Laminar.initialize()` handles LiteLLM instrumentation automatically.+</Warning>+## Viewing TracesYou can view traces in the Laminar UI by navigating to the traces tab in your project. When you select a trace, you can see:diff --git a/skyvern/forge/api_app.py b/skyvern/forge/api_app.pyindex c09de626d..0cc433f1a 100644--- a/skyvern/forge/api_app.py+++ b/skyvern/forge/api_app.py@@ -1,3 +1,4 @@+import osimport uuidfrom contextlib import asynccontextmanagerfrom datetime import datetime@@ -211,6 +212,25 @@ def create_api_app() -> FastAPI:forge_app_instance = start_forge_app()+ # Initialize Laminar tracing after ForgeApp so auto-instrumentation works.+ lmnr_api_key = os.environ.get("LMNR_PROJECT_API_KEY")+ if lmnr_api_key:+ try:+ from lmnr import Laminar # noqa: PLC0415++ lmnr_base_url = os.environ.get("LMNR_BASE_URL", "http://localhost")+ lmnr_grpc_port = int(os.environ.get("LMNR_GRPC_PORT", "8001"))+ lmnr_http_port = int(os.environ.get("LMNR_HTTP_PORT", "8000"))+ Laminar.initialize(+ project_api_key=lmnr_api_key,+ base_url=lmnr_base_url,+ grpc_port=lmnr_grpc_port,+ http_port=lmnr_http_port,+ )+ LOG.info("Laminar tracing initialized", base_url=lmnr_base_url, grpc_port=lmnr_grpc_port)+ except Exception as e:+ LOG.warning("Failed to initialize Laminar tracing", error=str(e))+fastapi_app = FastAPI(lifespan=lifespan)# Add CORS middleware