Class: Bigcommerce::Lightstep::Interceptors::Env
- Defined in:
- lib/bigcommerce/lightstep/interceptors/env.rb
Overview
Hydrates span tags with specified ENV vars
Constant Summary collapse
- PRESET_NOMAD =
{ 'container.cpu': 'NOMAD_CPU_LIMIT', 'container.mem': 'NOMAD_MEMORY_LIMIT', 'git.sha': 'NOMAD_META_SHA', 'nomad.task_name': 'NOMAD_TASK_NAME', 'provider.region': 'NOMAD_REGION', 'provider.datacenter': 'NOMAD_DC' }.freeze
- PRESET_HOSTNAME =
{ 'hostname': 'HOSTNAME', }.freeze
Instance Method Summary collapse
- #call(span:) {|span| ... } ⇒ Object
-
#initialize(keys: nil, env: nil, presets: []) ⇒ Env
constructor
A new instance of Env.
Constructor Details
#initialize(keys: nil, env: nil, presets: []) ⇒ Env
Returns a new instance of Env.
43 44 45 46 47 48 |
# File 'lib/bigcommerce/lightstep/interceptors/env.rb', line 43 def initialize(keys: nil, env: nil, presets: []) @keys = keys || {} @presets = presets || [] @env = env || ENV augment_keys_with_presets! end |
Instance Method Details
#call(span:) {|span| ... } ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/bigcommerce/lightstep/interceptors/env.rb', line 53 def call(span:) @keys.each do |span_key, env_key| value = @env.fetch(env_key.to_s, nil) span.set_tag(span_key.to_s.downcase.tr('-', '_').strip, value.nil? ? '' : value) end yield span end |