-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add support for typed task Labels. #138
Conversation
(discussed with Rajeev, posting here to not forget it / have an entry where it may be discussed) One thing which is lost from |
|
39df4fe
to
1d64b00
Compare
Summary of changes since the first reviewed version:
|
467b7b5
to
981d5e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just docs nits
[PR98](awslabs#98) added support for associated a single untyped `Tag` with each task and thread. As we've gained experience with Tags, we've increasingly felt a need to have a mechanism that is both better typed, and allows more than one tag to be associated with tasks. This commit introduces `Labels`, which are inspired by `Extensions` in [the http crate](https://docs.rs/http/latest/http/struct.Extensions.html). Users can attach any set of Labels to a task or thread, with the only caveat being that there can be at most one Label for a given type T. This is not too onerous a restriction, since one can use the common [newtype idiom](https://doc.rust-lang.org/rust-by-example/generics/new_types.html) to easily work around this. For tracing, we also provide a newtype `TaskName` that can be converted to and from a `String`. If the `TaskName` label is set for a task, tracing output will show the `TaskName` (in addition to the `TaskId`) to make logs easier to read. Since the current functionality provided by `Tag` is superseded by `Labels`, we also mark `Tag` as deprecated. They will be removed in a future release.
PR98 added support for associated a single untyped
Tag
with each task and thread. As we've gained experience with Tags, we've increasingly felt a need to have a mechanism that is both better typed, and allows more than one tag to be associated with tasks. This commit introducesLabels
, which are inspired byExtensions
in the http crate. Users can attach any set of Labels to a task or thread, with the only caveat being that there can be at most one Label for a given type T. This is not too onerous a restriction, since one can use the common newtype idiom to easily work around this.For tracing, we also provide a newtype
TaskName
that can be converted to and from aString
. If theTaskName
label is set for a task, tracing output will show theTaskName
(in addition to theTaskId
) to make logs easier to read.Since the current functionality provided by
Tag
is superseded byLabels
, we also markTag
as deprecated. They will be removed in a future release.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.