Class: TracecapOpenTelemetry::Exporter
- Inherits:
-
OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter
- Object
- OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter
- TracecapOpenTelemetry::Exporter
- Defined in:
- lib/tracecap_opentelemetry/exporter.rb
Overview
pretend to be this for now for ‘simple_exporter?’ check
Constant Summary collapse
- SUCCESS =
OpenTelemetry::SDK::Trace::Export::SUCCESS
- FAILURE =
OpenTelemetry::SDK::Trace::Export::FAILURE
Instance Method Summary collapse
- #export(spans, timeout: nil) ⇒ Object
- #force_flush(timeout: nil) ⇒ Object
-
#initialize ⇒ Exporter
constructor
A new instance of Exporter.
- #shutdown(timeout: nil) ⇒ Object
Constructor Details
#initialize ⇒ Exporter
Returns a new instance of Exporter.
10 11 12 |
# File 'lib/tracecap_opentelemetry/exporter.rb', line 10 def initialize @stopped = false end |
Instance Method Details
#export(spans, timeout: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tracecap_opentelemetry/exporter.rb', line 14 def export(spans, timeout: nil) return FAILURE if @stopped return SUCCESS unless TracecapOpenTelemetry::active? Array(spans).each do |span| = span.attributes component = ["db.system"] || ["component"] || "Trace" operation = span.name context = .dup context["span_id"] = span.hex_span_id context["span_parent_id"] = span.hex_parent_span_id if span.hex_parent_span_id != "0000000000000000" json_ctx = JSON.dump(context) start_time_nsec = span..to_i end_time_nsec = span..to_i now_nsec = (Time.now.to_r * 1_000_000_000).to_i duration = end_time_nsec - start_time_nsec end_delta = now_nsec - end_time_nsec TracecapOpenTelemetry::emit_span(duration, end_delta, component.to_s, operation.to_s, json_ctx) end SUCCESS end |
#force_flush(timeout: nil) ⇒ Object
42 43 44 |
# File 'lib/tracecap_opentelemetry/exporter.rb', line 42 def force_flush(timeout: nil) SUCCESS end |
#shutdown(timeout: nil) ⇒ Object
46 47 48 49 |
# File 'lib/tracecap_opentelemetry/exporter.rb', line 46 def shutdown(timeout: nil) @stopped = true SUCCESS end |