(
internal_exporters: list[SpanProcessor] = None,
)
| 476 | |
| 477 | |
| 478 | def _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 | |
| 520 | def _setup_telemetry_from_env( |
no test coverage detected