Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/solarwinds_apm/opentelemetry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
require 'opentelemetry-exporter-otlp'
require 'opentelemetry-exporter-otlp-metrics'
require 'opentelemetry-instrumentation-all'
require 'opentelemetry-logs-sdk'
require 'opentelemetry-exporter-otlp-logs'
require 'opentelemetry-instrumentation-logger'

require_relative 'opentelemetry/solarwinds_propagator'
require_relative 'opentelemetry/solarwinds_response_propagator'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def inject(carrier, context: ::OpenTelemetry::Context.current,
end

private

# SW_XTRACEOPTIONS_RESPONSE_KEY -> xtrace_options_response
def recover_response_from_tracestate(span_context)
sanitized = span_context.tracestate.value(SW_XTRACEOPTIONS_RESPONSE_KEY)
Expand Down
3 changes: 3 additions & 0 deletions lib/solarwinds_apm/otel_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def self.initialize
ENV['OTEL_LOG_LEVEL'] = SolarWindsAPM::Config::SW_LOG_LEVEL_MAPPING.dig(log_level, :otel)
end

# disable log bridge by default
ENV['OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED'] = 'false' unless %w[true false].include?(ENV['OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED'].to_s)

::OpenTelemetry::SDK.configure do |c|
c.resource = final_attributes
c.use_all(@@config_map)
Expand Down
4 changes: 2 additions & 2 deletions lib/solarwinds_apm/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module SolarWindsAPM
# solarwinds_apm.gemspec during gem build process
module Version
MAJOR = 7 # breaking,
MINOR = 0 # feature,
PATCH = 2 # fix => BFF
MINOR = 1 # feature,
PATCH = 0 # fix => BFF
PRE = 'prev1'

STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
Expand Down
3 changes: 3 additions & 0 deletions solarwinds_apm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ Gem::Specification.new do |s|
s.files -= ['Rakefile']

s.add_dependency('opentelemetry-exporter-otlp', '>= 0.29.1')
s.add_dependency('opentelemetry-exporter-otlp-logs', '>= 0.2.1')
s.add_dependency('opentelemetry-exporter-otlp-metrics', '>= 0.3.0')
s.add_dependency('opentelemetry-instrumentation-all', '>= 0.31.0')
s.add_dependency('opentelemetry-instrumentation-logger', '>= 0.1.0')
s.add_dependency('opentelemetry-logs-sdk', '>= 0.4.0')
s.add_dependency('opentelemetry-metrics-sdk', '>= 0.2.0')
s.add_dependency('opentelemetry-resource-detector-aws', '>= 0.1.0')
s.add_dependency('opentelemetry-resource-detector-azure', '>= 0.2.0')
Expand Down
47 changes: 47 additions & 0 deletions test/solarwinds_apm/otel_config_log_bridge_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

# Copyright (c) 2019 SolarWinds, LLC.
# All rights reserved.

require 'minitest_helper'
require './lib/solarwinds_apm/config'
require './lib/solarwinds_apm/opentelemetry'
require './lib/solarwinds_apm/support/txn_name_manager'
require './lib/solarwinds_apm/otel_config'

describe 'Log Bridge Initialization Test' do
describe 'check if log bridge is enabled' do
after do
ENV.delete('OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED')
end

it 'OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED=true -> enabled' do
ENV['OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED'] = 'true'
SolarWindsAPM::OTelConfig.initialize
_(ENV.fetch('OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED', nil)).must_equal 'true'
end

it 'OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED=false -> enabled' do
ENV['OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED'] = 'false'
SolarWindsAPM::OTelConfig.initialize
_(ENV.fetch('OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED', nil)).must_equal 'false'
end

it 'OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED=empty -> disabled' do
ENV['OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED'] = ''
SolarWindsAPM::OTelConfig.initialize
_(ENV.fetch('OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED', nil)).must_equal 'false'
end

it 'OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED=nil -> disabled' do
ENV['OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED'] = nil
SolarWindsAPM::OTelConfig.initialize
_(ENV.fetch('OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED', nil)).must_equal 'false'
end
it 'OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED=djisdfes -> disabled' do
ENV['OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED'] = 'djisdfes'
SolarWindsAPM::OTelConfig.initialize
_(ENV.fetch('OTEL_RUBY_INSTRUMENTATION_LOGGER_ENABLED', nil)).must_equal 'false'
end
end
end