Skip to content

Is it possible to deduplicate data emitted in child spans? #2906

Answered by hawkw
jssblck asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately, there isn't really a way to do this automatically that doesn't introduce undesirable overhead --- something like storing all span fields in a hashmap so that we can skip formatting duplicates would have an unacceptable performance cost. When I have a nested call stack of functions that are all instrumented, I've occasionally factored out a private version of the shared code that isn't instrumented, to avoid duplicate spans.

For example, this:

#[instrument]
pub fn do_thing_with_stuff(thing: Thing, stuff: Stuff) { 
    do_thing(thing) 
    // ...
}

#[instrument]
pub fn do_thing(thing: Thing) {
   // ...
}

might become this:

#[instrument]
pub fn do_thing_with_stuff(thing: Thing,

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jssblck
Comment options

@hawkw
Comment options

Answer selected by jssblck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants