Skip to content

Commit

Permalink
Added: analytics_enabled as option to Datadog::Configuration::Settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
delner committed Mar 14, 2019
1 parent c741381 commit 4907261
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions lib/ddtrace/configuration/settings.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'ddtrace/ext/analytics'
require 'ddtrace/environment'
require 'ddtrace/configuration/options'

Expand All @@ -8,6 +9,10 @@ class Settings
extend Datadog::Environment::Helpers
include Options

option :analytics_enabled,
default: -> { env_to_bool(Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED, nil) },
lazy: true

option :tracer, default: Tracer.new

def initialize(options = {})
Expand Down
1 change: 1 addition & 0 deletions lib/ddtrace/ext/analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module Datadog
module Ext
# Defines constants for trace analytics
module Analytics
ENV_TRACE_ANALYTICS_ENABLED = 'DD_TRACE_ANALYTICS_ENABLED'.freeze
# Tag for sample rate; used by agent to determine whether analytics event is emitted.
TAG_SAMPLE_RATE = '_dd1.sr.eausr'.freeze
end
Expand Down
12 changes: 6 additions & 6 deletions spec/ddtrace/contrib/analytics_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

context 'and the global flag is enabled' do
around do |example|
ClimateControl.modify(Datadog::Configuration::ENV_TRACE_ANALYTICS_ENABLED => 'true') do
ClimateControl.modify(Datadog::Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED => 'true') do
example.run
end
end
Expand All @@ -31,7 +31,7 @@

context 'and the global flag is disabled' do
around do |example|
ClimateControl.modify(Datadog::Configuration::ENV_TRACE_ANALYTICS_ENABLED => 'false') do
ClimateControl.modify(Datadog::Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED => 'false') do
example.run
end
end
Expand Down Expand Up @@ -74,7 +74,7 @@

context 'is explicitly enabled' do
around do |example|
ClimateControl.modify(Datadog::Configuration::ENV_TRACE_ANALYTICS_ENABLED => 'true') do
ClimateControl.modify(Datadog::Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED => 'true') do
example.run
end
end
Expand All @@ -84,7 +84,7 @@

context 'is explicitly disabled' do
around do |example|
ClimateControl.modify(Datadog::Configuration::ENV_TRACE_ANALYTICS_ENABLED => 'false') do
ClimateControl.modify(Datadog::Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED => 'false') do
example.run
end
end
Expand Down Expand Up @@ -125,7 +125,7 @@

context 'is explicitly enabled' do
around do |example|
ClimateControl.modify(Datadog::Configuration::ENV_TRACE_ANALYTICS_ENABLED => 'true') do
ClimateControl.modify(Datadog::Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED => 'true') do
example.run
end
end
Expand All @@ -135,7 +135,7 @@

context 'is explicitly disabled' do
around do |example|
ClimateControl.modify(Datadog::Configuration::ENV_TRACE_ANALYTICS_ENABLED => 'false') do
ClimateControl.modify(Datadog::Ext::Analytics::ENV_TRACE_ANALYTICS_ENABLED => 'false') do
example.run
end
end
Expand Down

0 comments on commit 4907261

Please sign in to comment.