Skip to content

Commit 55aa6f6

Browse files
jawoszekcopybara-github
authored andcommitted
feat(otel): set default_log_name for GCP logging exporter
Uses value of GCP_DEFAULT_LOG_NAME env var if it exists, defaults to literal adk-otel. PiperOrigin-RevId: 817125337
1 parent 9b8a4aa commit 55aa6f6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/google/adk/telemetry/google_cloud.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from __future__ import annotations
1616

1717
import logging
18+
import os
1819
from typing import cast
1920
from typing import Optional
2021
from typing import TYPE_CHECKING
@@ -37,6 +38,9 @@
3738

3839
logger = logging.getLogger('google_adk.' + __name__)
3940

41+
_GCP_LOG_NAME_ENV_VARIABLE_NAME = 'GOOGLE_CLOUD_DEFAULT_LOG_NAME'
42+
_DEFAULT_LOG_NAME = 'adk-otel'
43+
4044

4145
@experimental
4246
def get_gcp_exporters(
@@ -118,9 +122,13 @@ def _get_gcp_metrics_exporter(project_id: str) -> MetricReader:
118122
def _get_gcp_logs_exporter(project_id: str) -> LogRecordProcessor:
119123
from opentelemetry.exporter.cloud_logging import CloudLoggingExporter
120124

125+
default_log_name = os.environ.get(
126+
_GCP_LOG_NAME_ENV_VARIABLE_NAME, _DEFAULT_LOG_NAME
127+
)
121128
return BatchLogRecordProcessor(
122-
# TODO(jawoszek) - add default_log_name once design is approved.
123-
CloudLoggingExporter(project_id=project_id)
129+
CloudLoggingExporter(
130+
project_id=project_id, default_log_name=default_log_name
131+
),
124132
)
125133

126134

0 commit comments

Comments
 (0)