Skip to content

Provide examples for async use of Hub #507

Open
@peterstuart

Description

@peterstuart

I recently had an issue (events/spans being recorded in the wrong places) which was caused by me not understanding that I needed to be manually cloning/creating Hubs and using bind_hub on futures which I was joining/spawning/etc. (See support request 72484 if you're interested). The docs do explain that, but:

  • I naively assumed that sentry-tracing would deal with that for me, since it already has the concepts of spans which work with futures
  • the docs are pretty light on details about exactly what I needed to do

I think it'd be helpful to provide an example in the repo of manually using bind_hub, and I think it might be worth linking to something about working with async code more prominently (the front page of the docs)?

I'm also not totally clear on exactly how to manually deal with Hubs. Should I be using Hub::new_from_top vs Hub::new, or just reusing Hub::current? (I don't understand what "the top scope of another hub" means in the docs for new_from_top.) Hub::new_from_top(Hub::current()) seems to be working the way I'd expect so far. 🤷🏻

Anyway, thanks for the great SDK. I'm very happy with how seamless it's been to use (especially with the tower and tracing integrations). Just thought I'd report the troubles I ran into.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions