ddtrace 0.45.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +79 -0
- data/.rubocop.yml +250 -7
- data/.rubocop_todo.yml +396 -0
- data/Appraisals +15 -0
- data/CHANGELOG.md +68 -1
- data/Gemfile +38 -3
- data/Rakefile +5 -23
- data/ddtrace.gemspec +6 -36
- data/docs/DevelopmentGuide.md +28 -0
- data/docs/GettingStarted.md +8 -9
- data/integration/README.md +68 -0
- data/integration/apps/rack/.dockerignore +1 -0
- data/integration/apps/rack/.envrc.sample +1 -0
- data/integration/apps/rack/.gitignore +4 -0
- data/integration/apps/rack/.rspec +1 -0
- data/integration/apps/rack/Dockerfile +25 -0
- data/integration/apps/rack/Dockerfile-ci +11 -0
- data/integration/apps/rack/Gemfile +24 -0
- data/integration/apps/rack/README.md +93 -0
- data/integration/apps/rack/app/acme.rb +80 -0
- data/integration/apps/rack/app/datadog.rb +17 -0
- data/integration/apps/rack/bin/run +22 -0
- data/integration/apps/rack/bin/setup +17 -0
- data/integration/apps/rack/bin/test +24 -0
- data/integration/apps/rack/config.ru +6 -0
- data/integration/apps/rack/config/puma.rb +14 -0
- data/integration/apps/rack/config/unicorn.rb +23 -0
- data/integration/apps/rack/docker-compose.ci.yml +62 -0
- data/integration/apps/rack/docker-compose.yml +78 -0
- data/integration/apps/rack/script/build-images +38 -0
- data/integration/apps/rack/script/ci +50 -0
- data/integration/apps/rack/spec/integration/basic_spec.rb +10 -0
- data/integration/apps/rack/spec/spec_helper.rb +16 -0
- data/integration/apps/rack/spec/support/integration_helper.rb +22 -0
- data/integration/apps/rails-five/.dockerignore +1 -0
- data/integration/apps/rails-five/.env +3 -0
- data/integration/apps/rails-five/.envrc.sample +1 -0
- data/integration/apps/rails-five/.gitignore +30 -0
- data/integration/apps/rails-five/Dockerfile +25 -0
- data/integration/apps/rails-five/Dockerfile-ci +11 -0
- data/integration/apps/rails-five/Gemfile +104 -0
- data/integration/apps/rails-five/README.md +94 -0
- data/integration/apps/rails-five/Rakefile +6 -0
- data/integration/apps/rails-five/app/channels/application_cable/channel.rb +4 -0
- data/integration/apps/rails-five/app/channels/application_cable/connection.rb +4 -0
- data/integration/apps/rails-five/app/controllers/application_controller.rb +2 -0
- data/integration/apps/rails-five/app/controllers/basic_controller.rb +36 -0
- data/integration/apps/rails-five/app/controllers/concerns/.keep +0 -0
- data/integration/apps/rails-five/app/controllers/health_controller.rb +9 -0
- data/integration/apps/rails-five/app/controllers/jobs_controller.rb +12 -0
- data/integration/apps/rails-five/app/jobs/application_job.rb +2 -0
- data/integration/apps/rails-five/app/jobs/test_job.rb +12 -0
- data/integration/apps/rails-five/app/mailers/application_mailer.rb +4 -0
- data/integration/apps/rails-five/app/models/application_record.rb +3 -0
- data/integration/apps/rails-five/app/models/concerns/.keep +0 -0
- data/integration/apps/rails-five/app/models/test.rb +2 -0
- data/integration/apps/rails-five/app/views/layouts/mailer.html.erb +13 -0
- data/integration/apps/rails-five/app/views/layouts/mailer.text.erb +1 -0
- data/integration/apps/rails-five/bin/bundle +3 -0
- data/integration/apps/rails-five/bin/rails +9 -0
- data/integration/apps/rails-five/bin/rake +9 -0
- data/integration/apps/rails-five/bin/run +24 -0
- data/integration/apps/rails-five/bin/setup +27 -0
- data/integration/apps/rails-five/bin/spring +17 -0
- data/integration/apps/rails-five/bin/test +21 -0
- data/integration/apps/rails-five/bin/update +28 -0
- data/integration/apps/rails-five/config.ru +5 -0
- data/integration/apps/rails-five/config/application.rb +97 -0
- data/integration/apps/rails-five/config/boot.rb +4 -0
- data/integration/apps/rails-five/config/cable.yml +10 -0
- data/integration/apps/rails-five/config/credentials.yml.enc +1 -0
- data/integration/apps/rails-five/config/database.yml +28 -0
- data/integration/apps/rails-five/config/environment.rb +5 -0
- data/integration/apps/rails-five/config/environments/development.rb +51 -0
- data/integration/apps/rails-five/config/environments/production.rb +82 -0
- data/integration/apps/rails-five/config/environments/test.rb +43 -0
- data/integration/apps/rails-five/config/initializers/datadog.rb +18 -0
- data/integration/apps/rails-five/config/initializers/filter_parameter_logging.rb +4 -0
- data/integration/apps/rails-five/config/initializers/resque.rb +4 -0
- data/integration/apps/rails-five/config/initializers/rollbar.rb +5 -0
- data/integration/apps/rails-five/config/initializers/wrap_parameters.rb +14 -0
- data/integration/apps/rails-five/config/locales/en.yml +33 -0
- data/integration/apps/rails-five/config/puma.rb +24 -0
- data/integration/apps/rails-five/config/routes.rb +11 -0
- data/integration/apps/rails-five/config/spring.rb +6 -0
- data/integration/apps/rails-five/config/unicorn.rb +29 -0
- data/integration/apps/rails-five/db/migrate/20190927215052_create_tests.rb +11 -0
- data/integration/apps/rails-five/db/schema.rb +23 -0
- data/integration/apps/rails-five/db/seeds.rb +7 -0
- data/integration/apps/rails-five/docker-compose.ci.yml +98 -0
- data/integration/apps/rails-five/docker-compose.yml +100 -0
- data/integration/apps/rails-five/lib/tasks/.keep +0 -0
- data/integration/apps/rails-five/log/.keep +0 -0
- data/integration/apps/rails-five/public/robots.txt +1 -0
- data/integration/apps/rails-five/script/build-images +35 -0
- data/integration/apps/rails-five/script/ci +50 -0
- data/integration/apps/rails-five/spec/integration/basic_spec.rb +10 -0
- data/integration/apps/rails-five/spec/spec_helper.rb +16 -0
- data/integration/apps/rails-five/spec/support/integration_helper.rb +22 -0
- data/integration/apps/rails-five/storage/.keep +0 -0
- data/integration/apps/rails-five/tmp/.keep +0 -0
- data/integration/apps/rails-five/vendor/.keep +0 -0
- data/integration/apps/ruby/.dockerignore +1 -0
- data/integration/apps/ruby/.envrc.sample +1 -0
- data/integration/apps/ruby/.gitignore +2 -0
- data/integration/apps/ruby/Dockerfile +25 -0
- data/integration/apps/ruby/Dockerfile-ci +11 -0
- data/integration/apps/ruby/Gemfile +11 -0
- data/integration/apps/ruby/README.md +70 -0
- data/integration/apps/ruby/agent.yaml +3 -0
- data/integration/apps/ruby/app/datadog.rb +13 -0
- data/integration/apps/ruby/app/fibonacci.rb +58 -0
- data/integration/apps/ruby/bin/run +20 -0
- data/integration/apps/ruby/bin/setup +17 -0
- data/integration/apps/ruby/bin/test +21 -0
- data/integration/apps/ruby/docker-compose.ci.yml +51 -0
- data/integration/apps/ruby/docker-compose.yml +63 -0
- data/integration/apps/ruby/script/build-images +38 -0
- data/integration/apps/ruby/script/ci +50 -0
- data/integration/images/agent/Dockerfile +2 -0
- data/integration/images/agent/agent.yaml +3 -0
- data/integration/images/include/datadog/analyzer.rb +71 -0
- data/integration/images/include/datadog/demo_env.rb +101 -0
- data/integration/images/include/http-health-check +33 -0
- data/integration/images/ruby/2.0/Dockerfile +54 -0
- data/integration/images/ruby/2.1/Dockerfile +54 -0
- data/integration/images/ruby/2.2/Dockerfile +54 -0
- data/integration/images/ruby/2.3/Dockerfile +70 -0
- data/integration/images/ruby/2.4/Dockerfile +54 -0
- data/integration/images/ruby/2.5/Dockerfile +54 -0
- data/integration/images/ruby/2.6/Dockerfile +54 -0
- data/integration/images/ruby/2.7/Dockerfile +54 -0
- data/integration/images/ruby/3.0/Dockerfile +54 -0
- data/integration/images/wrk/Dockerfile +33 -0
- data/integration/images/wrk/scripts/entrypoint.sh +17 -0
- data/integration/images/wrk/scripts/scenarios/basic/default.lua +1 -0
- data/integration/images/wrk/scripts/scenarios/basic/fibonacci.lua +1 -0
- data/integration/script/build-images +43 -0
- data/lib/ddtrace.rb +0 -5
- data/lib/ddtrace/analytics.rb +2 -0
- data/lib/ddtrace/buffer.rb +4 -4
- data/lib/ddtrace/configuration.rb +1 -1
- data/lib/ddtrace/configuration/base.rb +1 -1
- data/lib/ddtrace/configuration/components.rb +2 -2
- data/lib/ddtrace/configuration/option_definition.rb +1 -3
- data/lib/ddtrace/configuration/options.rb +2 -3
- data/lib/ddtrace/configuration/settings.rb +17 -3
- data/lib/ddtrace/context.rb +5 -6
- data/lib/ddtrace/context_provider.rb +1 -0
- data/lib/ddtrace/contrib/action_cable/event.rb +1 -0
- data/lib/ddtrace/contrib/action_pack/action_controller/instrumentation.rb +1 -3
- data/lib/ddtrace/contrib/action_view/event.rb +1 -1
- data/lib/ddtrace/contrib/action_view/utils.rb +1 -1
- data/lib/ddtrace/contrib/active_record/configuration/resolver.rb +17 -5
- data/lib/ddtrace/contrib/active_record/utils.rb +1 -0
- data/lib/ddtrace/contrib/active_support/notifications/event.rb +2 -1
- data/lib/ddtrace/contrib/active_support/notifications/subscriber.rb +1 -0
- data/lib/ddtrace/contrib/active_support/notifications/subscription.rb +9 -5
- data/lib/ddtrace/contrib/auto_instrument.rb +1 -0
- data/lib/ddtrace/contrib/aws/patcher.rb +1 -0
- data/lib/ddtrace/contrib/aws/services.rb +1 -0
- data/lib/ddtrace/contrib/configuration/resolvers/pattern_resolver.rb +1 -4
- data/lib/ddtrace/contrib/cucumber/configuration/settings.rb +0 -10
- data/lib/ddtrace/contrib/cucumber/ext.rb +0 -2
- data/lib/ddtrace/contrib/cucumber/formatter.rb +5 -11
- data/lib/ddtrace/contrib/dalli/patcher.rb +0 -38
- data/lib/ddtrace/contrib/delayed_job/plugin.rb +0 -1
- data/lib/ddtrace/contrib/elasticsearch/quantize.rb +3 -2
- data/lib/ddtrace/contrib/ethon/easy_patch.rb +5 -5
- data/lib/ddtrace/contrib/excon/middleware.rb +2 -6
- data/lib/ddtrace/contrib/extensions.rb +1 -0
- data/lib/ddtrace/contrib/faraday/middleware.rb +1 -3
- data/lib/ddtrace/contrib/faraday/patcher.rb +0 -36
- data/lib/ddtrace/contrib/grape/endpoint.rb +8 -15
- data/lib/ddtrace/contrib/grape/patcher.rb +0 -42
- data/lib/ddtrace/contrib/grpc/datadog_interceptor.rb +8 -8
- data/lib/ddtrace/contrib/grpc/datadog_interceptor/server.rb +1 -0
- data/lib/ddtrace/contrib/grpc/patcher.rb +0 -36
- data/lib/ddtrace/contrib/http/circuit_breaker.rb +1 -3
- data/lib/ddtrace/contrib/http/instrumentation.rb +5 -5
- data/lib/ddtrace/contrib/httpclient/instrumentation.rb +2 -3
- data/lib/ddtrace/contrib/httprb/instrumentation.rb +2 -3
- data/lib/ddtrace/contrib/mongodb/instrumentation.rb +2 -0
- data/lib/ddtrace/contrib/mongodb/subscribers.rb +2 -3
- data/lib/ddtrace/contrib/patcher.rb +1 -1
- data/lib/ddtrace/contrib/qless/qless_job.rb +1 -0
- data/lib/ddtrace/contrib/qless/tracer_cleaner.rb +1 -0
- data/lib/ddtrace/contrib/que/ext.rb +19 -19
- data/lib/ddtrace/contrib/que/tracer.rb +1 -1
- data/lib/ddtrace/contrib/racecar/event.rb +1 -0
- data/lib/ddtrace/contrib/rack/configuration/settings.rb +3 -3
- data/lib/ddtrace/contrib/rack/middlewares.rb +5 -10
- data/lib/ddtrace/contrib/rack/patcher.rb +1 -3
- data/lib/ddtrace/contrib/rake/instrumentation.rb +4 -2
- data/lib/ddtrace/contrib/redis/quantize.rb +1 -0
- data/lib/ddtrace/contrib/redis/vendor/LICENSE +20 -0
- data/lib/ddtrace/contrib/redis/vendor/resolver.rb +6 -7
- data/lib/ddtrace/contrib/registry.rb +2 -2
- data/lib/ddtrace/contrib/resque/resque_job.rb +2 -0
- data/lib/ddtrace/contrib/rest_client/request_patch.rb +1 -3
- data/lib/ddtrace/contrib/rspec/configuration/settings.rb +0 -10
- data/lib/ddtrace/contrib/rspec/example.rb +24 -10
- data/lib/ddtrace/contrib/rspec/ext.rb +0 -3
- data/lib/ddtrace/contrib/rspec/integration.rb +1 -1
- data/lib/ddtrace/contrib/rspec/patcher.rb +0 -2
- data/lib/ddtrace/contrib/sequel/utils.rb +5 -6
- data/lib/ddtrace/contrib/shoryuken/tracer.rb +0 -1
- data/lib/ddtrace/contrib/sidekiq/server_tracer.rb +2 -7
- data/lib/ddtrace/contrib/sidekiq/tracing.rb +0 -1
- data/lib/ddtrace/contrib/sinatra/env.rb +1 -3
- data/lib/ddtrace/contrib/sinatra/headers.rb +1 -3
- data/lib/ddtrace/contrib/sinatra/tracer.rb +1 -3
- data/lib/ddtrace/contrib/sinatra/tracer_middleware.rb +3 -3
- data/lib/ddtrace/contrib/sneakers/ext.rb +11 -11
- data/lib/ddtrace/contrib/sneakers/tracer.rb +2 -4
- data/lib/ddtrace/contrib/status_code_matcher.rb +5 -3
- data/lib/ddtrace/correlation.rb +1 -0
- data/lib/ddtrace/diagnostics/environment_logger.rb +2 -1
- data/lib/ddtrace/distributed_tracing/headers/headers.rb +1 -0
- data/lib/ddtrace/distributed_tracing/headers/helpers.rb +1 -3
- data/lib/ddtrace/ext/ci.rb +2 -2
- data/lib/ddtrace/ext/distributed.rb +1 -1
- data/lib/ddtrace/ext/http.rb +1 -1
- data/lib/ddtrace/ext/runtime.rb +1 -1
- data/lib/ddtrace/forced_tracing.rb +2 -0
- data/lib/ddtrace/logger.rb +1 -1
- data/lib/ddtrace/metrics.rb +10 -6
- data/lib/ddtrace/opentracer/distributed_headers.rb +3 -0
- data/lib/ddtrace/opentracer/span.rb +2 -6
- data/lib/ddtrace/opentracer/thread_local_scope.rb +1 -0
- data/lib/ddtrace/patcher.rb +2 -3
- data/lib/ddtrace/pin.rb +3 -52
- data/lib/ddtrace/pipeline/span_filter.rb +1 -1
- data/lib/ddtrace/propagation/grpc_propagator.rb +1 -0
- data/lib/ddtrace/quantization/http.rb +1 -0
- data/lib/ddtrace/runtime/cgroup.rb +1 -1
- data/lib/ddtrace/runtime/container.rb +2 -2
- data/lib/ddtrace/sampler.rb +1 -1
- data/lib/ddtrace/sampling/rule_sampler.rb +1 -0
- data/lib/ddtrace/span.rb +7 -7
- data/lib/ddtrace/sync_writer.rb +7 -10
- data/lib/ddtrace/tracer.rb +1 -1
- data/lib/ddtrace/transport/http.rb +1 -3
- data/lib/ddtrace/transport/http/adapters/net.rb +9 -4
- data/lib/ddtrace/transport/http/adapters/registry.rb +1 -0
- data/lib/ddtrace/transport/http/adapters/unix_socket.rb +2 -4
- data/lib/ddtrace/transport/http/builder.rb +2 -0
- data/lib/ddtrace/transport/http/traces.rb +2 -3
- data/lib/ddtrace/transport/io.rb +1 -1
- data/lib/ddtrace/transport/traces.rb +3 -0
- data/lib/ddtrace/utils/time.rb +25 -1
- data/lib/ddtrace/vendor/active_record/MIT-LICENSE +20 -0
- data/lib/ddtrace/version.rb +1 -1
- data/lib/ddtrace/workers.rb +5 -0
- data/lib/ddtrace/workers/async.rb +8 -0
- data/lib/ddtrace/workers/loop.rb +3 -0
- data/lib/ddtrace/workers/polling.rb +1 -0
- data/lib/ddtrace/workers/trace_writer.rb +9 -10
- data/lib/ddtrace/writer.rb +3 -3
- metadata +133 -400
- data/lib/ddtrace/augmentation.rb +0 -13
- data/lib/ddtrace/augmentation/method_wrapper.rb +0 -20
- data/lib/ddtrace/augmentation/method_wrapping.rb +0 -38
- data/lib/ddtrace/augmentation/shim.rb +0 -102
- data/lib/ddtrace/contrib/rspec/example_group.rb +0 -61
- data/lib/ddtrace/monkey.rb +0 -58
|
@@ -7,13 +7,13 @@ module Datadog
|
|
|
7
7
|
# A holistic collection of the environment in which ddtrace is running.
|
|
8
8
|
# This logger should allow for easy reporting by users to Datadog support.
|
|
9
9
|
#
|
|
10
|
-
# rubocop:disable Style/DoubleNegation
|
|
11
10
|
module EnvironmentLogger
|
|
12
11
|
class << self
|
|
13
12
|
# Outputs environment information to {Datadog.logger}.
|
|
14
13
|
# Executes only for the lifetime of the program.
|
|
15
14
|
def log!(transport_responses)
|
|
16
15
|
return if @executed || !log?
|
|
16
|
+
|
|
17
17
|
@executed = true
|
|
18
18
|
|
|
19
19
|
data = EnvironmentCollector.new.collect!(transport_responses)
|
|
@@ -165,6 +165,7 @@ module Datadog
|
|
|
165
165
|
def tags
|
|
166
166
|
tags = Datadog.configuration.tags
|
|
167
167
|
return nil if tags.empty?
|
|
168
|
+
|
|
168
169
|
hash_serializer(tags)
|
|
169
170
|
end
|
|
170
171
|
|
|
@@ -35,9 +35,7 @@ module Datadog
|
|
|
35
35
|
# for us so we want to make sure the comparision will work as expected
|
|
36
36
|
# DEV: regex, remove all leading zeros up until we find the last 0 in the string
|
|
37
37
|
# or we find the first non-zero, this allows `'0000' -> '0'` and `'00001' -> '1'`
|
|
38
|
-
value
|
|
39
|
-
|
|
40
|
-
value
|
|
38
|
+
value.sub(/^0*(?=(0$)|[^0])/, '')
|
|
41
39
|
end
|
|
42
40
|
end
|
|
43
41
|
end
|
data/lib/ddtrace/ext/ci.rb
CHANGED
|
@@ -75,7 +75,7 @@ module Datadog
|
|
|
75
75
|
|
|
76
76
|
{
|
|
77
77
|
TAG_PROVIDER_NAME => 'appveyor',
|
|
78
|
-
Git::TAG_REPOSITORY_URL =>
|
|
78
|
+
Git::TAG_REPOSITORY_URL => repository,
|
|
79
79
|
Git::TAG_COMMIT_SHA => commit,
|
|
80
80
|
TAG_WORKSPACE_PATH => env['APPVEYOR_BUILD_FOLDER'],
|
|
81
81
|
TAG_PIPELINE_ID => env['APPVEYOR_BUILD_ID'],
|
|
@@ -260,7 +260,7 @@ module Datadog
|
|
|
260
260
|
{
|
|
261
261
|
Git::TAG_BRANCH => (env['TRAVIS_PULL_REQUEST_BRANCH'] || env['TRAVIS_BRANCH']),
|
|
262
262
|
Git::TAG_COMMIT_SHA => env['TRAVIS_COMMIT'],
|
|
263
|
-
Git::TAG_REPOSITORY_URL =>
|
|
263
|
+
Git::TAG_REPOSITORY_URL => "https://github.com/#{env['TRAVIS_REPO_SLUG']}.git",
|
|
264
264
|
Git::TAG_TAG => env['TRAVIS_TAG'],
|
|
265
265
|
TAG_JOB_URL => env['TRAVIS_JOB_WEB_URL'],
|
|
266
266
|
TAG_PIPELINE_ID => env['TRAVIS_BUILD_ID'],
|
|
@@ -22,7 +22,7 @@ module Datadog
|
|
|
22
22
|
PROPAGATION_STYLE_B3_SINGLE_HEADER = 'B3 single header'.freeze
|
|
23
23
|
PROPAGATION_STYLE_INJECT_ENV = 'DD_PROPAGATION_STYLE_INJECT'.freeze
|
|
24
24
|
PROPAGATION_STYLE_EXTRACT_ENV = 'DD_PROPAGATION_STYLE_EXTRACT'.freeze
|
|
25
|
-
#
|
|
25
|
+
# NOTE: the below inject/extract values are deprecated and were defined erronously
|
|
26
26
|
# they were never part of the datadog language client standard or documentation
|
|
27
27
|
# some users may already be relying on them, but we should look to remove these in the future
|
|
28
28
|
# or before 1.0.
|
data/lib/ddtrace/ext/http.rb
CHANGED
data/lib/ddtrace/ext/runtime.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Datadog
|
|
|
5
5
|
module Runtime
|
|
6
6
|
# Identity
|
|
7
7
|
LANG = 'ruby'.freeze
|
|
8
|
-
LANG_INTERPRETER =
|
|
8
|
+
LANG_INTERPRETER = "#{RUBY_ENGINE}-#{RUBY_PLATFORM}".freeze
|
|
9
9
|
LANG_VERSION = RUBY_VERSION
|
|
10
10
|
RUBY_ENGINE = ::RUBY_ENGINE # e.g. 'ruby', 'jruby', 'truffleruby'
|
|
11
11
|
TRACER_VERSION = Datadog::VERSION::STRING
|
|
@@ -7,11 +7,13 @@ module Datadog
|
|
|
7
7
|
class << self
|
|
8
8
|
def keep(span)
|
|
9
9
|
return if span.nil? || span.context.nil?
|
|
10
|
+
|
|
10
11
|
span.context.sampling_priority = Datadog::Ext::Priority::USER_KEEP
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def drop(span)
|
|
14
15
|
return if span.nil? || span.context.nil?
|
|
16
|
+
|
|
15
17
|
span.context.sampling_priority = Datadog::Ext::Priority::USER_REJECT
|
|
16
18
|
end
|
|
17
19
|
end
|
data/lib/ddtrace/logger.rb
CHANGED
data/lib/ddtrace/metrics.rb
CHANGED
|
@@ -41,7 +41,7 @@ module Datadog
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def default_statsd_client
|
|
44
|
-
require 'datadog/statsd'
|
|
44
|
+
require 'datadog/statsd'
|
|
45
45
|
|
|
46
46
|
# Create a StatsD client that points to the agent.
|
|
47
47
|
Datadog::Statsd.new(default_hostname, default_port)
|
|
@@ -58,7 +58,8 @@ module Datadog
|
|
|
58
58
|
|
|
59
59
|
def count(stat, value = nil, options = nil, &block)
|
|
60
60
|
return unless send_stats? && statsd.respond_to?(:count)
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
value, options = yield if block
|
|
62
63
|
raise ArgumentError if value.nil?
|
|
63
64
|
|
|
64
65
|
statsd.count(stat, value, metric_options(options))
|
|
@@ -68,7 +69,8 @@ module Datadog
|
|
|
68
69
|
|
|
69
70
|
def distribution(stat, value = nil, options = nil, &block)
|
|
70
71
|
return unless send_stats? && statsd.respond_to?(:distribution)
|
|
71
|
-
|
|
72
|
+
|
|
73
|
+
value, options = yield if block
|
|
72
74
|
raise ArgumentError if value.nil?
|
|
73
75
|
|
|
74
76
|
statsd.distribution(stat, value, metric_options(options))
|
|
@@ -78,6 +80,7 @@ module Datadog
|
|
|
78
80
|
|
|
79
81
|
def increment(stat, options = nil)
|
|
80
82
|
return unless send_stats? && statsd.respond_to?(:increment)
|
|
83
|
+
|
|
81
84
|
options = yield if block_given?
|
|
82
85
|
|
|
83
86
|
statsd.increment(stat, metric_options(options))
|
|
@@ -87,7 +90,8 @@ module Datadog
|
|
|
87
90
|
|
|
88
91
|
def gauge(stat, value = nil, options = nil, &block)
|
|
89
92
|
return unless send_stats? && statsd.respond_to?(:gauge)
|
|
90
|
-
|
|
93
|
+
|
|
94
|
+
value, options = yield if block
|
|
91
95
|
raise ArgumentError if value.nil?
|
|
92
96
|
|
|
93
97
|
statsd.gauge(stat, value, metric_options(options))
|
|
@@ -100,7 +104,7 @@ module Datadog
|
|
|
100
104
|
|
|
101
105
|
# Calculate time, send it as a distribution.
|
|
102
106
|
start = Utils::Time.get_time
|
|
103
|
-
|
|
107
|
+
yield
|
|
104
108
|
ensure
|
|
105
109
|
begin
|
|
106
110
|
if send_stats? && !start.nil?
|
|
@@ -186,7 +190,7 @@ module Datadog
|
|
|
186
190
|
attr_accessor :logger
|
|
187
191
|
|
|
188
192
|
def initialize(logger = nil)
|
|
189
|
-
@logger = logger || Logger.new(
|
|
193
|
+
@logger = logger || Logger.new($stdout).tap do |l|
|
|
190
194
|
l.level = Logger::INFO
|
|
191
195
|
l.progname = nil
|
|
192
196
|
l.formatter = proc do |_severity, datetime, _progname, msg|
|
|
@@ -29,8 +29,10 @@ module Datadog
|
|
|
29
29
|
# It's important to make a difference between no header,
|
|
30
30
|
# and a header defined to zero.
|
|
31
31
|
return unless hdr
|
|
32
|
+
|
|
32
33
|
value = hdr.to_i
|
|
33
34
|
return if value < 0
|
|
35
|
+
|
|
34
36
|
value
|
|
35
37
|
end
|
|
36
38
|
|
|
@@ -45,6 +47,7 @@ module Datadog
|
|
|
45
47
|
def id(header)
|
|
46
48
|
value = @carrier[header].to_i
|
|
47
49
|
return if value.zero? || value >= Datadog::Span::EXTERNAL_MAX_ID
|
|
50
|
+
|
|
48
51
|
value < 0 ? value + 0x1_0000_0000_0000_0000 : value
|
|
49
52
|
end
|
|
50
53
|
end
|
|
@@ -73,9 +73,7 @@ module Datadog
|
|
|
73
73
|
super # Log deprecation warning
|
|
74
74
|
|
|
75
75
|
# If the fields specify an error
|
|
76
|
-
if fields.key?(:'error.object')
|
|
77
|
-
datadog_span.set_error(fields[:'error.object'])
|
|
78
|
-
end
|
|
76
|
+
datadog_span.set_error(fields[:'error.object']) if fields.key?(:'error.object')
|
|
79
77
|
end
|
|
80
78
|
|
|
81
79
|
# Add a log entry to this span
|
|
@@ -83,9 +81,7 @@ module Datadog
|
|
|
83
81
|
# @param fields [Hash] Additional information to log
|
|
84
82
|
def log_kv(timestamp: Time.now, **fields)
|
|
85
83
|
# If the fields specify an error
|
|
86
|
-
if fields.key?(:'error.object')
|
|
87
|
-
datadog_span.set_error(fields[:'error.object'])
|
|
88
|
-
end
|
|
84
|
+
datadog_span.set_error(fields[:'error.object']) if fields.key?(:'error.object')
|
|
89
85
|
end
|
|
90
86
|
|
|
91
87
|
# Finish the {Span}
|
data/lib/ddtrace/patcher.rb
CHANGED
|
@@ -24,9 +24,7 @@ module Datadog
|
|
|
24
24
|
def do_once(key = nil, options = {})
|
|
25
25
|
# If already done, don't do again
|
|
26
26
|
@done_once ||= Hash.new { |h, k| h[k] = {} }
|
|
27
|
-
if @done_once.key?(key) && @done_once[key].key?(options[:for])
|
|
28
|
-
return @done_once[key][options[:for]]
|
|
29
|
-
end
|
|
27
|
+
return @done_once[key][options[:for]] if @done_once.key?(key) && @done_once[key].key?(options[:for])
|
|
30
28
|
|
|
31
29
|
# Otherwise 'do'
|
|
32
30
|
yield.tap do
|
|
@@ -37,6 +35,7 @@ module Datadog
|
|
|
37
35
|
|
|
38
36
|
def done?(key, options = {})
|
|
39
37
|
return false unless instance_variable_defined?(:@done_once)
|
|
38
|
+
|
|
40
39
|
!@done_once.nil? && @done_once.key?(key) && @done_once[key].key?(options[:for])
|
|
41
40
|
end
|
|
42
41
|
end
|
data/lib/ddtrace/pin.rb
CHANGED
|
@@ -9,17 +9,11 @@ module Datadog
|
|
|
9
9
|
class Pin
|
|
10
10
|
def self.get_from(obj)
|
|
11
11
|
return nil unless obj.respond_to? :datadog_pin
|
|
12
|
+
|
|
12
13
|
obj.datadog_pin
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
attr_accessor :app
|
|
16
|
-
attr_accessor :app_type
|
|
17
|
-
attr_accessor :config
|
|
18
|
-
attr_accessor :name
|
|
19
|
-
attr_accessor :service_name
|
|
20
|
-
attr_accessor :tags
|
|
21
|
-
attr_reader :tracer
|
|
22
|
-
attr_accessor :writer
|
|
16
|
+
attr_accessor :app, :app_type, :config, :name, :service_name, :tags, :writer
|
|
23
17
|
|
|
24
18
|
alias service= service_name=
|
|
25
19
|
alias service service_name
|
|
@@ -42,6 +36,7 @@ module Datadog
|
|
|
42
36
|
|
|
43
37
|
def enabled?
|
|
44
38
|
return tracer.enabled if tracer
|
|
39
|
+
|
|
45
40
|
false
|
|
46
41
|
end
|
|
47
42
|
|
|
@@ -91,48 +86,4 @@ module Datadog
|
|
|
91
86
|
end
|
|
92
87
|
end
|
|
93
88
|
end
|
|
94
|
-
|
|
95
|
-
# Modification to Pin which logs deprecation warnings if accessed.
|
|
96
|
-
# Will be used by integrations which are phasing out the direct use of #datadog_pin.
|
|
97
|
-
module DeprecatedPin
|
|
98
|
-
include Datadog::Patcher
|
|
99
|
-
|
|
100
|
-
DEPRECATION_WARNING = %(
|
|
101
|
-
Use of Datadog::Pin is DEPRECATED.
|
|
102
|
-
Upgrade to the configuration API using the migration guide here:
|
|
103
|
-
https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.0).freeze
|
|
104
|
-
|
|
105
|
-
# Raise a deprecation warning when #datadog_pin or #datadog_pin= is accessed.
|
|
106
|
-
def onto(obj)
|
|
107
|
-
obj.instance_exec(self) do |pin|
|
|
108
|
-
@datadog_deprecated_pin = pin
|
|
109
|
-
|
|
110
|
-
unless respond_to? :datadog_pin=
|
|
111
|
-
def datadog_pin=(pin)
|
|
112
|
-
@datadog_deprecated_pin.log_deprecation_warning('#datadog_pin=')
|
|
113
|
-
@datadog_pin = pin
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
unless respond_to? :datadog_pin
|
|
118
|
-
def datadog_pin
|
|
119
|
-
@datadog_deprecated_pin.log_deprecation_warning('#datadog_pin')
|
|
120
|
-
@datadog_pin
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# Set instance variable to avoid deprecation warnings
|
|
125
|
-
@datadog_pin = @datadog_deprecated_pin
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
self
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def log_deprecation_warning(method_name)
|
|
132
|
-
# Only log each deprecation warning once (safeguard against log spam)
|
|
133
|
-
do_once(method_name) do
|
|
134
|
-
Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}")
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
89
|
end
|
|
@@ -10,7 +10,7 @@ module Datadog
|
|
|
10
10
|
@criteria = filter || block
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
#
|
|
13
|
+
# NOTE: this SpanFilter implementation only handles traces in which child spans appear
|
|
14
14
|
# after parent spans in the trace array. If in the future child spans can be before
|
|
15
15
|
# parent spans, then the code below will need to be updated.
|
|
16
16
|
def call(trace)
|
|
@@ -19,6 +19,7 @@ module Datadog
|
|
|
19
19
|
def self.extract(metadata)
|
|
20
20
|
metadata = Carrier.new(metadata)
|
|
21
21
|
return Datadog::Context.new unless metadata.valid?
|
|
22
|
+
|
|
22
23
|
Datadog::Context.new(trace_id: metadata.trace_id,
|
|
23
24
|
span_id: metadata.parent_id,
|
|
24
25
|
sampling_priority: metadata.sampling_priority,
|
|
@@ -8,8 +8,8 @@ module Datadog
|
|
|
8
8
|
UUID_PATTERN = '[0-9a-f]{8}[-_]?[0-9a-f]{4}[-_]?[0-9a-f]{4}[-_]?[0-9a-f]{4}[-_]?[0-9a-f]{12}'.freeze
|
|
9
9
|
CONTAINER_PATTERN = '[0-9a-f]{64}'.freeze
|
|
10
10
|
|
|
11
|
-
POD_REGEX = /(pod)?(#{UUID_PATTERN})(?:.slice)
|
|
12
|
-
CONTAINER_REGEX = /(#{UUID_PATTERN}|#{CONTAINER_PATTERN})(?:.scope)
|
|
11
|
+
POD_REGEX = /(pod)?(#{UUID_PATTERN})(?:.slice)?$/.freeze
|
|
12
|
+
CONTAINER_REGEX = /(#{UUID_PATTERN}|#{CONTAINER_PATTERN})(?:.scope)?$/.freeze
|
|
13
13
|
|
|
14
14
|
Descriptor = Struct.new(
|
|
15
15
|
:platform,
|
data/lib/ddtrace/sampler.rb
CHANGED
|
@@ -81,7 +81,7 @@ module Datadog
|
|
|
81
81
|
:default_key
|
|
82
82
|
|
|
83
83
|
def initialize(default_key, default_rate = 1.0, &block)
|
|
84
|
-
raise ArgumentError, 'No resolver given!' unless
|
|
84
|
+
raise ArgumentError, 'No resolver given!' unless block
|
|
85
85
|
|
|
86
86
|
@default_key = default_key
|
|
87
87
|
@resolver = block
|
data/lib/ddtrace/span.rb
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'time'
|
|
4
|
-
require 'thread'
|
|
5
|
-
|
|
6
4
|
require 'ddtrace/utils'
|
|
7
5
|
require 'ddtrace/ext/errors'
|
|
8
6
|
require 'ddtrace/ext/priority'
|
|
@@ -38,14 +36,16 @@ module Datadog
|
|
|
38
36
|
EXTERNAL_MAX_ID = 1 << 64
|
|
39
37
|
|
|
40
38
|
# This limit is for numeric tags because uint64 could end up rounded.
|
|
41
|
-
NUMERIC_TAG_SIZE_RANGE = (-1 << 53..1 << 53)
|
|
39
|
+
NUMERIC_TAG_SIZE_RANGE = (-1 << 53..1 << 53).freeze
|
|
42
40
|
|
|
43
41
|
attr_accessor :name, :service, :resource, :span_type,
|
|
44
42
|
:span_id, :trace_id, :parent_id,
|
|
45
43
|
:status, :sampled,
|
|
46
|
-
:tracer, :context
|
|
44
|
+
:tracer, :context
|
|
45
|
+
|
|
46
|
+
attr_reader :parent, :start_time, :end_time
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
attr_writer :duration
|
|
49
49
|
|
|
50
50
|
# Create a new span linked to the given tracer. Call the \Tracer method <tt>start_span()</tt>
|
|
51
51
|
# and then <tt>finish()</tt> once the tracer operation is over.
|
|
@@ -180,7 +180,7 @@ module Datadog
|
|
|
180
180
|
# behavior and so we maintain it for backward compatibility for those
|
|
181
181
|
# who are using async manual instrumentation that may rely on this
|
|
182
182
|
|
|
183
|
-
@start_time = start_time || Time.now.utc
|
|
183
|
+
@start_time = start_time || Utils::Time.now.utc
|
|
184
184
|
@duration_start = start_time.nil? ? duration_marker : nil
|
|
185
185
|
|
|
186
186
|
self
|
|
@@ -206,7 +206,7 @@ module Datadog
|
|
|
206
206
|
|
|
207
207
|
@allocation_count_finish = now_allocations
|
|
208
208
|
|
|
209
|
-
now = Time.now.utc
|
|
209
|
+
now = Utils::Time.now.utc
|
|
210
210
|
|
|
211
211
|
# Provide a default start_time if unset.
|
|
212
212
|
# Using `now` here causes duration to be 0; this is expected
|