Class: OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter
- Inherits:
-
Object
- Object
- OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter
- Defined in:
- lib/opentelemetry/exporter/google_cloud_trace/span_exporter.rb
Overview
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.
Instance Method Summary collapse
-
#export(span_data, timeout: nil) ⇒ Integer
Called to export sampled SDK::Trace::SpanData structs.
-
#force_flush(timeout: nil) ⇒ Object
Called when SDK::Trace::TracerProvider#force_flush is called, if this exporter is registered to a SDK::Trace::TracerProvider object.
-
#initialize(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil) ⇒ OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter
constructor
Creates a new object for google cloud trace opentelemetry span exporter.
-
#shutdown(timeout: nil) ⇒ Object
Called when SDK::Trace::TracerProvider#shutdown is called, if this exporter is registered to a SDK::Trace::TracerProvider object.
Constructor Details
#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.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/opentelemetry/exporter/google_cloud_trace/span_exporter.rb', line 75 def initialize project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil @client = ::Google::Cloud::Trace::V2::TraceService::Client.new do |config| config.project_id = project_id if project_id config.credentials = credentials if credentials config.scope = scope if scope config.timeout = timeout if timeout config.endpoint = endpoint if endpoint end @project_id = (project_id || default_project_id || credentials&.project_id) @project_id = @project_id.to_s raise ArgumentError, "project_id is missing" if @project_id.empty? @shutdown = false @translator = Translator.new @project_id end |
Instance Method Details
#export(span_data, timeout: nil) ⇒ Integer
Called to export sampled SDK::Trace::SpanData structs.
104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/opentelemetry/exporter/google_cloud_trace/span_exporter.rb', line 104 def export span_data, timeout: nil return FAILURE if @shutdown begin batch_request = @translator.create_batch span_data @client.batch_write_spans batch_request SUCCESS rescue StandardError FAILURE end end |
#force_flush(timeout: nil) ⇒ Object
Called when SDK::Trace::TracerProvider#force_flush is called, if this exporter is registered to a SDK::Trace::TracerProvider object.
119 120 121 |
# File 'lib/opentelemetry/exporter/google_cloud_trace/span_exporter.rb', line 119 def force_flush timeout: nil SUCCESS end |
#shutdown(timeout: nil) ⇒ Object
Called when SDK::Trace::TracerProvider#shutdown is called, if this exporter is registered to a SDK::Trace::TracerProvider object.
126 127 128 129 |
# File 'lib/opentelemetry/exporter/google_cloud_trace/span_exporter.rb', line 126 def shutdown timeout: nil @shutdown = true SUCCESS end |