-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
@@ -124,6 +124,10 @@ pub struct Data { | |||
#[derive(Clone, Debug, PartialEq, Eq, Hash)] | |||
pub struct Id(u64); | |||
|
|||
pub trait AsId { | |||
fn as_id(&self) -> Option<Id>; |
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.
Abstracts over anything that may have a span ID, so we can add a follows-from annotation from a Span
handle, an Id
, and so on. I was hoping there was a trait in the standard library that could be used here, but this seemed simpler.
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.
Yeah, I guess this depends on rust-lang/rust#33417 landing.
tokio-trace/src/subscriber.rs
Outdated
@@ -38,6 +38,8 @@ pub trait Subscriber { | |||
value: &dyn IntoValue, | |||
) -> Result<(), AddValueError>; | |||
|
|||
fn add_follows_from(&self, span: &span::Id, follows: span::Id); |
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.
Should this return an error if the span corresponding to that ID doesn't exist, like how add_value
does?
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.
Yes, I think so. I can imagine two types of subscribers:
- Subscribers that do care whether a span corresponds to that ID doesn't exist. An example might be a profiler like pprof or hawktracer.
- Subscribers that don't care whether a span corresponds to that ID doesn't exist. An example might be a metrics emission system.
A metrics emission system could just ignore the error, but an implementer of a profiler might be frustrated if they don't get an error when calling this method. Introducing an error down the line would be a breaking error, so I'd opt for an error that can be ignored now.
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.
Yeah, that's reasonable. Good point.
tokio-trace/src/subscriber.rs
Outdated
@@ -38,6 +38,8 @@ pub trait Subscriber { | |||
value: &dyn IntoValue, | |||
) -> Result<(), AddValueError>; | |||
|
|||
fn add_follows_from(&self, span: &span::Id, follows: span::Id); |
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.
Taking the ID of the span to annotate by-reference may not really be necessary...
|
||
/// Queries the registry for an iterator over the IDs of the spans that | ||
/// `span` follows from. | ||
fn get_follows_from(&self, span: &Id) -> Self::FollowsFrom; |
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.
Are there other ways of querying these relationships that ought to be part of the registry API?
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.
Should the subscriber interface also have a similar function? I kept it out because I didn't want to add too many more methods to that trait...
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.
Are there other ways of querying these relationships that ought to be part of the registry API?
I'm thinking the follows_from
family of methods should be named succeeds
/proceeds
to more clearly delineate ordering. Alternatively—and this might be a infeasible—but a PartialOrd
implementation could be helpful.
Should the subscriber interface also have a similar function? I kept it out because I didn't want to add too many more methods to that trait.
No, probably not, but I can be convinced otherwise.
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.
I'm thinking the
follows_from
family of methods should be namedsucceeds
/proceeds
to more clearly delineate ordering.
That's reasonable --- this naming is per tokio-rs/tokio#561 (comment), but I'm open to renaming it. I'm not sure how I feel about succeeds
here, though, since that seems easy to confuse with a notion of success/failure...
Alternatively—and this might be a infeasible—but a
PartialOrd
implementation could be helpful.
Having something like this would certainly be ergonomic, but I don't think it's immediately possible in the current scheme --- it's the subscriber that knows these relationships, not the spans themselves. That said, I'll keep thinking about the potential of doing that.
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.
That's reasonable --- this naming is per tokio-rs/tokio#561 (comment), but I'm open to renaming it. I'm not sure how I feel about succeeds here, though, since that seems easy to confuse with a notion of success/failure...
True. What about “prior/subsequent?”
Having something like this would certainly be ergonomic, but I don't think it's immediately possible in the current scheme --- it's the subscriber that knows these relationships, not the spans themselves. That said, I'll keep thinking about the potential of doing that.
Good point, didn't consider that that part.
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.
That's reasonable --- this naming is per tokio-rs/tokio#561 (comment), but I'm open to renaming it. I'm not sure how I feel about succeeds here, though, since that seems easy to confuse with a notion of success/failure...
True. What about “prior/subsequent?”
That works for me!
[...] I don't think it's immediately possible in the current scheme --- it's the subscriber that knows these relationships, not the spans themselves.
Good point, didn't consider that that part.
I am considering changing the SpanRef
type in the tokio-trace-subscriber
crate to have a reference back to the registry for querying it to get span data, so it may be possible to implement something like that for SpanRef
s in the more batteries-included crate...but that'll be its own branch.
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.
Left some comments that aren't blocking, but might be useful directions to explore.
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
40edea6
to
620924a
Compare
There is one other potential concern that comes to mind here: namely, how should the similar follows-from annotations for events be handled? Do we want each one to correspond to an The former would be more consistent with spans, but it also introduces some additional complexity --- currently, there isn't a way to refer to an event that's already occurred (there's no event ID type), and the |
@davidbarsky I think I've addressed all your feedback --- any other concerns? |
No other concerns.
…On Thu, Oct 25, 2018 at 5:34 PM Eliza Weisman ***@***.***> wrote:
@davidbarsky <https://github.com/davidbarsky> I think I've addressed all
your feedback --- any other concerns?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#49 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB-NPjsCa9Ywc4emJ3Sx5seLlh23cmsOks5uoi55gaJpZM4X5QVc>
.
|
This branch adds
Subscriber
andSpan
methods for annotating spanswith prior spans from which they follow. For the most part, this branch
doesn't add implementations of this interface for now, besides proxying
to it in composite subscribers.
It would be good to get a review of the interface before getting too deep
into implementation.
Signed-off-by: Eliza Weisman eliza@buoyant.io