opentelemetry.exporter.cloud_trace.CloudTraceSpanExporter

class opentelemetry.exporter.cloud_trace.CloudTraceSpanExporter(project_id=None, client=None, resource_regex=None)[source]

Bases: opentelemetry.sdk.trace.export.SpanExporter

Cloud Trace span exporter for OpenTelemetry.

Parameters
  • project_id – ID of the cloud project that will receive the traces.

  • client – Cloud Trace client. If not given, will be taken from gcloud default credentials

  • resource_regex – Resource attributes with keys matching this regex will be added to exported spans as labels (default: None).

Methods

export

Export the spans to Cloud Trace.

shutdown

Shuts down the exporter.

export(spans)[source]

Export the spans to Cloud Trace.

See: https://cloud.google.com/trace/docs/reference/v2/rest/v2/projects.traces/batchWrite

Parameters

spans (Sequence[ReadableSpan]) – Sequence of spans to export

Return type

SpanExportResult

shutdown()[source]

Shuts down the exporter.

Called when the SDK is shut down.