Skip to content

Commit

Permalink
Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py committed Aug 16, 2023
1 parent 0afa9a3 commit 23a4d06
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
config.trace_propagation_targets = [/.*/] # default is to all targets
config.trace_propagation_targets = [/example.com/, 'foobar.org/api/v2']
```
- Tracing without Performance
- Implement `PropagationContext` on `Scope` and add `Sentry.get_trace_propagation_headers` API [#2084](https://github.com/getsentry/sentry-ruby/pull/2084)

The SDK now supports connecting arbitrary events (Errors / Transactions / Replays) across distributed services and not just Transactions.
To continue an incoming trace starting with this version of the SDK, use `Sentry.continue_trace` as follows.

```rb
# rack application
def call(env)
transaction = Sentry.continue_trace(env, name: 'transaction', op: 'op')
Sentry.start_transaction(transaction: transaction)
end
```

To inject headers into outgoing requests, use `Sentry.get_trace_propagation_headers` to get a hash of headers to add to your request.

## 5.10.0

Expand Down
13 changes: 9 additions & 4 deletions sentry-ruby/lib/sentry/hub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,15 @@ def get_baggage
def get_trace_propagation_headers
return nil unless configuration.propagate_traces

Check warning on line 247 in sentry-ruby/lib/sentry/hub.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/hub.rb#L247

Added line #L247 was not covered by tests

{
SENTRY_TRACE_HEADER_NAME => get_traceparent,
BAGGAGE_HEADER_NAME => get_baggage
}.compact
headers = {}

Check warning on line 249 in sentry-ruby/lib/sentry/hub.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/hub.rb#L249

Added line #L249 was not covered by tests

traceparent = get_traceparent
headers[SENTRY_TRACE_HEADER_NAME] = traceparent if traceparent

Check warning on line 252 in sentry-ruby/lib/sentry/hub.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/hub.rb#L251-L252

Added lines #L251 - L252 were not covered by tests

baggage = get_baggage
headers[BAGGAGE_HEADER_NAME] = baggage if baggage && !baggage.empty?

Check warning on line 255 in sentry-ruby/lib/sentry/hub.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/hub.rb#L254-L255

Added lines #L254 - L255 were not covered by tests

headers

Check warning on line 257 in sentry-ruby/lib/sentry/hub.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/hub.rb#L257

Added line #L257 was not covered by tests
end

private
Expand Down
10 changes: 5 additions & 5 deletions sentry-ruby/lib/sentry/net/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def request(req, body = nil, &block)

Sentry.with_child_span(op: OP_NAME, start_timestamp: Sentry.utc_now.to_f) do |sentry_span|
request_info = extract_request_info(req)
set_propagation_headers(req, request_info)

if propagate_trace?(request_info[:url], Sentry.configuration.trace_propagation_targets)
set_propagation_headers(req)

Check warning on line 36 in sentry-ruby/lib/sentry/net/http.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/net/http.rb#L35-L36

Added lines #L35 - L36 were not covered by tests
end

super.tap do |res|
record_sentry_breadcrumb(request_info, res)
Expand All @@ -49,10 +52,7 @@ def request(req, body = nil, &block)

private

def set_propagation_headers(req, request_info)
client = Sentry.get_current_client
return unless propagate_trace?(request_info[:url], client.configuration.trace_propagation_targets)

def set_propagation_headers(req)
Sentry.get_trace_propagation_headers&.each { |k, v| req[k] = v }

Check warning on line 56 in sentry-ruby/lib/sentry/net/http.rb

View check run for this annotation

Codecov / codecov/patch

sentry-ruby/lib/sentry/net/http.rb#L56

Added line #L56 was not covered by tests
end

Expand Down

0 comments on commit 23a4d06

Please sign in to comment.