util: change some layers to require recorders that are Sync
#538
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
Mentioned in #533, our recent change to require the global recorder to be
Sync
had a downstream effect for users taking advantage of certain layers likeFanout
andRouter
. This is due to the fact that those layers only require taking something that isRecorder
, which then is held as aBox<dyn Recorder>
.Solution
This PR updates
Fanout
andRouter
(and by extension, their builders,FanoutBuilder
andRouterBuilder
) to take recorders that areSync
, and then holds them asBox<dyn Recorder + Sync>
. This facilitates being able to once again use these layers as part of the global recorder.The original intent, before the change to require
Sync
in the global recorder, was always to have layers be usable for the global recorder, so this change is simply aligning these utilities to match.While there are areas where a
Sync
recorder is not required, such asmetrics::with_local_recorder
ormetrics::set_default_local_recorder
... they're much more rare and generally scoped to testing, where something likeDebuggingRecorder
is being used and there would be no reason to use a layer. If somehow it turns out that there's a need for non-Sync
layers for these use cases, we can address this by creatingUnsync
variants in the future.