ddtrace 0.21.0 → 0.21.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddab3a41c741e4d490ee6d078c40a953a9095b18
4
- data.tar.gz: 6853021a4383b29e7ae678a809a5697ea5619456
3
+ metadata.gz: a09aedaed6a1aa22354f3c9c3696c6a3b9885f43
4
+ data.tar.gz: 35fdddc2a09fb5f57a9e21a67ccab6d26297583e
5
5
  SHA512:
6
- metadata.gz: aaacd674bf8f46df992234b9a8b72a5d8d53b0d73eaf2a89ad5f0c92a94d8632381402389ca1ee3c3353c6618a94c39db9597a40e3b48ec006122f5023d7b158
7
- data.tar.gz: 95785d1b6ec7472301aa0c5d386edbcadc9ff60c4bf65effedbd130b91bfb1149b1e736d982282b3565d78c9253d0deda998b612cec2ced66c7f373bd691ba72
6
+ metadata.gz: 5851f49e14aa8e4b0be89723b84ee97f912583aac7ec5f66b7a7ef5c3f2962c43ca0a239e6ad44aa781df47339575eacd0d8f11d67d97e84bc0e639103fb3872
7
+ data.tar.gz: beb715b01e94b8e62ecac54dd46ba433beaeb19e905abe6d0b143550fe997a68c60eb88e9a40eae2f7a3269baf892fc980d668fbe5c4acfbf30c71ee09b52f9b
@@ -4,6 +4,16 @@
4
4
 
5
5
  ## [Unreleased (beta)]
6
6
 
7
+ ## [0.21.1] - 2019-03-26
8
+
9
+ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.21.1
10
+
11
+ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.21.0...v0.21.1
12
+
13
+ ### Changed
14
+
15
+ - Support `TAG_ENABLED` for custom instrumentation with analytics. (#728)
16
+
7
17
  ## [0.21.0] - 2019-03-20
8
18
 
9
19
  Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.21.0
@@ -731,8 +741,9 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
731
741
 
732
742
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
733
743
 
734
- [Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.21.0...master
735
- [Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.21.0...0.22-dev
744
+ [Unreleased (stable)]: https://github.com/DataDog/dd-trace-rb/compare/v0.21.1...master
745
+ [Unreleased (beta)]: https://github.com/DataDog/dd-trace-rb/compare/v0.21.1...0.22-dev
746
+ [0.21.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.21.0...v0.21.1
736
747
  [0.21.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.20.0...v0.21.0
737
748
  [0.20.0]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.1...v0.20.0
738
749
  [0.19.1]: https://github.com/DataDog/dd-trace-rb/compare/v0.19.0...v0.19.1
@@ -0,0 +1,58 @@
1
+ require 'ddtrace/ext/analytics'
2
+
3
+ module Datadog
4
+ # Defines analytics behavior
5
+ module Analytics
6
+ class << self
7
+ def set_sample_rate(span, sample_rate)
8
+ return if span.nil? || !sample_rate.is_a?(Numeric)
9
+ span.set_metric(Datadog::Ext::Analytics::TAG_SAMPLE_RATE, sample_rate)
10
+ end
11
+ end
12
+
13
+ # Extension for Datadog::Span
14
+ module Span
15
+ def self.included(base)
16
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
17
+ base.class_eval do
18
+ # Instance methods
19
+ include InstanceMethodsCompatibility
20
+ include InstanceMethods
21
+ end
22
+ else
23
+ base.send(:prepend, InstanceMethods)
24
+ end
25
+ end
26
+
27
+ # Compatibility shim for Rubies not supporting `.prepend`
28
+ module InstanceMethodsCompatibility
29
+ def self.included(base)
30
+ base.class_eval do
31
+ alias_method :set_tag_without_analytics, :set_tag
32
+ remove_method :set_tag
33
+ end
34
+ end
35
+
36
+ def set_tag(*args, &block)
37
+ set_tag_without_analytics(*args, &block)
38
+ end
39
+ end
40
+
41
+ # Instance methods
42
+ module InstanceMethods
43
+ def set_tag(key, value)
44
+ case key
45
+ when Ext::Analytics::TAG_ENABLED
46
+ # If true, set rate to 1.0, otherwise set 0.0.
47
+ value = value == true ? Ext::Analytics::DEFAULT_SAMPLE_RATE : 0.0
48
+ Analytics.set_sample_rate(self, value)
49
+ when Ext::Analytics::TAG_SAMPLE_RATE
50
+ Analytics.set_sample_rate(self, value)
51
+ else
52
+ super if defined?(super)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,8 +1,8 @@
1
- require 'ddtrace/ext/analytics'
1
+ require 'ddtrace/analytics'
2
2
 
3
3
  module Datadog
4
4
  module Contrib
5
- # Defines sampling behavior for integrations
5
+ # Defines analytics behavior for integrations
6
6
  module Analytics
7
7
  module_function
8
8
 
@@ -13,8 +13,7 @@ module Datadog
13
13
  end
14
14
 
15
15
  def set_sample_rate(span, sample_rate)
16
- return if span.nil? || sample_rate.nil?
17
- span.set_metric(Datadog::Ext::Analytics::TAG_SAMPLE_RATE, sample_rate)
16
+ Datadog::Analytics.set_sample_rate(span, sample_rate)
18
17
  end
19
18
  end
20
19
  end
@@ -7,7 +7,7 @@ module Datadog
7
7
  module Extensions
8
8
  def self.extended(base)
9
9
  Datadog.send(:extend, Helpers)
10
- Datadog::Configuration::Settings.send(:include, Configuration)
10
+ Datadog::Configuration::Settings.send(:include, Configuration::Settings)
11
11
  end
12
12
 
13
13
  # Helper methods for Datadog module.
@@ -17,44 +17,41 @@ module Datadog
17
17
  end
18
18
  end
19
19
 
20
- # Extensions for Datadog::Configuration::Settings
21
20
  module Configuration
22
- InvalidIntegrationError = Class.new(StandardError)
23
-
24
- def self.included(base)
25
- # Add the additional options to the global configuration settings
26
- base.instance_eval do
27
- option :registry, default: Registry.new
21
+ # Extensions for Datadog::Configuration::Settings
22
+ module Settings
23
+ InvalidIntegrationError = Class.new(StandardError)
24
+
25
+ def self.included(base)
26
+ # Add the additional options to the global configuration settings
27
+ base.instance_eval do
28
+ option :registry, default: Registry.new
29
+ end
28
30
  end
29
- end
30
31
 
31
- def initialize(options = {})
32
- super
33
- set_option(:registry, options[:registry]) if options.key?(:registry)
34
- end
32
+ def [](integration_name, configuration_name = :default)
33
+ integration = fetch_integration(integration_name)
34
+ integration.configuration(configuration_name) unless integration.nil?
35
+ end
35
36
 
36
- def [](integration_name, configuration_name = :default)
37
- integration = fetch_integration(integration_name)
38
- integration.configuration(configuration_name) unless integration.nil?
39
- end
37
+ def use(integration_name, options = {}, &block)
38
+ integration = fetch_integration(integration_name)
40
39
 
41
- def use(integration_name, options = {}, &block)
42
- integration = fetch_integration(integration_name)
40
+ unless integration.nil?
41
+ configuration_name = options[:describes] || :default
42
+ filtered_options = options.reject { |k, _v| k == :describes }
43
+ integration.configure(configuration_name, filtered_options, &block)
44
+ end
43
45
 
44
- unless integration.nil?
45
- configuration_name = options[:describes] || :default
46
- filtered_options = options.reject { |k, _v| k == :describes }
47
- integration.configure(configuration_name, filtered_options, &block)
46
+ integration.patch if integration.respond_to?(:patch)
48
47
  end
49
48
 
50
- integration.patch if integration.respond_to?(:patch)
51
- end
52
-
53
- private
49
+ private
54
50
 
55
- def fetch_integration(name)
56
- get_option(:registry)[name] ||
57
- raise(InvalidIntegrationError, "'#{name}' is not a valid integration.")
51
+ def fetch_integration(name)
52
+ get_option(:registry)[name] ||
53
+ raise(InvalidIntegrationError, "'#{name}' is not a valid integration.")
54
+ end
58
55
  end
59
56
  end
60
57
  end
@@ -2,8 +2,9 @@ module Datadog
2
2
  module Ext
3
3
  # Defines constants for trace analytics
4
4
  module Analytics
5
+ DEFAULT_SAMPLE_RATE = 1.0
5
6
  ENV_TRACE_ANALYTICS_ENABLED = 'DD_TRACE_ANALYTICS_ENABLED'.freeze
6
- # Tag for sample rate; used by agent to determine whether analytics event is emitted.
7
+ TAG_ENABLED = 'analytics.enabled'.freeze
7
8
  TAG_SAMPLE_RATE = '_dd1.sr.eausr'.freeze
8
9
  end
9
10
  end
@@ -3,6 +3,7 @@ require 'thread'
3
3
 
4
4
  require 'ddtrace/utils'
5
5
  require 'ddtrace/ext/errors'
6
+ require 'ddtrace/analytics'
6
7
 
7
8
  module Datadog
8
9
  # Represents a logical unit of work in the system. Each trace consists of one or more spans.
@@ -252,3 +253,6 @@ module Datadog
252
253
  end
253
254
  end
254
255
  end
256
+
257
+ # Include extensions after Span (for Ruby 1.9 compatibility)
258
+ Datadog::Span.send(:include, Datadog::Analytics::Span)
@@ -2,7 +2,7 @@ module Datadog
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 21
5
- PATCH = 0
5
+ PATCH = 1
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddtrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-20 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -297,6 +297,7 @@ files:
297
297
  - docker-compose.yml
298
298
  - docs/GettingStarted.md
299
299
  - lib/ddtrace.rb
300
+ - lib/ddtrace/analytics.rb
300
301
  - lib/ddtrace/augmentation.rb
301
302
  - lib/ddtrace/augmentation/method_wrapper.rb
302
303
  - lib/ddtrace/augmentation/method_wrapping.rb