MCPcopy Index your code
hub / github.com/google/adk-python / _setup_gcp_telemetry

Function _setup_gcp_telemetry

src/google/adk/cli/api_server.py:478–517  ·  view source on GitHub ↗
(
    internal_exporters: list[SpanProcessor] = None,
)

Source from the content-addressed store, hash-verified

476
477
478def _setup_gcp_telemetry(
479 internal_exporters: list[SpanProcessor] = None,
480):
481 if typing.TYPE_CHECKING:
482 from ..telemetry.setup import OTelHooks
483
484 otel_hooks_to_add: list[OTelHooks] = []
485
486 if internal_exporters:
487 from ..telemetry.setup import OTelHooks
488
489 # Register ADK-specific exporters in trace provider.
490 otel_hooks_to_add.append(OTelHooks(span_processors=internal_exporters))
491
492 import google.auth
493
494 from ..telemetry.google_cloud import get_gcp_exporters
495 from ..telemetry.google_cloud import get_gcp_resource
496 from ..telemetry.setup import maybe_set_otel_providers
497
498 credentials, project_id = google.auth.default()
499
500 otel_hooks_to_add.append(
501 get_gcp_exporters(
502 # TODO - use trace_to_cloud here as well once otel_to_cloud is no
503 # longer experimental.
504 enable_cloud_tracing=True,
505 # TODO - re-enable metrics once errors during shutdown are fixed.
506 enable_cloud_metrics=False,
507 enable_cloud_logging=True,
508 google_auth=(credentials, project_id),
509 )
510 )
511 otel_resource = get_gcp_resource(project_id)
512
513 maybe_set_otel_providers(
514 otel_hooks_to_setup=otel_hooks_to_add,
515 otel_resource=otel_resource,
516 )
517 _setup_instrumentation_lib_if_installed()
518
519
520def _setup_telemetry_from_env(

Callers 1

_setup_telemetryFunction · 0.85

Calls 7

OTelHooksClass · 0.85
get_gcp_exportersFunction · 0.85
get_gcp_resourceFunction · 0.85
maybe_set_otel_providersFunction · 0.85
defaultMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected