Class: Lapsoss::Adapters::OpenobserveAdapter

Inherits:
Base
  • Object
show all
Includes:
Concerns::HttpDelivery, Concerns::LevelMapping
Defined in:
lib/lapsoss/adapters/openobserve_adapter.rb

Overview

OpenObserve adapter - sends errors as structured JSON logs OpenObserve is an observability platform that accepts logs via simple JSON API Docs: openobserve.ai/docs/ingestion/

Constant Summary collapse

DEFAULT_STREAM =
"errors"
DEFAULT_ORG =
"default"

Constants included from Concerns::LevelMapping

Concerns::LevelMapping::LEVEL_MAPPINGS

Constants inherited from Base

Base::JSON_CONTENT_TYPE, Base::USER_AGENT

Instance Attribute Summary

Attributes inherited from Base

#name, #settings

Instance Method Summary collapse

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 included from Concerns::LevelMapping

#map_level

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 = {}) ⇒ OpenobserveAdapter



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/lapsoss/adapters/openobserve_adapter.rb', line 20

def initialize(name, settings = {})
  super

  @endpoint = settings[:endpoint].presence || ENV["OPENOBSERVE_ENDPOINT"]
  @username = settings[:username].presence || ENV["OPENOBSERVE_USERNAME"]
  @password = settings[:password].presence || ENV["OPENOBSERVE_PASSWORD"]
  @org = settings[:org].presence || ENV["OPENOBSERVE_ORG"] || DEFAULT_ORG
  @stream = settings[:stream].presence || ENV["OPENOBSERVE_STREAM"] || DEFAULT_STREAM

  if @endpoint.blank? || @username.blank? || @password.blank?
    Lapsoss.configuration.logger&.warn "[Lapsoss::OpenobserveAdapter] Missing endpoint, username or password - adapter disabled"
    @enabled = false
    return
  end

  setup_endpoint
end

Instance Method Details

#capabilitiesObject



42
43
44
45
46
47
48
# File 'lib/lapsoss/adapters/openobserve_adapter.rb', line 42

def capabilities
  super.merge(
    breadcrumbs: false,
    code_context: true,
    data_scrubbing: true
  )
end

#capture(event) ⇒ Object



38
39
40
# File 'lib/lapsoss/adapters/openobserve_adapter.rb', line 38

def capture(event)
  deliver(event.scrubbed)
end