Class: Lapsoss::Adapters::OtlpAdapter
- Includes:
- Concerns::EnvelopeBuilder, Concerns::HttpDelivery, Concerns::StacktraceBuilder, Concerns::TraceContext
- Defined in:
- lib/lapsoss/adapters/otlp_adapter.rb
Overview
OTLP adapter - sends errors via OpenTelemetry Protocol Works with any OTLP-compatible backend: SigNoz, Jaeger, Tempo, Honeycomb, etc. Docs: opentelemetry.io/docs/specs/otlp/
Constant Summary collapse
- STATUS_CODE_UNSET =
OTLP status codes
0- STATUS_CODE_OK =
1- STATUS_CODE_ERROR =
2- SPAN_KIND_INTERNAL =
OTLP span kinds
1- DEFAULT_ENDPOINT =
"http://localhost:4318"
Constants included from Concerns::EnvelopeBuilder
Concerns::EnvelopeBuilder::GZIP_THRESHOLD
Constants inherited from Base
Base::JSON_CONTENT_TYPE, Base::USER_AGENT
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #capabilities ⇒ Object
- #capture(event) ⇒ Object
-
#initialize(name, settings = {}) ⇒ OtlpAdapter
constructor
A new instance of OtlpAdapter.
Methods included from Concerns::EnvelopeBuilder
#build_envelope_wrapper, #format_breadcrumbs, #format_timestamp, #sdk_info
Methods included from Concerns::TraceContext
#generate_span_id, #generate_trace_id, #timestamp_micros, #timestamp_millis, #timestamp_nanos
Methods included from Concerns::StacktraceBuilder
#build_frame, #build_frames, #build_raw_stacktrace, #build_stacktrace_string
Methods included from Concerns::HttpDelivery
#build_delivery_headers, #deliver, #git_branch, #git_sha, #handle_client_error, #handle_delivery_error, #handle_response, #mark_error_handled
Methods inherited from Base
#disable!, #enable!, #enabled?, #flush, #shutdown, #supports?
Methods included from Validators
logger, validate_api_key!, validate_callable!, validate_dsn!, validate_environment!, validate_presence!, validate_retries!, validate_sample_rate!, validate_timeout!, validate_url!
Constructor Details
#initialize(name, settings = {}) ⇒ OtlpAdapter
Returns a new instance of OtlpAdapter.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/lapsoss/adapters/otlp_adapter.rb', line 26 def initialize(name, settings = {}) super @endpoint = settings[:endpoint].presence || ENV["OTLP_ENDPOINT"] || DEFAULT_ENDPOINT @headers = settings[:headers] || {} @service_name = settings[:service_name].presence || ENV["OTEL_SERVICE_NAME"] || "rails" @environment = settings[:environment].presence || ENV["OTEL_ENVIRONMENT"] || "production" # Support common auth patterns if (api_key = settings[:api_key].presence || ENV["OTLP_API_KEY"]) @headers["Authorization"] = "Bearer #{api_key}" end if (signoz_key = settings[:signoz_api_key].presence || ENV["SIGNOZ_API_KEY"]) @headers["signoz-access-token"] = signoz_key end setup_endpoint end |
Instance Method Details
#capabilities ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/lapsoss/adapters/otlp_adapter.rb', line 50 def capabilities super.merge( breadcrumbs: false, code_context: true, data_scrubbing: true ) end |
#capture(event) ⇒ Object
46 47 48 |
# File 'lib/lapsoss/adapters/otlp_adapter.rb', line 46 def capture(event) deliver(event.scrubbed) end |