Skip to content

Commit

Permalink
clean up to pass last main suite test, CircleCI integrations, and Git…
Browse files Browse the repository at this point in the history
…Hub checks
  • Loading branch information
sarahchen6 committed Aug 10, 2023
1 parent a3e7ee1 commit b61584c
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 50 deletions.
2 changes: 2 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ target :ddtrace do
ignore 'lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb'
ignore 'lib/datadog/profiling/collectors/old_stack.rb'
ignore 'lib/datadog/profiling/collectors/stack.rb'
ignore 'lib/datadog/profiling/diagnostics/environment_logger.rb'
ignore 'lib/datadog/profiling/encoding/profile.rb'
ignore 'lib/datadog/profiling/event.rb'
ignore 'lib/datadog/profiling/events/stack.rb'
Expand Down Expand Up @@ -554,6 +555,7 @@ target :ddtrace do
ignore 'lib/datadog/tracing/contrib/utils/quantization/hash.rb'
ignore 'lib/datadog/tracing/contrib/utils/quantization/http.rb'
ignore 'lib/datadog/tracing/correlation.rb'
ignore 'lib/datadog/tracing/diagnostics/environment_logger.rb'
ignore 'lib/datadog/tracing/diagnostics/ext.rb'
ignore 'lib/datadog/tracing/diagnostics/health.rb'
ignore 'lib/datadog/tracing/distributed/b3_multi.rb'
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/profiling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def self.allocation_count # rubocop:disable Lint/DuplicateMethods, Lint/NestedMe
require_relative 'profiling/collectors/old_stack'
require_relative 'profiling/collectors/stack'
require_relative 'profiling/collectors/thread_context'
require_relative 'profiling/diagnostics/environment_logger'
require_relative 'profiling/stack_recorder'
require_relative 'profiling/old_recorder'
require_relative 'profiling/exporter'
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/tracing/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def subscribe_to_writer_events!(writer, sampler_delegator, test_mode)
end

WRITER_RECORD_ENVIRONMENT_INFORMATION_CALLBACK = lambda do |_, responses|
Tracing::Diagnostics::EnvironmentLogger.collect_and_log!(responses)
Tracing::Diagnostics::EnvironmentLogger.collect_and_log!(responses: responses)
end

# Create new lambda for writer callback,
Expand Down
66 changes: 29 additions & 37 deletions sig/datadog/core/diagnostics/environment_logger.rbs
Original file line number Diff line number Diff line change
@@ -1,52 +1,44 @@
module Datadog
module Core
module Diagnostics
module EnvironmentLogger
def self.log!: (untyped transport_responses) -> untyped

private
module EnvironmentLogging
def log_configuration!: (untyped prefix, untyped data) -> untyped

def self.log_environment!: (untyped line) -> untyped
def log_error!: (untyped prefix, untyped type, untyped error) -> untyped

def self.log_error!: (untyped `type`, untyped error) -> untyped
def self.log?: () -> untyped
def logger: () -> untyped
def log_once!: () ?{ () -> untyped } -> (false | untyped)
def log?: () -> untyped

REPL_PROGRAM_NAMES: ::Array["irb" | "pry"]

def self.repl?: () -> untyped
def repl?: () -> untyped

def rspec?: () -> untyped
end
class EnvironmentCollector
def date: () -> untyped
def os_name: () -> untyped
def version: () -> untyped
def lang: () -> untyped
def lang_version: () -> untyped
def env: () -> untyped
def enabled: () -> untyped
def service: () -> untyped
def dd_version: () -> untyped
def agent_url: () -> (nil | untyped)
def agent_error: (untyped transport_responses) -> (nil | untyped)
def debug: () -> untyped
def analytics_enabled: () -> untyped
def sample_rate: () -> (nil | untyped)
def sampling_rules: () -> (nil | untyped)
def tags: () -> (nil | untyped)
def runtime_metrics_enabled: () -> untyped
def integrations_loaded: () -> (nil | untyped)
def vm: () -> ::String
def partial_flushing_enabled: () -> untyped
def priority_sampling_enabled: () -> untyped
def health_metrics_enabled: () -> untyped
module EnvironmentLogger
extend EnvironmentLogging

def profiling_enabled: () -> untyped
def collect!: (untyped transport_responses) -> ::Hash[:date | :os_name | :version | :lang | :lang_version | :env | :enabled | :service | :dd_version | :agent_url | :agent_error | :debug | :analytics_enabled | :sample_rate | :sampling_rules | :tags | :runtime_metrics_enabled | :integrations_loaded | :vm | :partial_flushing_enabled | :priority_sampling_enabled | :health_metrics_enabled | :profiling_enabled | untyped, untyped]
def self.collect_and_log!: () -> untyped
end
module EnvironmentCollector
def self.collect_config!: () -> { date: untyped, os_name: untyped, version: untyped, lang: untyped, lang_version: untyped, env: untyped, service: untyped, dd_version: untyped, debug: untyped, tags: untyped, runtime_metrics_enabled: untyped, vm: untyped, health_metrics_enabled: untyped }
def self.date: () -> untyped
def self.os_name: () -> untyped
def self.version: () -> untyped
def self.lang: () -> untyped
def self.lang_version: () -> untyped
def self.env: () -> untyped
def self.service: () -> untyped
def self.dd_version: () -> untyped
def self.debug: () -> untyped
def self.tags: () -> (nil | untyped)
def self.runtime_metrics_enabled: () -> untyped
def self.vm: () -> ::String
def self.health_metrics_enabled: () -> untyped

private

def instrumented_integrations: () -> untyped
def instrumented_integrations_settings: () -> untyped
def hash_serializer: (untyped h) -> untyped
def self.hash_serializer: (untyped h) -> untyped
end
end
end
Expand Down
16 changes: 16 additions & 0 deletions sig/datadog/profiling/diagnostics/environment_logger.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Datadog
module Profiling
module Diagnostics
module EnvironmentLogger
extend Core::Diagnostics::EnvironmentLogging

def self.collect_and_log!: () -> untyped
end
module EnvironmentCollector
def self.collect_config!: (*untyped args) -> { profiling_enabled: untyped }

def self.profiling_enabled: () -> untyped
end
end
end
end
30 changes: 30 additions & 0 deletions sig/datadog/tracing/diagnostics/environment_logger.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Datadog
module Tracing
module Diagnostics
module EnvironmentLogger
extend Core::Diagnostics::EnvironmentLogging

def self.collect_and_log!: (?responses: untyped?) -> untyped
end
module EnvironmentCollector
def self.collect_config!: () -> ::Hash[:enabled | :agent_url | :analytics_enabled | :sample_rate | :sampling_rules | :integrations_loaded | :partial_flushing_enabled | :priority_sampling_enabled | untyped, untyped]

def self.collect_errors!: (untyped responses) -> { agent_error: untyped }
def self.enabled: () -> untyped
def self.agent_url: () -> (nil | untyped)
def self.agent_error: (untyped responses) -> (nil | untyped)
def self.analytics_enabled: () -> untyped
def self.sample_rate: () -> (nil | untyped)
def self.sampling_rules: () -> (nil | untyped)
def self.integrations_loaded: () -> (nil | untyped)
def self.partial_flushing_enabled: () -> untyped
def self.priority_sampling_enabled: () -> untyped

private

def self.instrumented_integrations: () -> untyped
def self.instrumented_integrations_settings: () -> untyped
end
end
end
end
13 changes: 2 additions & 11 deletions spec/datadog/core/configuration/components_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
require 'datadog/tracing/writer'
require 'ddtrace/transport/http/adapters/net'

# TODO: Components contains behavior for all of the different products.
# Test behavior needs to be extracted to complimentary component files for every product.
RSpec.describe Datadog::Core::Configuration::Components do
subject(:components) { described_class.new(settings) }

Expand Down Expand Up @@ -943,17 +945,6 @@
end

describe 'writer event callbacks' do
# describe Datadog::Core::Configuration::Components.singleton_class::WRITER_RECORD_ENVIRONMENT_INFORMATION_CALLBACK do
# subject(:call) { described_class.call(writer, responses) }
# let(:writer) { double('writer') }
# let(:responses) { [double('response')] }

# it 'invokes the environment logger with responses' do
# expect(Datadog::Core::Diagnostics::EnvironmentLogger).to receive(:collect_and_log!).with(responses)
# call
# end
# end

describe '.writer_update_priority_sampler_rates_callback' do
subject(:call) do
described_class.writer_update_priority_sampler_rates_callback(sampler).call(writer, responses)
Expand Down
15 changes: 15 additions & 0 deletions spec/datadog/tracing/component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

require 'rspec'

RSpec.describe Datadog::Tracing::Component do
describe 'writer event callbacks' do
describe Datadog::Tracing::Component::WRITER_RECORD_ENVIRONMENT_INFORMATION_CALLBACK do
subject(:call) { described_class.call(writer, responses) }
let(:writer) { double('writer') }
let(:responses) { [double('response')] }

it 'invokes the environment logger with responses' do
expect(Datadog::Tracing::Diagnostics::EnvironmentLogger).to receive(:collect_and_log!).with(responses: responses)
call
end
end
end
end

RSpec.describe Datadog::Tracing::Component::SamplerDelegatorComponent do
let(:delegator) { described_class.new(old_sampler) }
let(:old_sampler) { double('initial') }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
end
end

after { Datadog.configure { proc { |c| c.tracing.transport_options = {} } } }
after { Datadog.configure { |c| c.tracing.transport_options = nil } }

it { is_expected.to include agent_url: include('unix') }
it { is_expected.to include agent_url: include('/tmp/trace.sock') }
Expand Down

0 comments on commit b61584c

Please sign in to comment.