subscriber: use Span::record
for attribute updates
#264
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.
This PR switches to using
Span::record
for recording state updates onasync ops and resources as suggested in #246. The changes a bit the scheme
for naming attributes. Basically now fields that are recorded as state attributes
need to be defined on span creation and have the form of
state.field_name.unit
where the unit is optional. We then use
Span::record
to emit an update on this field.In order to express an update that is a delta we can use
state.field_name.delta
. Thisonly works for numeric fields.
The fact that we now need to know the attributes for a resource or an async op upfront
allows us to avoid resizing the map of attributes and using the mutex on it. However, it also
brings a complication around attribute inheritance. Basically, we use attribute inheritance for
resources and async ops to propagate the attributes of some private type like
batch_semaphore::Semaphore
to some other public type like theSemaphore
. This alsostands true for async ops of these resources. This allows us to instrument parent async
ops very easily by just doing this. Because now we need to know the set of fields upfront, it will
make this kind of instrumentation harder.
You can patch the tokio version with this branch to test.
Signed-off-by: Zahari Dichev [email protected]