Add sentry_trace connection example#1444
Conversation
- Parent: sentry-rails' example app - Child: sentry-ruby's sinatra example Usage: 1. `$ cd sentry-rails/examples/rails-6.0` 2. `$ bundle exec rails s` 3. `$ cd sentry-ruby/examples/sinatra` 4. `$ bundle exec ruby app.rb` 5. Visit `http://localhost:3000/connect_trace` in browser
rhcarvalho
left a comment
There was a problem hiding this comment.
Thanks for the example!
| uri = URI("http://localhost:4567/connect_trace") | ||
| http = Net::HTTP.new(uri.host, uri.port) | ||
| request = Net::HTTP::Get.new(uri.request_uri) | ||
| request["SENTRY_TRACE"] = transaction.to_sentry_trace |
There was a problem hiding this comment.
There was a problem hiding this comment.
I'm not aware of this requirement in the backend SDK 🤔 can you point me the implementation in sentry-python and sentry-go?
There was a problem hiding this comment.
Go doesn't have this yet (know limitation), and when we do it won't be like Python and Ruby because we can't monkey-patch libraries.
But the idea is that we automatically create spans for outgoing requests and propagate the trace header sentry-trace with information on the current span (the one that was just created for the request).
There was a problem hiding this comment.
@rhcarvalho I see, thanks. I'll merge this PR now and then implemented the propagation. after that's done I'll update the example again.
Usage:
$ cd sentry-rails/examples/rails-6.0$ bundle exec rails s$ cd sentry-ruby/examples/sinatra$ bundle exec ruby app.rbhttp://localhost:3000/connect_tracein browser