opentelemetry-exporter-google_cloud_trace - Class OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter (v0.1.1)

Reference documentation and code samples for the opentelemetry-exporter-google_cloud_trace class OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter.

This provides an implementation of span exporter for Google Cloud Trace It will convert the Opentelemetry span data into Clould Trace spans and publish them to the Cloud trace service.

Inherits

  • Object

Methods

#export

def export(span_data, timeout: nil) -> Integer

Called to export sampled SDK::Trace::SpanData structs.

Parameter
  • span_data (Enumerable<OpenTelemetry::SDK::Trace::SpanData>) — the list of recorded SDK::Trace::SpanData structs to be exported.
Returns
  • (Integer) — the result of the export.

#force_flush

def force_flush(timeout: nil)

Called when SDK::Trace::TracerProvider#force_flush is called, if this exporter is registered to a SDK::Trace::TracerProvider object.

#initialize

def initialize(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil) -> OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter

Creates a new object for google cloud trace opentelemetry span exporter. It creates client for Google cloud trace service to be used for publihing span.

Parameters
  • project_id (String) (defaults to: nil) — Project identifier for the Trace service you are connecting to. If not present, the default project for the credentials is used.
  • credentials (String, Hash, Google::Auth::Credentials) (defaults to: nil) — The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object.
  • scope (String, Array<String>) (defaults to: nil)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See Using OAuth 2.0 to Access Google APIs.

    The default scope is:

    • https://www.googleapis.com/auth/trace.append
  • timeout (Numeric) (defaults to: nil) — Default timeout to use in requests. Optional.
  • endpoint (String) (defaults to: nil) — Override of the endpoint host name. Optional. If the param is nil, uses the default endpoint.
Raises
  • (ArgumentError)
Example
require 'opentelemetry/sdk'
require 'opentelemetry/instrumentation/all'
require 'opentelemetry/exporter/google_cloud_trace'
OpenTelemetry::SDK.configure do |c|
  c.service_name = 'test_app'
  c.add_span_processor(
       OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
         OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter.new
       )
     )
  c.use_all() # enables all instrumentation!
end

#shutdown

def shutdown(timeout: nil)

Called when SDK::Trace::TracerProvider#shutdown is called, if this exporter is registered to a SDK::Trace::TracerProvider object.