sentry-rust
sentry-rust copied to clipboard
Expose span fields through FieldVisitor
Hi, in Sentry we define the FieldVisitor here in the extract_span_data, and used it here in the on_new_span for the sentry layer, the data of the tracing span is directly written into sentry Span, which does not expose these data at all. Can we make this customizable to be able to read certain data from span?
Thank you!
@loewenheim Hi, thanks for responding quickly! Do you think it is possible to simply bump extract_span_data to public? or to quickly add some getters for the inner data of sentry_span? Thanks!
For your use case, is it sufficient to get access to the data individually by key or do you need to be able to see the whole map at once?
I have devised a solution, would this work for you? https://github.com/getsentry/sentry-rust/pull/548
Hi @loewenheim thank you so much for such a quick change!! Yes I would love to access the data through key. A quick dumb question: what's the best way of getting this span in the event_mapping filter on sentry layer? Thank you!
Hi @loewenheim following up my question above. I am trying to fetch the sentry span in eventMapper, where I can only get the SpanRef, I thought the sentry span should be inside extension, but it is not. Can you help to understand the correct way to do it? Thanks a lot!!
I'll get back to you as soon as I can.
I think I have to pass this on to one of my colleagues. @swatinem or @jan-auer, can you weigh in?
So you are trying to access the current span from within the configured event_mapper? https://docs.rs/sentry/latest/sentry/integrations/tracing/struct.SentryLayer.html#method.event_mapper
I don’t think there is a straight forward way right now. You can maybe use a configure_scope call to get the current span/transaction:
if let Some(span) = sentry::configure_scope(|scope| scope.get_span()) {
// ...
}