Class: Uptrace::Trace::Exporter
- Inherits:
-
Object
- Object
- Uptrace::Trace::Exporter
- Defined in:
- lib/uptrace/trace/exporter.rb
Overview
Exporter is a span exporter for OpenTelemetry.
Instance Method Summary collapse
-
#export(spans, timeout: nil) ⇒ Integer
Called to export sampled OpenTelemetry::SDK::Trace::SpanData structs.
-
#initialize(dsn) ⇒ Exporter
constructor
A new instance of Exporter.
-
#shutdown(timeout: nil) ⇒ Object
Called when OpenTelemetry::SDK::Trace::Tracer#shutdown is called, if this exporter is registered to a OpenTelemetry::SDK::Trace::Tracer object.
Constructor Details
#initialize(dsn) ⇒ Exporter
Returns a new instance of Exporter.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/uptrace/trace/exporter.rb', line 23 def initialize(dsn) @dsn = dsn @endpoint = "/api/v1/tracing/#{@dsn.project_id}/spans" @http = Net::HTTP.new(@dsn.host, 443) @http.use_ssl = true @http.open_timeout = 5 @http.read_timeout = 5 @http.keep_alive_timeout = 30 end |
Instance Method Details
#export(spans, timeout: nil) ⇒ Integer
Called to export sampled OpenTelemetry::SDK::Trace::SpanData structs.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/uptrace/trace/exporter.rb', line 41 def export(spans, timeout: nil) return SUCCESS if @disabled return FAILURE if @shutdown out = [] spans.each do |span| out.push(uptrace_span(span)) end send({ spans: out }, timeout: timeout) end |
#shutdown(timeout: nil) ⇒ Object
Called when OpenTelemetry::SDK::Trace::Tracer#shutdown is called, if this exporter is registered to a OpenTelemetry::SDK::Trace::Tracer object.
59 60 61 62 |
# File 'lib/uptrace/trace/exporter.rb', line 59 def shutdown(timeout: nil) # rubocop:disable Lint/UnusedMethodArgument @shutdown = true @http.finish if @http.started? end |