Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add event_sample_rate configuration option #665

Merged
merged 2 commits into from
Jan 3, 2019
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
1 change: 1 addition & 0 deletions lib/ddtrace/contrib/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Settings

option :service_name
option :tracer, default: Datadog.tracer
option :event_sample_rate

def initialize(options = {})
configure(options)
Expand Down
2 changes: 2 additions & 0 deletions lib/ddtrace/ext/priority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module Ext
# Priority is a hint given to the backend so that it knows which traces to reject or kept.
# In a distributed context, it should be set before any context propagation (fork, RPC calls) to be effective.
module Priority
# Tag for span sample rate; used by agent to determine whether event is emitted.
TAG_EVENT_SAMPLE_RATE = '_dd1.sr.eausr'.freeze
# Use this to explicitely inform the backend that a trace should be rejected and not stored.
USER_REJECT = -1
# Used by the builtin sampler to inform the backend that a trace should be rejected and not stored.
Expand Down
20 changes: 18 additions & 2 deletions spec/ddtrace/contrib/configuration/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,23 @@

describe '#options' do
subject(:options) { settings.options }
it { is_expected.to include(:service_name) }
it { is_expected.to include(:tracer) }

describe ':service_name' do
subject(:option) { options[:service_name] }
it { expect(options).to include(:service_name) }
it { expect(option.get).to be nil }
end

describe ':tracer' do
subject(:option) { options[:tracer] }
it { expect(options).to include(:tracer) }
it { expect(option.get).to be Datadog.tracer }
end

describe ':event_sample_rate' do
subject(:option) { options[:event_sample_rate] }
it { expect(options).to include(:event_sample_rate) }
it { expect(option.get).to be nil }
end
end
end