Python: Telemetry and observability follow-up (#833)

* updated telemetry work

* updated telemetry

* slight improvement

* updated tests

* fixes for telemetry

* fixes for mypy

* added settings setup to runner to avoid error

* streamline usage

* updated tests

* updated tests

* further refinement

* fix dumped item for otel

* removed enable_workflow_otel

* final fixes

* final fixes

* updated samples

* removed exporters

* fix tests

* fixed last import'

* fixed devui
This commit is contained in:
Eduard van Valkenburg
2025-09-23 08:21:56 +02:00
committed by GitHub
Unverified
parent f93f16a9ad
commit 2576e7a091
52 changed files with 1625 additions and 1586 deletions
@@ -32,7 +32,7 @@ class GAIATelemetryConfig:
self,
enable_tracing: bool = False,
otlp_endpoint: str | None = None,
application_insights_connection_string: str | None = None,
applicationinsights_connection_string: str | None = None,
enable_live_metrics: bool = False,
trace_to_file: bool = False,
file_path: str | None = None,
@@ -43,30 +43,29 @@ class GAIATelemetryConfig:
Args:
enable_tracing: Whether to enable OpenTelemetry tracing
otlp_endpoint: OTLP endpoint for trace export
application_insights_connection_string: Azure Monitor connection string
applicationinsights_connection_string: Azure Monitor connection string
enable_live_metrics: Enable Azure Monitor live metrics
trace_to_file: Whether to export traces to local file
file_path: Path for local file export (defaults to gaia_traces.json)
"""
self.enable_tracing = enable_tracing
self.otlp_endpoint = otlp_endpoint
self.application_insights_connection_string = application_insights_connection_string
self.applicationinsights_connection_string = applicationinsights_connection_string
self.enable_live_metrics = enable_live_metrics
self.trace_to_file = trace_to_file
self.file_path = file_path or "gaia_traces.json"
def setup_telemetry(self) -> None:
def setup_observability(self) -> None:
"""Set up OpenTelemetry based on configuration."""
if not self.enable_tracing:
return
from agent_framework.telemetry import setup_telemetry
from agent_framework.observability import setup_observability
setup_telemetry(
enable_otel=True,
setup_observability(
enable_sensitive_data=True, # Enable for detailed task traces
otlp_endpoint=self.otlp_endpoint,
application_insights_connection_string=self.application_insights_connection_string,
applicationinsights_connection_string=self.applicationinsights_connection_string,
enable_live_metrics=self.enable_live_metrics,
)
@@ -272,7 +271,7 @@ class GAIA:
self.telemetry_config = telemetry_config or GAIATelemetryConfig()
# Set up telemetry
self.telemetry_config.setup_telemetry()
self.telemetry_config.setup_observability()
# Initialize tracer
if self.telemetry_config.enable_tracing:
@@ -29,7 +29,7 @@ async def main() -> None:
enable_tracing=True, # Enable OpenTelemetry tracing
# Optional: Configure external endpoints
# otlp_endpoint="http://localhost:4317", # For Aspire Dashboard or other OTLP endpoints
# application_insights_connection_string="your_connection_string", # For Azure Monitor
# applicationinsights_connection_string="your_connection_string", # For Azure Monitor
# enable_live_metrics=True, # Enable Azure Monitor live metrics
# Configure local file tracing
trace_to_file=True, # Export traces to local file