Class: OpenTelemetry::Exporter::Zipkin::Exporter
- Inherits:
-
Object
- Object
- OpenTelemetry::Exporter::Zipkin::Exporter
- Defined in:
- lib/opentelemetry/exporter/zipkin/exporter.rb
Overview
An OpenTelemetry trace exporter that sends spans over HTTP as JSON encoded Zipkin spans.
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(endpoint: config_opt('OTEL_EXPORTER_ZIPKIN_ENDPOINT', default: 'http://localhost:9411/api/v2/spans'), headers: config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_HEADERS', 'OTEL_EXPORTER_ZIPKIN_HEADERS'), timeout: config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_TIMEOUT', 'OTEL_EXPORTER_ZIPKIN_TIMEOUT', default: 10)) ⇒ Exporter
constructor
A new instance of Exporter.
-
#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: config_opt('OTEL_EXPORTER_ZIPKIN_ENDPOINT', default: 'http://localhost:9411/api/v2/spans'), headers: config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_HEADERS', 'OTEL_EXPORTER_ZIPKIN_HEADERS'), timeout: config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_TIMEOUT', 'OTEL_EXPORTER_ZIPKIN_TIMEOUT', default: 10)) ⇒ Exporter
Returns a new instance of Exporter.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/opentelemetry/exporter/zipkin/exporter.rb', line 30 def initialize(endpoint: config_opt('OTEL_EXPORTER_ZIPKIN_ENDPOINT', default: 'http://localhost:9411/api/v2/spans'), headers: config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_HEADERS', 'OTEL_EXPORTER_ZIPKIN_HEADERS'), timeout: config_opt('OTEL_EXPORTER_ZIPKIN_TRACES_TIMEOUT', 'OTEL_EXPORTER_ZIPKIN_TIMEOUT', default: 10)) raise ArgumentError, "invalid url for Zipkin::Exporter #{endpoint}" if invalid_url?(endpoint) raise ArgumentError, 'headers must be comma-separated k=v pairs or a Hash' unless valid_headers?(headers) @uri = if endpoint == ENV['OTEL_EXPORTER_ZIPKIN_ENDPOINT'] URI("#{endpoint}/api/v2/spans") else URI(endpoint) end @http = Net::HTTP.new(@uri.host, @uri.port) @http.use_ssl = @uri.scheme == 'https' @http.keep_alive_timeout = KEEP_ALIVE_TIMEOUT @timeout = timeout.to_f @path = @uri.path @headers = case headers when String then CSV.parse(headers, col_sep: '=', row_sep: ',').to_h when Hash then headers end @shutdown = false end |
Instance Method Details
#export(span_data, timeout: nil) ⇒ Integer
Called to export sampled SDK::Trace::SpanData structs.
63 64 65 66 67 68 69 70 71 |
# File 'lib/opentelemetry/exporter/zipkin/exporter.rb', line 63 def export(span_data, timeout: nil) return FAILURE if @shutdown zipkin_spans = encode_spans(span_data) send_spans(zipkin_spans, timeout: timeout) rescue StandardError => e OpenTelemetry.handle_error(exception: e, message: 'unexpected error in Zipkin::Exporter#export') FAILURE 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.
78 79 80 |
# File 'lib/opentelemetry/exporter/zipkin/exporter.rb', line 78 def force_flush(timeout: nil) SUCCESS end |
#shutdown(timeout: nil) ⇒ Object
Called when SDK::Trace::Tracer#shutdown is called, if this exporter is registered to a SDK::Trace::Tracer object.
90 91 92 93 |
# File 'lib/opentelemetry/exporter/zipkin/exporter.rb', line 90 def shutdown(timeout: nil) @shutdown = true SUCCESS end |