Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-9311): tag copilot Logfire spans with deployment.environment (#5718)
Andrew Neilson983b1532c55a
diff --git a/skyvern/forge/sdk/copilot/tracing_setup.py b/skyvern/forge/sdk/copilot/tracing_setup.pyindex be8ad6755..a53e4c977 100644--- a/skyvern/forge/sdk/copilot/tracing_setup.py+++ b/skyvern/forge/sdk/copilot/tracing_setup.py@@ -15,6 +15,8 @@ from typing import Anyimport structlog+from skyvern.config import settings+# Reuse the HTTP-logging redactor so trace-side and SSE-side redaction share# one exact-match sensitive-key policy.from skyvern.forge.request_logging import redact_sensitive_fields@@ -93,7 +95,11 @@ def ensure_tracing_initialized() -> None:_TRACING_INITIALIZED = Truereturn- logfire.configure(send_to_logfire="if-token-present", service_name="skyvern-copilot")+ logfire.configure(+ send_to_logfire="if-token-present",+ service_name="skyvern-copilot",+ environment=settings.ENV,+ )logfire.instrument_openai_agents()_patch_agent_span_attributes()# Logfire instruments via OpenTelemetry independently of the SDK'sdiff --git a/tests/unit/test_copilot_tracing_setup.py b/tests/unit/test_copilot_tracing_setup.pyindex 03f6306f9..4961da3eb 100644--- a/tests/unit/test_copilot_tracing_setup.py+++ b/tests/unit/test_copilot_tracing_setup.py@@ -17,6 +17,7 @@ from unittest.mock import MagicMockimport pytest+from skyvern.config import settingsfrom skyvern.forge.sdk.copilot import tracing_setup@@ -96,6 +97,7 @@ def test_enabled_with_logfire(assert len(configure_calls) == 1assert configure_calls[0]["send_to_logfire"] == "if-token-present"assert configure_calls[0]["service_name"] == "skyvern-copilot"+ assert configure_calls[0]["environment"] == settings.ENVassert instrument_calls == [None]assert patch_calls == [None]assert processors_calls == [[]]@@ -176,7 +178,13 @@ class TestTracingSetup:tracing_setup.ensure_tracing_initialized()tracing_setup.ensure_tracing_initialized()- assert configure_calls == [{"send_to_logfire": "if-token-present", "service_name": "skyvern-copilot"}]+ assert configure_calls == [+ {+ "send_to_logfire": "if-token-present",+ "service_name": "skyvern-copilot",+ "environment": settings.ENV,+ }+ ]assert instrument_calls == [None]def test_copilot_span_returns_nullcontext_when_disabled(