opentelemetry-exporter-google_cloud_trace - Class OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter (v0.1.1)
Stay organized with collections
Save and categorize content based on your preferences.
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
defexport(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
defforce_flush(timeout:nil)
Called when SDK::Trace::TracerProvider#force_flush is called, if
this exporter is registered to a SDK::Trace::TracerProvider
object.
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) —
require'opentelemetry/sdk'require'opentelemetry/instrumentation/all'require'opentelemetry/exporter/google_cloud_trace'OpenTelemetry::SDK.configuredo|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
defshutdown(timeout:nil)
Called when SDK::Trace::TracerProvider#shutdown is called, if
this exporter is registered to a SDK::Trace::TracerProvider
object.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-09 UTC."],[],[],null,["# opentelemetry-exporter-google_cloud_trace - Class OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter (v0.1.1)\n\nReference documentation and code samples for the opentelemetry-exporter-google_cloud_trace class OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter.\n\nThis provides an implementation of span exporter for Google Cloud Trace\nIt will convert the Opentelemetry span data into Clould Trace spans\nand publish them to the Cloud trace service. \n\nInherits\n--------\n\n- Object\n\nMethods\n-------\n\n### #export\n\n def export(span_data, timeout: nil) -\u003e Integer\n\nCalled to export sampled SDK::Trace::SpanData structs. \n**Parameter**\n\n- **span_data** (Enumerable\\\u003cOpenTelemetry::SDK::Trace::SpanData\\\u003e) --- the list of recorded SDK::Trace::SpanData structs to be exported. \n**Returns**\n\n- (Integer) --- the result of the export.\n\n### #force_flush\n\n def force_flush(timeout: nil)\n\nCalled when SDK::Trace::TracerProvider#force_flush is called, if\nthis exporter is registered to a SDK::Trace::TracerProvider\nobject.\n\n### #initialize\n\n def initialize(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil) -\u003e OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter\n\nCreates a new object for google cloud trace\nopentelemetry span exporter. It creates client for\nGoogle cloud trace service to be used for publihing span. \n**Parameters**\n\n- **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.\n- **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.\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling\n the set of resources and operations that the connection can access.\n See [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scope is:\n - `https://www.googleapis.com/auth/trace.append`\n- **timeout** (Numeric) *(defaults to: nil)* --- Default timeout to use in requests. Optional.\n- **endpoint** (String) *(defaults to: nil)* --- Override of the endpoint host name. Optional. If the param is nil, uses the default endpoint. \n**Returns**\n\n- ([OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter](./OpenTelemetry-Exporter-GoogleCloudTrace-SpanExporter)) \n**Raises**\n\n- (ArgumentError)\n**Example** \n\n```ruby\nrequire 'opentelemetry/sdk'\nrequire 'opentelemetry/instrumentation/all'\nrequire 'opentelemetry/exporter/google_cloud_trace'\nOpenTelemetry::SDK.configure do |c|\n c.service_name = 'test_app'\n c.add_span_processor(\n OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(\n OpenTelemetry::Exporter::GoogleCloudTrace::SpanExporter.new\n )\n )\n c.use_all() # enables all instrumentation!\nend\n```\n\n### #shutdown\n\n def shutdown(timeout: nil)\n\nCalled when SDK::Trace::TracerProvider#shutdown is called, if\nthis exporter is registered to a SDK::Trace::TracerProvider\nobject."]]