opentelemetry.exporter.cloud_trace.CloudTraceSpanExporter

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

Bases: SpanExporter

Cloud Trace span exporter for OpenTelemetry.

Parameters:
  • project_id – GCP project ID for the project to send spans to. Alternatively, can be configured with OTEL_EXPORTER_GCP_TRACE_PROJECT_ID.

  • 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). Alternatively, can be configured with OTEL_EXPORTER_GCP_TRACE_RESOURCE_REGEX.

Methods

export

Export the spans to Cloud Trace.

force_flush

Hint to ensure that the export of any spans the exporter has received prior to the call to ForceFlush SHOULD be completed as soon as possible, preferably before returning from this method.

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

force_flush(timeout_millis=30000)

Hint to ensure that the export of any spans the exporter has received prior to the call to ForceFlush SHOULD be completed as soon as possible, preferably before returning from this method.

Return type:

bool

shutdown()[source]

Shuts down the exporter.

Called when the SDK is shut down.