update mick jaeger and add some sanity unit tests (#5067)

* test: verify identifier generation is correct in jaeger

* bump mick jaeger to 0.1.8

Fixes the trace endianness issue.

* more docs, extra traceID field for CandidateHash as extra tag

* chore: spellcheck

* fix assert statement
This commit is contained in:
Bernhard Schuster
2022-03-10 18:25:54 +01:00
committed by GitHub
parent 3a11be1683
commit 9369dd3384
4 changed files with 86 additions and 3 deletions
+19
View File
@@ -92,6 +92,21 @@ impl Jaeger {
Ok(())
}
/// Provide a no-thrills test setup helper.
#[cfg(test)]
pub fn test_setup() {
let mut instance = INSTANCE.write();
match *instance {
Self::Launched { .. } => {},
_ => {
let (traces_in, _traces_out) = mick_jaeger::init(mick_jaeger::Config {
service_name: "polkadot-jaeger-test".to_owned(),
});
*instance = Self::Launched { traces_in };
},
}
}
/// Spawn the background task in order to send the tracing information out via UDP
#[cfg(not(target_os = "unknown"))]
pub fn launch<S: SpawnNamed>(self, spawner: S) -> result::Result<(), JaegerError> {
@@ -133,6 +148,10 @@ impl Jaeger {
Ok(())
}
/// Create a span, but defer the evaluation/transformation into a `TraceIdentifier`.
///
/// The deferral allows to avoid the additional CPU runtime cost in case of
/// items that are not a pre-computed hash by themselves.
pub(crate) fn span<F>(&self, lazy_hash: F, span_name: &'static str) -> Option<mick_jaeger::Span>
where
F: Fn() -> TraceIdentifier,