Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples clarifications #17

Open
marlon-sousa opened this issue May 4, 2021 · 2 comments
Open

Examples clarifications #17

marlon-sousa opened this issue May 4, 2021 · 2 comments

Comments

@marlon-sousa
Copy link

Hello,

Thanks for your work.

Being new to the whole eco system, I am still unsure how this library relates to others.

I like the idea of defining custom fields that can be filled at run time, but I am somewhat unsure about two questions I'd like to have clarified:

async fn personal_hello

  1. Inside this function, can I call info!, error! and others directly?
  2. In real life applications, this function will call other sync or async functions. If I need to call info!, error! from within that functions, what is going to happen? Do I have to pass the root_span around or just calling info! (etc) will work?
  3. what if this inner functions need to call .record to add yet more context they somehow acquire during request execution?

I will try to dig around on this library, but again it is kind of a puzzle where it is very hard to understand who is responsible for what, including all the async corner cases. If you could add this kind of information on the example this would be great to new members!

Thanks,
Marlon

@LukeMathWalker
Copy link
Owner

Those are extremely valid points @marlon-sousa!
I'll update the documentation to be clearer on each of those 😁

@marlon-sousa
Copy link
Author

Hello,

I have yet another question that I think would be valid to be addressed.

Because of diesel, I have to use a actix_web::web::block where I put the function calls that deal with database.

If some of these functions cause a panic, at first nothing is captured by tracing subscriber.

I then found a crate called tracing_unwrap, that is in fact sending the panic message to the subscriber, so that I have it logged nicely in JSON.

Issue is, though, that the contextual information that I recorded in the root span is not being sent together, so that I have all the standard otel fields, but not the extra fields I have recorded in my root span.
It would be really nice to know, again, how all these integrations work behind the walls.

Flow is as follows:

  1. root span is received in the async handler.
  2. Handler records a custom field (already initialized by the builder).
  3. Handler calls the execute function of GraphQLRequest of Juniper. This function is async.
  4. The resolver runs and calls one of my functions, also async. At this moment, I make a call tto info! inside my async function, and the log generated has the custom fields I recorded inside the handler.
  5. Soon after calling info! my function makes a actics_web::web::block and, inside that block, calls a sync function. The block call is awaited.
  6. The sync function calls another one, making an expect_or_log("error message")
  7. The error message is logged as expected, but the contextual information recorded in the root span is not recorded. Neither my specific field nor, apparently, other stuff such as request_id and others.

It would be really good if I could have some understanding of how these spans are passed abroad, because they are not injected into the functions as parameters, so something else has to be happening. I have been reading a lot of documentation but it seems for me that every time I got a response it brings fifty more unanswered questions.

Never thought the learning curve here would be so intense.

Thanks,
Marlon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants