Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 4bb8d62

Browse files
committed
more docs, extra traceID field for CandidateHash as extra tag
1 parent 9e123e7 commit 4bb8d62

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

Cargo.lock

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/jaeger/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ impl Jaeger {
148148
Ok(())
149149
}
150150

151+
/// Create a span, but defer the evaluation/transformation into a `TraceIdentifier`.
152+
///
153+
/// The deferal allows to avoid the additional CPU runtime cost in case of
154+
/// items that are not a pre-computed hash by themselves.
151155
pub(crate) fn span<F>(&self, lazy_hash: F, span_name: &'static str) -> Option<mick_jaeger::Span>
152156
where
153157
F: Fn() -> TraceIdentifier,

node/jaeger/src/spans.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,21 @@ impl LazyIdent for CandidateHash {
238238

239239
fn extra_tags(&self, span: &mut Span) {
240240
span.add_string_fmt_debug_tag("candidate-hash", &self.0);
241+
// A convenience for usage with the grafana tempo UI,
242+
// not a technical requirement. It merely provides an easy anchor
243+
// where the true trace identifier of the span is not based on
244+
// a candidate hash (which it should be!), but is required to
245+
// continue investigating.
246+
span.add_string_tag("traceID", self.eval().to_string());
241247
}
242248
}
243249

244250
impl Span {
245251
/// Creates a new span builder based on anything that can be lazily evaluated
246252
/// to and identifier.
253+
///
254+
/// Attention: The primary identifier will be used for identification
255+
/// and as such should be
247256
pub fn new<I: LazyIdent>(identifier: I, span_name: &'static str) -> Span {
248257
let mut span = INSTANCE
249258
.read_recursive()
@@ -479,7 +488,7 @@ mod tests {
479488
fn extra_tags_do_not_change_trace_id() {
480489
Jaeger::test_setup();
481490
let candidate_hash = dbg!(Hash::from(&RAW));
482-
let trace_id = dbg!(hash_to_identifier(candidate_hash));
491+
let trace_id = hash_to_identifier(candidate_hash);
483492

484493
let span = Span::new(candidate_hash, "foo");
485494

0 commit comments

Comments
 (0)