ddtrace 1.0.0.beta2 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 788940c4abaa23d0ff929cd72166de2e571552a7a1bb65dad00009b213ba05c5
4
- data.tar.gz: acce0442e79909476053a581894c772fc7cf1bc23248ae8f221c1d15ed34db0f
3
+ metadata.gz: 14636ceebc61d9de8ea83328295cb728de928bd0cf80af29f6c4f73d759ff243
4
+ data.tar.gz: 92110181e57676c407a782a3729a19499b3175fd653162ff260b79be8f75a502
5
5
  SHA512:
6
- metadata.gz: 3be22f6cefcd7f0cb04c8addc80a8f495ffbf527b9558f7caded4b56698d23d3497a8dfaa5d230cedd5d2c90bbf3d461b079cc59e43990eb8eae50fc42471a81
7
- data.tar.gz: d86c22e8352d4cfb55ae1022c80e1d5698e71890ec0867097b96ef2544fe760cd49a82258d77305d5892310bd930630519e6f01913aad5373829e643194bbe18
6
+ metadata.gz: 0dc73ef73c3269adfb1cbf50ba22df0f06b5e9a0237f8bec8428e1b4f9445e45f20fb5ede5c88355e18f4562b2f561b0a4f089715ff44aabf52130a6915e4498
7
+ data.tar.gz: f44f40e302ae841147d5bbd62ebc0fe716ee6b30e8776820efd4c39fd3f9c184b0919dc3752b30316c87e0cde19f5380a42ad6cb9290e319183b8440fef11be1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.0.0] - 2022-04-28
6
+
7
+ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v1.0.0
8
+
9
+ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v1.0.0.beta2...v1.0.0
10
+
11
+ Diff since last stable release: https://github.com/DataDog/dd-trace-rb/compare/v0.54.2...v1.0.0
12
+
13
+ ### Added
14
+
15
+ - GraphQL 2.0 support ([#1982][])
16
+
17
+ ### Changed
18
+
19
+ - AppSec: Update libddwaf to 1.3.0 ([#1981][])
20
+
21
+ ### Fixed
22
+
23
+ - Rails log correlation ([#1989][]) ([@cwoodcox][])
24
+ - Resource not inherited from lazily annotated spans ([#1983][])
25
+ - AppSec: Query address for libddwaf ([#1990][])
26
+
27
+ ### Refactored
28
+
29
+ - Docs: Add undocumented Rake option ([#1980][]) ([@ecdemis123][])
30
+ - Improvements to test suite & CI ([#1970][], [#1974][], [#1991][])
31
+ - Improvements to documentation ([#1984][])
32
+
5
33
  ## [1.0.0.beta2] - 2022-04-14
6
34
 
7
35
  Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v1.0.0.beta2
@@ -1959,7 +1987,8 @@ Release notes: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.3.1
1959
1987
 
1960
1988
  Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
1961
1989
 
1962
- [Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.0.0.beta2...master
1990
+ [Unreleased]: https://github.com/DataDog/dd-trace-rb/compare/v1.0.0...master
1991
+ [1.0.0]: https://github.com/DataDog/dd-trace-rb/compare/v1.0.0.beta2...v1.0.0
1963
1992
  [1.0.0.beta2]: https://github.com/DataDog/dd-trace-rb/compare/v1.0.0.beta1...v1.0.0.beta2
1964
1993
  [1.0.0.beta1]: https://github.com/DataDog/dd-trace-rb/compare/v0.54.2...v1.0.0.beta1
1965
1994
  [0.54.2]: https://github.com/DataDog/dd-trace-rb/compare/v0.54.1...v0.54.2
@@ -2782,9 +2811,19 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
2782
2811
  [#1964]: https://github.com/DataDog/dd-trace-rb/issues/1964
2783
2812
  [#1965]: https://github.com/DataDog/dd-trace-rb/issues/1965
2784
2813
  [#1968]: https://github.com/DataDog/dd-trace-rb/issues/1968
2814
+ [#1970]: https://github.com/DataDog/dd-trace-rb/issues/1970
2785
2815
  [#1973]: https://github.com/DataDog/dd-trace-rb/issues/1973
2816
+ [#1974]: https://github.com/DataDog/dd-trace-rb/issues/1974
2786
2817
  [#1975]: https://github.com/DataDog/dd-trace-rb/issues/1975
2787
2818
  [#1976]: https://github.com/DataDog/dd-trace-rb/issues/1976
2819
+ [#1980]: https://github.com/DataDog/dd-trace-rb/issues/1980
2820
+ [#1981]: https://github.com/DataDog/dd-trace-rb/issues/1981
2821
+ [#1982]: https://github.com/DataDog/dd-trace-rb/issues/1982
2822
+ [#1983]: https://github.com/DataDog/dd-trace-rb/issues/1983
2823
+ [#1984]: https://github.com/DataDog/dd-trace-rb/issues/1984
2824
+ [#1989]: https://github.com/DataDog/dd-trace-rb/issues/1989
2825
+ [#1990]: https://github.com/DataDog/dd-trace-rb/issues/1990
2826
+ [#1991]: https://github.com/DataDog/dd-trace-rb/issues/1991
2788
2827
  [@AdrianLC]: https://github.com/AdrianLC
2789
2828
  [@Azure7111]: https://github.com/Azure7111
2790
2829
  [@BabyGroot]: https://github.com/BabyGroot
@@ -2826,6 +2865,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
2826
2865
  [@ck3g]: https://github.com/ck3g
2827
2866
  [@components]: https://github.com/components
2828
2867
  [@cswatt]: https://github.com/cswatt
2868
+ [@cwoodcox]: https://github.com/cwoodcox
2829
2869
  [@dasch]: https://github.com/dasch
2830
2870
  [@dim]: https://github.com/dim
2831
2871
  [@dirk]: https://github.com/dirk
@@ -2834,6 +2874,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.3.0...v0.3.1
2834
2874
  [@drcapulet]: https://github.com/drcapulet
2835
2875
  [@dudo]: https://github.com/dudo
2836
2876
  [@e1senh0rn]: https://github.com/e1senh0rn
2877
+ [@ecdemis123]: https://github.com/ecdemis123
2837
2878
  [@elliterate]: https://github.com/elliterate
2838
2879
  [@elyalvarado]: https://github.com/elyalvarado
2839
2880
  [@ericmustin]: https://github.com/ericmustin
data/ddtrace.gemspec CHANGED
@@ -53,7 +53,7 @@ Gem::Specification.new do |spec|
53
53
  spec.add_dependency 'debase-ruby_core_source', '<= 0.10.15'
54
54
 
55
55
  # Used by appsec
56
- spec.add_dependency 'libddwaf', '~> 1.2.1.0.0.a'
56
+ spec.add_dependency 'libddwaf', '~> 1.3.0.0.0.a'
57
57
 
58
58
  spec.extensions = ['ext/ddtrace_profiling_native_extension/extconf.rb']
59
59
  end
@@ -1585,6 +1585,7 @@ Where `options` is an optional `Hash` that accepts the following parameters:
1585
1585
  | --- | ----------- | ------- |
1586
1586
  | `enabled` | Defines whether Rake tasks should be traced. Useful for temporarily disabling tracing. `true` or `false` | `true` |
1587
1587
  | `quantize` | Hash containing options for quantization of task arguments. See below for more details and examples. | `{}` |
1588
+ | `service_name` | Service name used for `rake` instrumentation | `'rake'` |
1588
1589
 
1589
1590
  **Configuring task quantization behavior**
1590
1591
 
data/docs/UpgradeGuide.md CHANGED
@@ -689,6 +689,7 @@ end
689
689
  | General | Changed | Many constants have been moved from `Datadog` to `Datadog::Core`, `Datadog::Tracing` | Update your references to these [new namespaces](#1.0-appendix-namespace-constants) where appropriate. |
690
690
  | General | Changed | Some `require` paths have been moved from `ddtrace` to `datadog` | Update your references to these [new paths](#1.0-appendix-namespace-requires) where appropriate. |
691
691
  | General | Removed | Support for trace agent API v0.2 | Use v0.4 instead (default behavior.) |
692
+ | General | Removed | `Datadog.configure` can no longer be called without a block | Remove uses of `Datadog.configure` without a block. |
692
693
  | CI API | Changed | `DD_TRACE_CI_MODE_ENABLED` environment variable is now `DD_TRACE_CI_ENABLED` | Use `DD_TRACE_CI_ENABLED` instead. |
693
694
  | Configuration | Changed | Many settings have been namespaced under specific categories | Update your configuration to these [new settings](#1.0-configuration-settings) where appropriate. |
694
695
  | Configuration | Removed | `Datadog.configure(client, options)` | Use `Datadog::Tracing.configure_onto(client, options)` instead. |
@@ -7,7 +7,14 @@ module Datadog
7
7
  # Normalized extration of data from Rack::Request
8
8
  module Request
9
9
  def self.query(request)
10
- request.query_string.split('&').map { |e| e.split('=').map { |s| CGI.unescape(s) } }
10
+ # Downstream libddwaf expects keys and values to be extractable
11
+ # separately so we can't use [[k, v], ...]. We also want to allow
12
+ # duplicate keys, so we use [{k, v}, ...] instead.
13
+ request.query_string.split('&').map do |e|
14
+ k, v = e.split('=').map { |s| CGI.unescape(s) }
15
+
16
+ { k => v }
17
+ end
11
18
  end
12
19
 
13
20
  # Rack < 2.0 does not have :each_header
@@ -5,12 +5,14 @@ require 'datadog/tracing/context'
5
5
  module Datadog
6
6
  module Tracing
7
7
  # DefaultContextProvider is a default context provider that retrieves
8
- # all contexts from the current thread-local storage. It is suitable for
8
+ # all contexts from the current fiber-local storage. It is suitable for
9
9
  # synchronous programming.
10
+ #
11
+ # @see https://ruby-doc.org/core-3.1.2/Thread.html#method-i-5B-5D Thread attributes are fiber-local
10
12
  class DefaultContextProvider
11
- # Initializes the default context provider with a thread-bound context.
13
+ # Initializes the default context provider with a fiber-bound context.
12
14
  def initialize
13
- @context = ThreadLocalContext.new
15
+ @context = FiberLocalContext.new
14
16
  end
15
17
 
16
18
  # Sets the current context.
@@ -35,32 +37,29 @@ module Datadog
35
37
  end
36
38
  end
37
39
 
38
- # ThreadLocalContext can be used as a tracer global reference to create
39
- # a different {Datadog::Tracing::Context} for each thread. In synchronous tracer, this
40
- # is required to prevent multiple threads sharing the same {Datadog::Tracing::Context}
41
- # in different executions.
42
- class ThreadLocalContext
43
- # ThreadLocalContext can be used as a tracer global reference to create
44
- # a different {Datadog::Tracing::Context} for each thread. In synchronous tracer, this
45
- # is required to prevent multiple threads sharing the same {Datadog::Tracing::Context}
46
- # in different executions.
47
- #
48
- # To support multiple tracers simultaneously, each {Datadog::Tracing::ThreadLocalContext}
49
- # instance has its own thread-local variable.
40
+ # FiberLocalContext can be used as a tracer global reference to create
41
+ # a different {Datadog::Tracing::Context} for each fiber. This allows for the tracer
42
+ # to create a serial execution graph regardless of any concurrent execution: each
43
+ # concurrent execution path creates a new trace graph.
44
+ #
45
+ # @see https://ruby-doc.org/core-3.1.2/Thread.html#method-i-5B-5D Thread attributes are fiber-local
46
+ class FiberLocalContext
47
+ # To support multiple tracers simultaneously, each {Datadog::Tracing::FiberLocalContext}
48
+ # instance has its own fiber-local variable.
50
49
  def initialize
51
50
  @key = "datadog_context_#{object_id}".to_sym
52
51
 
53
52
  self.local = Context.new
54
53
  end
55
54
 
56
- # Override the thread-local context with a new context.
55
+ # Override the fiber-local context with a new context.
57
56
  def local=(ctx)
58
57
  Thread.current[@key] = ctx
59
58
  end
60
59
 
61
- # Return the thread-local context.
62
- def local(thread = Thread.current)
63
- thread[@key] ||= Context.new
60
+ # Return the fiber-local context.
61
+ def local(storage = Thread.current)
62
+ storage[@key] ||= Context.new
64
63
  end
65
64
  end
66
65
  end
@@ -7,11 +7,11 @@ module Datadog
7
7
  # GraphQL integration constants
8
8
  # @public_api Changing resource names, tag names, or environment variables creates breaking changes.
9
9
  module Ext
10
- APP = 'ruby-graphql'.freeze
11
10
  ENV_ENABLED = 'DD_TRACE_GRAPHQL_ENABLED'.freeze
12
11
  ENV_ANALYTICS_ENABLED = 'DD_TRACE_GRAPHQL_ANALYTICS_ENABLED'.freeze
13
12
  ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_GRAPHQL_ANALYTICS_SAMPLE_RATE'.freeze
14
- SERVICE_NAME = 'ruby-graphql'.freeze
13
+ SERVICE_NAME = 'graphql'.freeze
14
+ TAG_COMPONENT = 'graphql'.freeze
15
15
  end
16
16
  end
17
17
  end
@@ -20,9 +20,11 @@ module Datadog
20
20
  end
21
21
 
22
22
  def patch
23
- return if get_option(:schemas).nil?
23
+ if (schemas = get_option(:schemas))
24
+ schemas.each { |s| patch_schema!(s) }
25
+ end
24
26
 
25
- get_option(:schemas).each { |s| patch_schema!(s) }
27
+ patch_legacy_gem!
26
28
  end
27
29
 
28
30
  def patch_schema!(schema)
@@ -55,9 +57,34 @@ module Datadog
55
57
  end
56
58
  end
57
59
 
60
+ # Before https://github.com/rmosolgo/graphql-ruby/pull/4038 was introduced,
61
+ # we were left with incompatibilities between ddtrace 1.0 and older graphql gem versions.
62
+ def patch_legacy_gem!
63
+ return unless Gem::Version.new(::GraphQL::VERSION) <= Gem::Version.new('2.0.6')
64
+
65
+ ::GraphQL::Tracing::DataDogTracing.prepend(PatchLegacyGem)
66
+ end
67
+
58
68
  def get_option(option)
59
69
  Datadog.configuration.tracing[:graphql].get_option(option)
60
70
  end
71
+
72
+ # Patches the graphql gem to support ddtrace 1.0.
73
+ # This is not necessary in versions containing https://github.com/rmosolgo/graphql-ruby/pull/4038.
74
+ module PatchLegacyGem
75
+ # Ensure invocation to #trace method targets the new namespaced public API object,
76
+ # instead of the old global Datadog.trace.
77
+ # This is fixed in graphql > 2.0.3.
78
+ def tracer
79
+ options.fetch(:tracer, Datadog::Tracing) # GraphQL will invoke #trace on the returned object
80
+ end
81
+
82
+ # Ensure resource name is not left as `nil`.
83
+ # This is fixed in graphql > 2.0.6.
84
+ def fallback_transaction_name(context)
85
+ context[:tracing_fallback_transaction_name] || 'execute.graphql'
86
+ end
87
+ end
61
88
  end
62
89
  end
63
90
  end
@@ -81,7 +81,9 @@ module Datadog
81
81
 
82
82
  # if lograge isn't set, check if tagged logged is enabled.
83
83
  # if so, add proc that injects trace identifiers for tagged logging.
84
- if (logger = app.config.logger) \
84
+ logger = app.config.logger || ::Rails.logger
85
+
86
+ if logger \
85
87
  && defined?(::ActiveSupport::TaggedLogging) \
86
88
  && logger.is_a?(::ActiveSupport::TaggedLogging)
87
89
 
@@ -89,7 +91,9 @@ module Datadog
89
91
  should_warn = false
90
92
  end
91
93
 
92
- Datadog.logger.warn("Unable to enable Datadog Trace context, Logger #{logger} is not supported") if should_warn
94
+ if should_warn
95
+ Datadog.logger.warn("Unable to enable Datadog Trace context, Logger #{logger.class} is not supported")
96
+ end
93
97
  end
94
98
 
95
99
  def patch_after_intialize
@@ -30,8 +30,6 @@ module Datadog
30
30
  :trace_service,
31
31
  :version
32
32
 
33
- # rubocop:disable Metrics/CyclomaticComplexity
34
- # rubocop:disable Metrics/PerceivedComplexity
35
33
  # @!visibility private
36
34
  def initialize(
37
35
  env: nil,
@@ -48,26 +46,19 @@ module Datadog
48
46
  version: nil
49
47
  )
50
48
  # Dup and freeze strings so they aren't modified by reference.
51
- @env = env || Datadog.configuration.env
52
- @service = service || Datadog.configuration.service
49
+ @env = Core::Utils::SafeDup.frozen_or_dup(env || Datadog.configuration.env).freeze
50
+ @service = Core::Utils::SafeDup.frozen_or_dup(service || Datadog.configuration.service).freeze
53
51
  @span_id = span_id || 0
54
- @span_name = span_name && span_name.dup.freeze
55
- @span_resource = span_resource && span_resource.dup.freeze
56
- @span_service = span_service && span_service.dup.freeze
57
- @span_type = span_type && span_type.dup.freeze
52
+ @span_name = Core::Utils::SafeDup.frozen_or_dup(span_name).freeze
53
+ @span_resource = Core::Utils::SafeDup.frozen_or_dup(span_resource).freeze
54
+ @span_service = Core::Utils::SafeDup.frozen_or_dup(span_service).freeze
55
+ @span_type = Core::Utils::SafeDup.frozen_or_dup(span_type).freeze
58
56
  @trace_id = trace_id || 0
59
- @trace_name = trace_name && trace_name.dup.freeze
60
- @trace_resource = trace_resource && trace_resource.dup.freeze
61
- @trace_service = trace_service && trace_service.dup.freeze
62
- @version = version || Datadog.configuration.version
63
-
64
- # Finish freezing globals
65
- @service = @service.dup.freeze unless @service.nil?
66
- @env = @env.dup.freeze unless @env.nil?
67
- @version = @version.dup.freeze unless @version.nil?
57
+ @trace_name = Core::Utils::SafeDup.frozen_or_dup(trace_name).freeze
58
+ @trace_resource = Core::Utils::SafeDup.frozen_or_dup(trace_resource).freeze
59
+ @trace_service = Core::Utils::SafeDup.frozen_or_dup(trace_service).freeze
60
+ @version = Core::Utils::SafeDup.frozen_or_dup(version || Datadog.configuration.version).freeze
68
61
  end
69
- # rubocop:enable Metrics/CyclomaticComplexity
70
- # rubocop:enable Metrics/PerceivedComplexity
71
62
 
72
63
  def to_log_format
73
64
  @log_format ||= begin
@@ -3,6 +3,7 @@
3
3
  # typed: true
4
4
 
5
5
  require 'datadog/core/utils'
6
+ require 'datadog/core/utils/safe_dup'
6
7
 
7
8
  require 'datadog/tracing/metadata/ext'
8
9
  require 'datadog/tracing/metadata'
@@ -79,10 +80,10 @@ module Datadog
79
80
  type: span_type,
80
81
  trace_id: nil
81
82
  )
82
- @name = name
83
- @service = service
84
- @resource = resource
85
- @type = type
83
+ @name = Core::Utils::SafeDup.frozen_or_dup(name)
84
+ @service = Core::Utils::SafeDup.frozen_or_dup(service)
85
+ @resource = Core::Utils::SafeDup.frozen_or_dup(resource)
86
+ @type = Core::Utils::SafeDup.frozen_or_dup(type)
86
87
 
87
88
  @id = id || Core::Utils.next_id
88
89
  @parent_id = parent_id || 0
@@ -457,18 +457,18 @@ module Datadog
457
457
  # we don't want this SpanOperation to modify it further.
458
458
  def build_span
459
459
  Span.new(
460
- @name.frozen? ? @name : @name.dup,
460
+ @name,
461
461
  duration: duration,
462
462
  end_time: @end_time,
463
463
  id: @id,
464
464
  meta: meta.dup,
465
465
  metrics: metrics.dup,
466
466
  parent_id: @parent_id,
467
- resource: @resource.frozen? ? @resource : @resource.dup,
468
- service: @service.frozen? ? @service : @service.dup,
467
+ resource: @resource,
468
+ service: @service,
469
469
  start_time: @start_time,
470
470
  status: @status,
471
- type: @type.frozen? ? @type : @type.dup,
471
+ type: @type,
472
472
  trace_id: @trace_id
473
473
  )
474
474
  end
@@ -32,14 +32,11 @@ module Datadog
32
32
  attr_accessor \
33
33
  :agent_sample_rate,
34
34
  :hostname,
35
- :name,
36
35
  :origin,
37
36
  :rate_limiter_rate,
38
- :resource,
39
37
  :rule_sample_rate,
40
38
  :sample_rate,
41
- :sampling_priority,
42
- :service
39
+ :sampling_priority
43
40
 
44
41
  attr_reader \
45
42
  :active_span_count,
@@ -49,7 +46,10 @@ module Datadog
49
46
  :parent_span_id
50
47
 
51
48
  attr_writer \
52
- :sampled
49
+ :name,
50
+ :resource,
51
+ :sampled,
52
+ :service
53
53
 
54
54
  def initialize(
55
55
  agent_sample_rate: nil,
@@ -128,6 +128,18 @@ module Datadog
128
128
  self.sampling_priority = Sampling::Ext::Priority::USER_REJECT
129
129
  end
130
130
 
131
+ def name
132
+ @name || (root_span && root_span.name)
133
+ end
134
+
135
+ def resource
136
+ @resource || (root_span && root_span.resource)
137
+ end
138
+
139
+ def service
140
+ @service || (root_span && root_span.service)
141
+ end
142
+
131
143
  def measure(
132
144
  op_name,
133
145
  events: nil,
@@ -242,13 +254,13 @@ module Datadog
242
254
  span_type: (@active_span && @active_span.type),
243
255
  trace_hostname: @hostname,
244
256
  trace_id: @id,
245
- trace_name: @name,
257
+ trace_name: name,
246
258
  trace_origin: @origin,
247
259
  trace_process_id: Core::Environment::Identity.pid,
248
- trace_resource: @resource,
260
+ trace_resource: resource,
249
261
  trace_runtime_id: Core::Environment::Identity.id,
250
262
  trace_sampling_priority: @sampling_priority,
251
- trace_service: @service,
263
+ trace_service: service,
252
264
  ).freeze
253
265
  end
254
266
 
@@ -261,16 +273,16 @@ module Datadog
261
273
  hostname: (@hostname && @hostname.dup),
262
274
  id: @id,
263
275
  max_length: @max_length,
264
- name: (@name && @name.dup),
276
+ name: (name && name.dup),
265
277
  origin: (@origin && @origin.dup),
266
278
  parent_span_id: (@active_span && @active_span.id) || @parent_span_id,
267
279
  rate_limiter_rate: @rate_limiter_rate,
268
- resource: (@resource && @resource.dup),
280
+ resource: (resource && resource.dup),
269
281
  rule_sample_rate: @rule_sample_rate,
270
282
  sample_rate: @sample_rate,
271
283
  sampled: @sampled,
272
284
  sampling_priority: @sampling_priority,
273
- service: (@service && @service.dup),
285
+ service: (service && service.dup),
274
286
  tags: meta.dup,
275
287
  metrics: metrics.dup
276
288
  )
@@ -370,7 +382,7 @@ module Datadog
370
382
  deactivate_span!(span_op)
371
383
 
372
384
  # Set finished, to signal root span has completed.
373
- @finished = true if span_op == @root_span
385
+ @finished = true if span_op == root_span
374
386
 
375
387
  # Update active span count
376
388
  @active_span_count -= 1
@@ -390,12 +402,6 @@ module Datadog
390
402
  return if span.nil? || root_span
391
403
 
392
404
  @root_span = span
393
-
394
- # Auto populate these attributes if
395
- # they haven't been set yet.
396
- @name ||= span.name
397
- @resource ||= span.resource
398
- @service ||= span.service
399
405
  end
400
406
 
401
407
  def build_trace(spans, partial = false)
@@ -412,12 +418,12 @@ module Datadog
412
418
  runtime_id: Core::Environment::Identity.id,
413
419
  sample_rate: @sample_rate,
414
420
  sampling_priority: @sampling_priority,
415
- name: @name,
416
- resource: @resource,
417
- service: @service,
421
+ name: name,
422
+ resource: resource,
423
+ service: service,
418
424
  tags: meta,
419
425
  metrics: metrics,
420
- root_span_id: !partial ? @root_span && @root_span.id : nil
426
+ root_span_id: !partial ? root_span && root_span.id : nil
421
427
  )
422
428
  end
423
429
  end
@@ -62,8 +62,8 @@ module Datadog
62
62
 
63
63
  # Does not make an effort to move metrics out of tags
64
64
  # The caller is expected to have done that
65
- @meta = tags || {}
66
- @metrics = metrics || {}
65
+ @meta = (tags && tags.dup) || {}
66
+ @metrics = (metrics && metrics.dup) || {}
67
67
 
68
68
  # Set well-known tags, defaulting to getting the values from tags
69
69
  @agent_sample_rate = agent_sample_rate || agent_sample_rate_tag
@@ -199,7 +199,7 @@ module Datadog
199
199
 
200
200
  # The active, unfinished trace, representing the current instrumentation context.
201
201
  #
202
- # The active trace is thread-local.
202
+ # The active trace is fiber-local.
203
203
  #
204
204
  # @param [Thread] key Thread to retrieve trace from. Defaults to current thread. For internal use only.
205
205
  # @return [Datadog::Tracing::TraceSegment] the active trace
@@ -5,7 +5,7 @@ module DDTrace
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = 'beta2'.freeze
8
+ PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
11
11
 
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: 1.0.0.beta2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-15 00:00:00.000000000 Z
11
+ date: 2022-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.1.0.0.a
47
+ version: 1.3.0.0.0.a
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2.1.0.0.a
54
+ version: 1.3.0.0.0.a
55
55
  description: |
56
56
  ddtrace is Datadog’s tracing client for Ruby. It is used to trace requests
57
57
  as they flow across web servers, databases and microservices so that developers
@@ -717,7 +717,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
717
717
  - !ruby/object:Gem::Version
718
718
  version: 2.0.0
719
719
  requirements: []
720
- rubygems_version: 3.2.3
720
+ rubygems_version: 3.1.6
721
721
  signing_key:
722
722
  specification_version: 4
723
723
  summary: Datadog tracing code for your Ruby applications