Skip to content

Commit

Permalink
Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py committed Aug 28, 2023
1 parent 143cf28 commit 7c3bbbb
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 @@ -11,6 +11,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.

### Bug Fixes

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 7c3bbbb

Please sign in to comment.