Tracing values (#6679)

* Switch to serde_json::Value for Visitor values

* add tests

* switch Visitor to use Map

* refactor change names

* \n

* update integration test

* use discrete maps for each type of recorded value

* update integration test

* add docs

* Update client/tracing/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* add docs

Co-authored-by: Matt Rutherford <mattrutherford@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
mattrutherford
2020-07-22 12:29:33 +01:00
committed by GitHub
parent 0feac04f36
commit c4dd079119
2 changed files with 151 additions and 39 deletions
@@ -661,17 +661,16 @@ fn parallel_execution(wasm_method: WasmExecutionMethod) {
fn wasm_tracing_should_work(wasm_method: WasmExecutionMethod) {
use std::sync::{Arc, Mutex};
use sc_tracing::SpanDatum;
struct TestTraceHandler(Arc<Mutex<Vec<SpanDatum>>>);
impl sc_tracing::TraceHandler for TestTraceHandler {
fn process_span(&self, sd: SpanDatum) {
fn handle_span(&self, sd: SpanDatum) {
self.0.lock().unwrap().push(sd);
}
}
struct TestTraceHandler(Arc<Mutex<Vec<SpanDatum>>>);
let traces = Arc::new(Mutex::new(Vec::new()));
let handler = TestTraceHandler(traces.clone());
@@ -749,9 +748,9 @@ fn wasm_tracing_should_work(wasm_method: WasmExecutionMethod) {
assert_eq!(len, 1);
let span_datum = traces.lock().unwrap().pop().unwrap();
let values = span_datum.values.into_inner();
let values = span_datum.values;
assert_eq!(span_datum.target, "integration_test_span_target");
assert_eq!(span_datum.name, "integration_test_span_name");
assert_eq!(values.get("wasm").unwrap(), "true");
assert_eq!(values.get("is_valid_trace").unwrap(), "true");
assert_eq!(values.bool_values.get("wasm").unwrap(), &true);
assert_eq!(values.bool_values.get("is_valid_trace").unwrap(), &true);
}