sentry-ruby-core 5.10.0 → 5.11.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: e70916ec6385aa4a3aa3b7a7581c4c641076bb71eab38effea7cb1640c9b582a
4
- data.tar.gz: 943213fc7484da3a08692dd525d52cafbfff60dacead8373627765d1ba05120f
3
+ metadata.gz: bdd8eb2494c450be3e5f5fddfad4bf2a03ea8977d389aa289e55e320d5d00608
4
+ data.tar.gz: ff18479058fdcd44227409610251a2c0b014766be1d0641ac9b83e8badd6489a
5
5
  SHA512:
6
- metadata.gz: b0f5fa06a98c566aff53a89e1169cb40b148faf7a8ed90c5df2d7d38481f0f8ace365dc4d51359616ccbafb6920a6794ddf79490026c3306a4b38656a09b6ec4
7
- data.tar.gz: 3ddaa6472d696a19dd9cc97bb7fb259ecff49d36da7e8dbff65cebdf2fc62bdf95da54a92c2ee8f32ab5206044a7306842946c5fde7e0fa365c4c5b282c9fb49
6
+ metadata.gz: 77ab7c5172623cf4e48daa4e743ad2d0f6490592d9786498cdc03c9652dff2ec607b5738c7b9bf4b3799f300bfabd51226afe780a6b50a124f312330be66db8e
7
+ data.tar.gz: 4fdbd60228c2fe23e7db4b4d7d1c2e8841eeec561ef3de01f41c0415b997bc5a5d90cc5fe08e6ccc98eb1352043a25c82e98489cd9720db65967c5a126859d78
data/lib/sentry/client.rb CHANGED
@@ -148,6 +148,8 @@ module Sentry
148
148
  raise
149
149
  end
150
150
 
151
+ # @deprecated use Sentry.get_traceparent instead.
152
+ #
151
153
  # Generates a Sentry trace for distribted tracing from the given Span.
152
154
  # Returns `nil` if `config.propagate_traces` is `false`.
153
155
  # @param span [Span] the span to generate trace from.
@@ -160,7 +162,9 @@ module Sentry
160
162
  trace
161
163
  end
162
164
 
163
- # Generates a W3C Baggage header for distribted tracing from the given Span.
165
+ # @deprecated Use Sentry.get_baggage instead.
166
+ #
167
+ # Generates a W3C Baggage header for distributed tracing from the given Span.
164
168
  # Returns `nil` if `config.propagate_traces` is `false`.
165
169
  # @param span [Span] the span to generate trace from.
166
170
  # @return [String, nil]
@@ -243,6 +243,11 @@ module Sentry
243
243
  # @return [Boolean]
244
244
  attr_accessor :auto_session_tracking
245
245
 
246
+ # Allowlist of outgoing request targets to which sentry-trace and baggage headers are attached.
247
+ # Default is all (/.*/)
248
+ # @return [Array<String, Regexp>]
249
+ attr_accessor :trace_propagation_targets
250
+
246
251
  # The instrumenter to use, :sentry or :otel
247
252
  # @return [Symbol]
248
253
  attr_reader :instrumenter
@@ -290,6 +295,8 @@ module Sentry
290
295
 
291
296
  INSTRUMENTERS = [:sentry, :otel]
292
297
 
298
+ PROPAGATION_TARGETS_MATCH_ALL = /.*/.freeze
299
+
293
300
  class << self
294
301
  # Post initialization callbacks are called at the end of initialization process
295
302
  # allowing extending the configuration of sentry-ruby by multiple extensions
@@ -332,6 +339,7 @@ module Sentry
332
339
  self.dsn = ENV['SENTRY_DSN']
333
340
  self.server_name = server_name_from_env
334
341
  self.instrumenter = :sentry
342
+ self.trace_propagation_targets = [PROPAGATION_TARGETS_MATCH_ALL]
335
343
 
336
344
  self.before_send = nil
337
345
  self.before_send_transaction = nil
data/lib/sentry/event.rb CHANGED
@@ -37,6 +37,11 @@ module Sentry
37
37
  # @return [RequestInterface]
38
38
  attr_reader :request
39
39
 
40
+ # Dynamic Sampling Context (DSC) that gets attached
41
+ # as the trace envelope header in the transport.
42
+ # @return [Hash, nil]
43
+ attr_accessor :dynamic_sampling_context
44
+
40
45
  # @param configuration [Configuration]
41
46
  # @param integration_meta [Hash, nil]
42
47
  # @param message [String, nil]
@@ -54,6 +59,7 @@ module Sentry
54
59
  @tags = {}
55
60
 
56
61
  @fingerprint = []
62
+ @dynamic_sampling_context = nil
57
63
 
58
64
  # configuration data that's directly used by events
59
65
  @server_name = configuration.server_name
data/lib/sentry/hub.rb CHANGED
@@ -229,6 +229,50 @@ module Sentry
229
229
  end_session
230
230
  end
231
231
 
232
+ def get_traceparent
233
+ return nil unless current_scope
234
+
235
+ current_scope.get_span&.to_sentry_trace ||
236
+ current_scope.propagation_context.get_traceparent
237
+ end
238
+
239
+ def get_baggage
240
+ return nil unless current_scope
241
+
242
+ current_scope.get_span&.to_baggage ||
243
+ current_scope.propagation_context.get_baggage&.serialize
244
+ end
245
+
246
+ def get_trace_propagation_headers
247
+ headers = {}
248
+
249
+ traceparent = get_traceparent
250
+ headers[SENTRY_TRACE_HEADER_NAME] = traceparent if traceparent
251
+
252
+ baggage = get_baggage
253
+ headers[BAGGAGE_HEADER_NAME] = baggage if baggage && !baggage.empty?
254
+
255
+ headers
256
+ end
257
+
258
+ def continue_trace(env, **options)
259
+ configure_scope { |s| s.generate_propagation_context(env) }
260
+
261
+ return nil unless configuration.tracing_enabled?
262
+
263
+ propagation_context = current_scope.propagation_context
264
+ return nil unless propagation_context.incoming_trace
265
+
266
+ Transaction.new(
267
+ hub: self,
268
+ trace_id: propagation_context.trace_id,
269
+ parent_span_id: propagation_context.parent_span_id,
270
+ parent_sampled: propagation_context.parent_sampled,
271
+ baggage: propagation_context.baggage,
272
+ **options
273
+ )
274
+ end
275
+
232
276
  private
233
277
 
234
278
  def current_layer
@@ -11,7 +11,8 @@ module Sentry
11
11
  OMISSION_MARK = "...".freeze
12
12
  MAX_LOCAL_BYTES = 1024
13
13
 
14
- attr_reader :type, :value, :module, :thread_id, :stacktrace
14
+ attr_reader :type, :module, :thread_id, :stacktrace
15
+ attr_accessor :value
15
16
 
16
17
  def initialize(exception:, stacktrace: nil)
17
18
  @type = exception.class.to_s
@@ -30,18 +30,21 @@ module Sentry
30
30
  return super if from_sentry_sdk?
31
31
 
32
32
  Sentry.with_child_span(op: OP_NAME, start_timestamp: Sentry.utc_now.to_f) do |sentry_span|
33
- set_sentry_trace_header(req, sentry_span)
33
+ request_info = extract_request_info(req)
34
+
35
+ if propagate_trace?(request_info[:url], Sentry.configuration)
36
+ set_propagation_headers(req)
37
+ end
34
38
 
35
39
  super.tap do |res|
36
- record_sentry_breadcrumb(req, res)
40
+ record_sentry_breadcrumb(request_info, res)
37
41
 
38
42
  if sentry_span
39
- request_info = extract_request_info(req)
40
43
  sentry_span.set_description("#{request_info[:method]} #{request_info[:url]}")
41
- sentry_span.set_data('url', request_info[:url])
42
- sentry_span.set_data('http.method', request_info[:method])
43
- sentry_span.set_data('http.query', request_info[:query]) if request_info[:query]
44
- sentry_span.set_data('status', res.code.to_i)
44
+ sentry_span.set_data(Span::DataConventions::URL, request_info[:url])
45
+ sentry_span.set_data(Span::DataConventions::HTTP_METHOD, request_info[:method])
46
+ sentry_span.set_data(Span::DataConventions::HTTP_QUERY, request_info[:query]) if request_info[:query]
47
+ sentry_span.set_data(Span::DataConventions::HTTP_STATUS_CODE, res.code.to_i)
45
48
  end
46
49
  end
47
50
  end
@@ -49,23 +52,13 @@ module Sentry
49
52
 
50
53
  private
51
54
 
52
- def set_sentry_trace_header(req, sentry_span)
53
- return unless sentry_span
54
-
55
- client = Sentry.get_current_client
56
-
57
- trace = client.generate_sentry_trace(sentry_span)
58
- req[SENTRY_TRACE_HEADER_NAME] = trace if trace
59
-
60
- baggage = client.generate_baggage(sentry_span)
61
- req[BAGGAGE_HEADER_NAME] = baggage if baggage && !baggage.empty?
55
+ def set_propagation_headers(req)
56
+ Sentry.get_trace_propagation_headers&.each { |k, v| req[k] = v }
62
57
  end
63
58
 
64
- def record_sentry_breadcrumb(req, res)
59
+ def record_sentry_breadcrumb(request_info, res)
65
60
  return unless Sentry.initialized? && Sentry.configuration.breadcrumbs_logger.include?(:http_logger)
66
61
 
67
- request_info = extract_request_info(req)
68
-
69
62
  crumb = Sentry::Breadcrumb.new(
70
63
  level: :info,
71
64
  category: BREADCRUMB_CATEGORY,
@@ -96,6 +89,12 @@ module Sentry
96
89
 
97
90
  result
98
91
  end
92
+
93
+ def propagate_trace?(url, configuration)
94
+ url &&
95
+ configuration.propagate_traces &&
96
+ configuration.trace_propagation_targets.any? { |target| url.match?(target) }
97
+ end
99
98
  end
100
99
  end
101
100
  end
@@ -0,0 +1,134 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "securerandom"
4
+ require "sentry/baggage"
5
+
6
+ module Sentry
7
+ class PropagationContext
8
+ SENTRY_TRACE_REGEXP = Regexp.new(
9
+ "^[ \t]*" + # whitespace
10
+ "([0-9a-f]{32})?" + # trace_id
11
+ "-?([0-9a-f]{16})?" + # span_id
12
+ "-?([01])?" + # sampled
13
+ "[ \t]*$" # whitespace
14
+ )
15
+
16
+ # An uuid that can be used to identify a trace.
17
+ # @return [String]
18
+ attr_reader :trace_id
19
+ # An uuid that can be used to identify the span.
20
+ # @return [String]
21
+ attr_reader :span_id
22
+ # Span parent's span_id.
23
+ # @return [String, nil]
24
+ attr_reader :parent_span_id
25
+ # The sampling decision of the parent transaction.
26
+ # @return [Boolean, nil]
27
+ attr_reader :parent_sampled
28
+ # Is there an incoming trace or not?
29
+ # @return [Boolean]
30
+ attr_reader :incoming_trace
31
+ # This is only for accessing the current baggage variable.
32
+ # Please use the #get_baggage method for interfacing outside this class.
33
+ # @return [Baggage, nil]
34
+ attr_reader :baggage
35
+
36
+ def initialize(scope, env = nil)
37
+ @scope = scope
38
+ @parent_span_id = nil
39
+ @parent_sampled = nil
40
+ @baggage = nil
41
+ @incoming_trace = false
42
+
43
+ if env
44
+ sentry_trace_header = env["HTTP_SENTRY_TRACE"] || env[SENTRY_TRACE_HEADER_NAME]
45
+ baggage_header = env["HTTP_BAGGAGE"] || env[BAGGAGE_HEADER_NAME]
46
+
47
+ if sentry_trace_header
48
+ sentry_trace_data = self.class.extract_sentry_trace(sentry_trace_header)
49
+
50
+ if sentry_trace_data
51
+ @trace_id, @parent_span_id, @parent_sampled = sentry_trace_data
52
+
53
+ @baggage = if baggage_header && !baggage_header.empty?
54
+ Baggage.from_incoming_header(baggage_header)
55
+ else
56
+ # If there's an incoming sentry-trace but no incoming baggage header,
57
+ # for instance in traces coming from older SDKs,
58
+ # baggage will be empty and frozen and won't be populated as head SDK.
59
+ Baggage.new({})
60
+ end
61
+
62
+ @baggage.freeze!
63
+ @incoming_trace = true
64
+ end
65
+ end
66
+ end
67
+
68
+ @trace_id ||= SecureRandom.uuid.delete("-")
69
+ @span_id = SecureRandom.uuid.delete("-").slice(0, 16)
70
+ end
71
+
72
+ # Extract the trace_id, parent_span_id and parent_sampled values from a sentry-trace header.
73
+ #
74
+ # @param sentry_trace [String] the sentry-trace header value from the previous transaction.
75
+ # @return [Array, nil]
76
+ def self.extract_sentry_trace(sentry_trace)
77
+ match = SENTRY_TRACE_REGEXP.match(sentry_trace)
78
+ return nil if match.nil?
79
+
80
+ trace_id, parent_span_id, sampled_flag = match[1..3]
81
+ parent_sampled = sampled_flag.nil? ? nil : sampled_flag != "0"
82
+
83
+ [trace_id, parent_span_id, parent_sampled]
84
+ end
85
+
86
+ # Returns the trace context that can be used to embed in an Event.
87
+ # @return [Hash]
88
+ def get_trace_context
89
+ {
90
+ trace_id: trace_id,
91
+ span_id: span_id,
92
+ parent_span_id: parent_span_id
93
+ }
94
+ end
95
+
96
+ # Returns the sentry-trace header from the propagation context.
97
+ # @return [String]
98
+ def get_traceparent
99
+ "#{trace_id}-#{span_id}"
100
+ end
101
+
102
+ # Returns the Baggage from the propagation context or populates as head SDK if empty.
103
+ # @return [Baggage, nil]
104
+ def get_baggage
105
+ populate_head_baggage if @baggage.nil? || @baggage.mutable
106
+ @baggage
107
+ end
108
+
109
+ # Returns the Dynamic Sampling Context from the baggage.
110
+ # @return [String, nil]
111
+ def get_dynamic_sampling_context
112
+ get_baggage&.dynamic_sampling_context
113
+ end
114
+
115
+ private
116
+
117
+ def populate_head_baggage
118
+ return unless Sentry.initialized?
119
+
120
+ configuration = Sentry.configuration
121
+
122
+ items = {
123
+ "trace_id" => trace_id,
124
+ "environment" => configuration.environment,
125
+ "release" => configuration.release,
126
+ "public_key" => configuration.dsn&.public_key,
127
+ "user_segment" => @scope.user && @scope.user["segment"]
128
+ }
129
+
130
+ items.compact!
131
+ @baggage = Baggage.new(items, mutable: false)
132
+ end
133
+ end
134
+ end
@@ -62,11 +62,8 @@ module Sentry
62
62
  end
63
63
 
64
64
  def start_transaction(env, scope)
65
- sentry_trace = env["HTTP_SENTRY_TRACE"]
66
- baggage = env["HTTP_BAGGAGE"]
67
-
68
65
  options = { name: scope.transaction_name, source: scope.transaction_source, op: transaction_op }
69
- transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, baggage: baggage, **options) if sentry_trace
66
+ transaction = Sentry.continue_trace(env, **options)
70
67
  Sentry.start_transaction(transaction: transaction, custom_sampling_context: { env: env }, **options)
71
68
  end
72
69
 
data/lib/sentry/redis.rb CHANGED
@@ -19,7 +19,10 @@ module Sentry
19
19
 
20
20
  if span
21
21
  span.set_description(commands_description)
22
- span.set_data(:server, server_description)
22
+ span.set_data(Span::DataConventions::DB_SYSTEM, "redis")
23
+ span.set_data(Span::DataConventions::DB_NAME, db)
24
+ span.set_data(Span::DataConventions::SERVER_ADDRESS, host)
25
+ span.set_data(Span::DataConventions::SERVER_PORT, port)
23
26
  end
24
27
  end
25
28
  end
data/lib/sentry/scope.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "sentry/breadcrumb_buffer"
4
+ require "sentry/propagation_context"
4
5
  require "etc"
5
6
 
6
7
  module Sentry
@@ -20,7 +21,8 @@ module Sentry
20
21
  :event_processors,
21
22
  :rack_env,
22
23
  :span,
23
- :session
24
+ :session,
25
+ :propagation_context
24
26
  ]
25
27
 
26
28
  attr_reader(*ATTRIBUTES)
@@ -50,7 +52,10 @@ module Sentry
50
52
  event.transaction_info = { source: transaction_source } if transaction_source
51
53
 
52
54
  if span
53
- event.contexts[:trace] = span.get_trace_context
55
+ event.contexts[:trace] ||= span.get_trace_context
56
+ else
57
+ event.contexts[:trace] ||= propagation_context.get_trace_context
58
+ event.dynamic_sampling_context ||= propagation_context.get_dynamic_sampling_context
54
59
  end
55
60
 
56
61
  event.fingerprint = fingerprint
@@ -95,6 +100,7 @@ module Sentry
95
100
  copy.fingerprint = fingerprint.deep_dup
96
101
  copy.span = span.deep_dup
97
102
  copy.session = session.deep_dup
103
+ copy.propagation_context = propagation_context.deep_dup
98
104
  copy
99
105
  end
100
106
 
@@ -111,6 +117,7 @@ module Sentry
111
117
  self.transaction_sources = scope.transaction_sources
112
118
  self.fingerprint = scope.fingerprint
113
119
  self.span = scope.span
120
+ self.propagation_context = scope.propagation_context
114
121
  end
115
122
 
116
123
  # Updates the scope's data from the given options.
@@ -272,6 +279,13 @@ module Sentry
272
279
  @event_processors << block
273
280
  end
274
281
 
282
+ # Generate a new propagation context either from the incoming env headers or from scratch.
283
+ # @param env [Hash, nil]
284
+ # @return [void]
285
+ def generate_propagation_context(env = nil)
286
+ @propagation_context = PropagationContext.new(self, env)
287
+ end
288
+
275
289
  protected
276
290
 
277
291
  # for duplicating scopes internally
@@ -292,6 +306,7 @@ module Sentry
292
306
  @rack_env = {}
293
307
  @span = nil
294
308
  @session = nil
309
+ generate_propagation_context
295
310
  set_new_breadcrumb_buffer
296
311
  end
297
312
 
data/lib/sentry/span.rb CHANGED
@@ -4,6 +4,43 @@ require "securerandom"
4
4
 
5
5
  module Sentry
6
6
  class Span
7
+
8
+ # We will try to be consistent with OpenTelemetry on this front going forward.
9
+ # https://develop.sentry.dev/sdk/performance/span-data-conventions/
10
+ module DataConventions
11
+ URL = "url"
12
+ HTTP_STATUS_CODE = "http.response.status_code"
13
+ HTTP_QUERY = "http.query"
14
+ HTTP_METHOD = "http.method"
15
+
16
+ # An identifier for the database management system (DBMS) product being used.
17
+ # Example: postgresql
18
+ DB_SYSTEM = "db.system"
19
+
20
+ # The name of the database being accessed.
21
+ # For commands that switch the database, this should be set to the target database
22
+ # (even if the command fails).
23
+ # Example: myDatabase
24
+ DB_NAME = "db.name"
25
+
26
+ # Name of the database host.
27
+ # Example: example.com
28
+ SERVER_ADDRESS = "server.address"
29
+
30
+ # Logical server port number
31
+ # Example: 80; 8080; 443
32
+ SERVER_PORT = "server.port"
33
+
34
+ # Physical server IP address or Unix socket address.
35
+ # Example: 10.5.3.2
36
+ SERVER_SOCKET_ADDRESS = "server.socket.address"
37
+
38
+ # Physical server port.
39
+ # Recommended: If different than server.port.
40
+ # Example: 16456
41
+ SERVER_SOCKET_PORT = "server.socket.port"
42
+ end
43
+
7
44
  STATUS_MAP = {
8
45
  400 => "invalid_argument",
9
46
  401 => "unauthenticated",
@@ -75,7 +112,7 @@ module Sentry
75
112
  timestamp: nil
76
113
  )
77
114
  @trace_id = trace_id || SecureRandom.uuid.delete("-")
78
- @span_id = span_id || SecureRandom.hex(8)
115
+ @span_id = span_id || SecureRandom.uuid.delete("-").slice(0, 16)
79
116
  @parent_span_id = parent_span_id
80
117
  @sampled = sampled
81
118
  @start_timestamp = start_timestamp || Sentry.utc_now.to_f
@@ -208,7 +245,7 @@ module Sentry
208
245
  # @param status_code [String] example: "500".
209
246
  def set_http_status(status_code)
210
247
  status_code = status_code.to_i
211
- set_data("status_code", status_code)
248
+ set_data(DataConventions::HTTP_STATUS_CODE, status_code)
212
249
 
213
250
  status =
214
251
  if status_code >= 200 && status_code < 299
@@ -2,16 +2,13 @@
2
2
 
3
3
  require "sentry/baggage"
4
4
  require "sentry/profiler"
5
+ require "sentry/propagation_context"
5
6
 
6
7
  module Sentry
7
8
  class Transaction < Span
8
- SENTRY_TRACE_REGEXP = Regexp.new(
9
- "^[ \t]*" + # whitespace
10
- "([0-9a-f]{32})?" + # trace_id
11
- "-?([0-9a-f]{16})?" + # span_id
12
- "-?([01])?" + # sampled
13
- "[ \t]*$" # whitespace
14
- )
9
+ # @deprecated Use Sentry::PropagationContext::SENTRY_TRACE_REGEXP instead.
10
+ SENTRY_TRACE_REGEXP = PropagationContext::SENTRY_TRACE_REGEXP
11
+
15
12
  UNLABELD_NAME = "<unlabeled transaction>".freeze
16
13
  MESSAGE_PREFIX = "[Tracing]"
17
14
 
@@ -92,6 +89,8 @@ module Sentry
92
89
  init_span_recorder
93
90
  end
94
91
 
92
+ # @deprecated use Sentry.continue_trace instead.
93
+ #
95
94
  # Initalizes a Transaction instance with a Sentry trace string from another transaction (usually from an external request).
96
95
  #
97
96
  # The original transaction will become the parent of the new Transaction instance. And they will share the same `trace_id`.
@@ -132,18 +131,10 @@ module Sentry
132
131
  )
133
132
  end
134
133
 
135
- # Extract the trace_id, parent_span_id and parent_sampled values from a sentry-trace header.
136
- #
137
- # @param sentry_trace [String] the sentry-trace header value from the previous transaction.
134
+ # @deprecated Use Sentry::PropagationContext.extract_sentry_trace instead.
138
135
  # @return [Array, nil]
139
136
  def self.extract_sentry_trace(sentry_trace)
140
- match = SENTRY_TRACE_REGEXP.match(sentry_trace)
141
- return nil if match.nil?
142
-
143
- trace_id, parent_span_id, sampled_flag = match[1..3]
144
- parent_sampled = sampled_flag.nil? ? nil : sampled_flag != "0"
145
-
146
- [trace_id, parent_span_id, parent_sampled]
137
+ PropagationContext.extract_sentry_trace(sentry_trace)
147
138
  end
148
139
 
149
140
  # @return [Hash]
@@ -323,6 +314,7 @@ module Sentry
323
314
  items = {
324
315
  "trace_id" => trace_id,
325
316
  "sample_rate" => effective_sample_rate&.to_s,
317
+ "sampled" => sampled&.to_s,
326
318
  "environment" => @environment,
327
319
  "release" => @release,
328
320
  "public_key" => @dsn&.public_key
@@ -8,9 +8,6 @@ module Sentry
8
8
  # @return [<Array[Span]>]
9
9
  attr_accessor :spans
10
10
 
11
- # @return [Hash, nil]
12
- attr_accessor :dynamic_sampling_context
13
-
14
11
  # @return [Hash]
15
12
  attr_accessor :measurements
16
13
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sentry
4
- VERSION = "5.10.0"
4
+ VERSION = "5.11.0"
5
5
  end
data/lib/sentry-ruby.rb CHANGED
@@ -489,6 +489,42 @@ module Sentry
489
489
  Scope.add_global_event_processor(&block)
490
490
  end
491
491
 
492
+ # Returns the traceparent (sentry-trace) header for distributed tracing.
493
+ # Can be either from the currently active span or the propagation context.
494
+ #
495
+ # @return [String, nil]
496
+ def get_traceparent
497
+ return nil unless initialized?
498
+ get_current_hub.get_traceparent
499
+ end
500
+
501
+ # Returns the baggage header for distributed tracing.
502
+ # Can be either from the currently active span or the propagation context.
503
+ #
504
+ # @return [String, nil]
505
+ def get_baggage
506
+ return nil unless initialized?
507
+ get_current_hub.get_baggage
508
+ end
509
+
510
+ # Returns the a Hash containing sentry-trace and baggage.
511
+ # Can be either from the currently active span or the propagation context.
512
+ #
513
+ # @return [Hash, nil]
514
+ def get_trace_propagation_headers
515
+ return nil unless initialized?
516
+ get_current_hub.get_trace_propagation_headers
517
+ end
518
+
519
+ # Continue an incoming trace from a rack env like hash.
520
+ #
521
+ # @param env [Hash]
522
+ # @return [Transaction, nil]
523
+ def continue_trace(env, **options)
524
+ return nil unless initialized?
525
+ get_current_hub.continue_trace(env, **options)
526
+ end
527
+
492
528
  ##### Helpers #####
493
529
 
494
530
  # @!visibility private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-ruby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.10.0
4
+ version: 5.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-04 00:00:00.000000000 Z
11
+ date: 2023-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sentry-ruby
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.10.0
19
+ version: 5.11.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.10.0
26
+ version: 5.11.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: concurrent-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +86,7 @@ files:
86
86
  - lib/sentry/logger.rb
87
87
  - lib/sentry/net/http.rb
88
88
  - lib/sentry/profiler.rb
89
+ - lib/sentry/propagation_context.rb
89
90
  - lib/sentry/puma.rb
90
91
  - lib/sentry/rack.rb
91
92
  - lib/sentry/rack/capture_exceptions.rb