Module: Portage::Ucp::Observability
- Defined in:
- lib/portage/ucp/observability.rb
Overview
Structured log events (§12), emitted through a consumer-injected logger (defaults to Logger.new($stdout)) so the gem instruments nothing to a specific APM — it just exposes the events. Redacts payment_token, oauth_token, and Authorization by default so a debugging trail never leaks the exact values this gem is most careful never to log.
Constant Summary collapse
- REDACTED_KEYS =
%w[payment_token oauth_token authorization].freeze
- REDACTED =
"[REDACTED]".freeze
Class Method Summary collapse
Class Method Details
.log(logger, event, **fields) ⇒ Object
15 16 17 |
# File 'lib/portage/ucp/observability.rb', line 15 def self.log(logger, event, **fields) logger.info(JSON.generate({ event: event }.merge(redact(fields)))) end |
.redact(value) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/portage/ucp/observability.rb', line 19 def self.redact(value) case value when Hash value.to_h { |key, val| [key, REDACTED_KEYS.include?(key.to_s.downcase) ? REDACTED : redact(val)] } when Array value.map { |val| redact(val) } else value end end |