File tree Expand file tree Collapse file tree
agent/frameworks/adk/python/templates
mcp/frameworks/python/templates Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,5 +14,7 @@ COPY .python-version .python-version
1414
1515RUN uv sync
1616
17+ ENV OTEL_SERVICE_NAME= {{.Name }}
18+
1719CMD [" {{.Name}}" ]
1820
Original file line number Diff line number Diff line change 11import random
2+ import os
23
34from google.adk import Agent
45from google.adk.tools.tool_context import ToolContext
@@ -8,6 +9,9 @@ from google.adk.models.lite_llm import LiteLlm
89from .mcp_tools import get_mcp_tools
910
1011# Initialize OpenTelemetry
12+ # Set service name from environment variable for OpenTelemetry
13+ os.environ.setdefault ('OTEL_SERVICE_NAME', '{{.Name }}')
14+
1115from google.adk.telemetry.setup import maybe_set_otel_providers
1216maybe_set_otel_providers()
1317
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ services:
2828 - KAGENT_NAME= placeholder
2929 - KAGENT_NAMESPACE= placeholder
3030 - AGENT_NAME= {{.Name }}
31+ - OTEL_SERVICE_NAME= {{.Name }}
3132 - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT= $ {OTEL_EXPORTER_OTLP_TRACES_ENDPOINT}
3233 - MODEL_PROVIDER= {{.ModelProvider }}
3334 - MODEL_NAME= {{.ModelName }}
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
6565# Set environment variables
6666ENV PYTHONPATH=/app
6767ENV PYTHONUNBUFFERED=1
68+ ENV OTEL_SERVICE_NAME={{.Name}}
6869
6970# Default command
70- CMD ["python", "src/main.py"]
71+ CMD ["python", "src/main.py"]
You can’t perform that action at this time.
0 commit comments