Class: OpenTelemetry::Exporter::Jaeger::CollectorExporter
- Inherits:
-
Object
- Object
- OpenTelemetry::Exporter::Jaeger::CollectorExporter
- Defined in:
- lib/opentelemetry/exporter/jaeger/collector_exporter.rb
Overview
An OpenTelemetry trace exporter that sends spans over HTTP as Thrift Binary encoded Jaeger spans.
Instance Method Summary collapse
-
#export(span_data, timeout: nil) ⇒ Integer
Called to export sampled SDK::Trace::SpanData structs.
-
#initialize(endpoint: ENV.fetch('OTEL_EXPORTER_JAEGER_ENDPOINT', 'http://localhost:14268/api/traces'), username: ENV['OTEL_EXPORTER_JAEGER_USER'], password: ENV['OTEL_EXPORTER_JAEGER_PASSWORD']) ⇒ CollectorExporter
constructor
A new instance of CollectorExporter.
-
#shutdown(timeout: nil) ⇒ Object
Called when SDK::Trace::Tracer#shutdown is called, if this exporter is registered to a SDK::Trace::Tracer object.
Constructor Details
#initialize(endpoint: ENV.fetch('OTEL_EXPORTER_JAEGER_ENDPOINT', 'http://localhost:14268/api/traces'), username: ENV['OTEL_EXPORTER_JAEGER_USER'], password: ENV['OTEL_EXPORTER_JAEGER_PASSWORD']) ⇒ CollectorExporter
Returns a new instance of CollectorExporter.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/opentelemetry/exporter/jaeger/collector_exporter.rb', line 18 def initialize(endpoint: ENV.fetch('OTEL_EXPORTER_JAEGER_ENDPOINT', 'http://localhost:14268/api/traces'), username: ENV['OTEL_EXPORTER_JAEGER_USER'], password: ENV['OTEL_EXPORTER_JAEGER_PASSWORD']) raise ArgumentError, "invalid url for Jaeger::CollectorExporter #{endpoint}" if invalid_url?(endpoint) raise ArgumentError, 'username and password should either both be nil or both be set' if username.nil? != password.nil? @transport = ::Thrift::HTTPClientTransport.new(endpoint) unless username.nil? || password.nil? = Base64.strict_encode64("#{username}:#{password}") auth_header = { 'Authorization': "Basic #{}" } @transport.add_headers(auth_header) end @serializer = ::Thrift::Serializer.new @shutdown = false end |
Instance Method Details
#export(span_data, timeout: nil) ⇒ Integer
Called to export sampled SDK::Trace::SpanData structs.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/opentelemetry/exporter/jaeger/collector_exporter.rb', line 41 def export(span_data, timeout: nil) return FAILURE if @shutdown encoded_batches(span_data).each do |batch| @transport.write(@serializer.serialize(batch)) end untraced do @transport.flush end SUCCESS rescue StandardError => e OpenTelemetry.logger.error("unexpected error in Jaeger::CollectorExporter#export - #{e}") FAILURE end |
#shutdown(timeout: nil) ⇒ Object
Called when SDK::Trace::Tracer#shutdown is called, if this exporter is registered to a SDK::Trace::Tracer object.
62 63 64 |
# File 'lib/opentelemetry/exporter/jaeger/collector_exporter.rb', line 62 def shutdown(timeout: nil) @shutdown = true end |