-
Notifications
You must be signed in to change notification settings - Fork 11
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
V2 #3
V2 #3
Conversation
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 haven't reviewed everything yet, but here are a few notes on what i've looked at so far.
dist-tracing/src/telemetry_layer.rs
Outdated
let iter = itertools::unfold(Some(parent_id.clone()), |st| match st { | ||
Some(target_id) => { | ||
let res = ctx | ||
.span(target_id) | ||
.expect("span data not found during eval_ctx"); | ||
*st = res.parent().map(|x| x.id()); | ||
Some(res) | ||
} | ||
None => None, | ||
}); |
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.
seems like you could just use the existing SpanRef::parents
iterator for this:
let iter = ctx.span(id).iter().flat_map(|span| span.parents());
or something
dist-tracing/src/trace.rs
Outdated
@@ -0,0 +1,255 @@ | |||
use chrono::{DateTime, Utc}; |
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.
this whole module feels honeycomb-specific...I believe other distributed tracing systems have their own notions of trace and span IDs that might have different representations, and the format these are parsed from feels honeycomb-specific. what do you think about replacing the implementation in the dist-tracing
crate with an interface and moving this implementation to the honeycomb-tracing
crate?
I think the Telemetry
trait could have associated types defining IDs, something like
pub trait Telemetry {
type TraceId: Clone + Hash + Eq + FromStr + fmt::Display;
type SpanId: Clone + Hash + Eq + FromStr + fmt::Display;
// ...
}
or something?
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.
This is almost certainly the right thing to do, but it'll result in a small usability hit - I've been trying to keep the out-of-band functions (TraceCtx::new_root().record_on_current_span()
, TraceCtx::current_trace_ctx()
) free of type parameters.
I suppose it would be fine to export specialized wrapper functions from the honeycomb-tracing
crate, and to expect any other such crates to do so as well, and the small bit of extra boilerplate would be worth it for the added flexibility.
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.
update: implemented this
dist-tracing/src/telemetry_layer.rs
Outdated
// TODO: dedup | ||
let iter = itertools::unfold(Some(id.clone()), |st| match st { | ||
Some(target_id) => { | ||
let res = ctx | ||
.span(target_id) | ||
.expect("span data not found during eval_ctx"); | ||
*st = res.parent().map(|x| x.id()); | ||
Some(res) | ||
} | ||
None => None, | ||
}); |
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.
seems like this could be
let iter = span.parents();
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 code is a bit messy, but the iter I construct w/ unfold also includes the current span. I'm not sure how to modify this to use span.parents
, my intuition is to write something like
std::iter::once(span).chain(span.parents());
but that results in a move error:
error[E0382]: borrow of moved value: `span`
--> dist-tracing/src/telemetry_layer.rs:213:49
|
211 | let span = ctx.span(&id).expect("span data not found during on_close");
| ---- move occurs because `span` has type `tracing_subscriber::registry::SpanRef<'_, S>`, which does not implement the `Copy` trait
212 |
213 | let iter2 = std::iter::once(span).chain(span.parents());
| ---- ^^^^ value borrowed here after move
| |
| value moved here
let subscriber = telemetry_layer // publish to tracing | ||
.and_then(tracing_subscriber::fmt::Layer::builder().finish()) // log to stdout | ||
.and_then(LevelFilter::INFO) // omit low-level debug tracing (eg tokio executor) | ||
.and_then(LevelFilter::INFO) // filter out low-level debug tracing (eg tokio executor) | ||
.with_subscriber(registry::Registry::default()); // provide underlying span data store |
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.
Nit: I'd suggest writing this instead as:
let subscriber = registry::Registry::default() // provide underlying span data store
.with(LevelFilter::INFO) // filter out low-level debug tracing (eg tokio executor)
.with(tracing_subscriber::fmt::Layer::builder().finish()) // log to stdout
.with(telemetry_layer); // publish to tracing
It makes the hierarchy somewhat cleaner and closer to other frameworks.
- Relaxed dependency constraints. - Was included in 0.2.1-eaze.2 - Fixed a panic in case of multiple current callers. See [inanna-malick#3](eaze/tracing-honeycomb#3). - Was included in 0.2.1-eaze.3 - Added `parking_lot` feature. - Was included in 0.2.1-eaze.2
major changes, refactoring to use new tracing-subscriber tek