mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
test
This commit is contained in:
parent
5ef84a46c4
commit
49ca5bee2b
2 changed files with 261 additions and 0 deletions
|
|
@ -121,3 +121,216 @@ res1: { resource = None;
|
||||||
];
|
];
|
||||||
schema_url = "";(* absent *)
|
schema_url = "";(* absent *)
|
||||||
}
|
}
|
||||||
|
trace size: 371B
|
||||||
|
trace1: { resource = None;
|
||||||
|
scope_spans =
|
||||||
|
[{ scope = None;
|
||||||
|
spans =
|
||||||
|
[{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=0>;(* absent *)
|
||||||
|
name = "sp1";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 10;
|
||||||
|
end_time_unix_nano = 15;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp2";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 20;
|
||||||
|
end_time_unix_nano = 25;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp3";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 30;
|
||||||
|
end_time_unix_nano = 35;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp4";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 40;
|
||||||
|
end_time_unix_nano = 45;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp5";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 50;
|
||||||
|
end_time_unix_nano = 55;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp6";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 60;
|
||||||
|
end_time_unix_nano = 65;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
schema_url = "";(* absent *)
|
||||||
|
}
|
||||||
|
];
|
||||||
|
schema_url = "";(* absent *)
|
||||||
|
}
|
||||||
|
trace2: { resource = None;
|
||||||
|
scope_spans =
|
||||||
|
[{ scope = None;
|
||||||
|
spans =
|
||||||
|
[{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=0>;(* absent *)
|
||||||
|
name = "sp1";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 10;
|
||||||
|
end_time_unix_nano = 15;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp2";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 20;
|
||||||
|
end_time_unix_nano = 25;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp3";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 30;
|
||||||
|
end_time_unix_nano = 35;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp4";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 40;
|
||||||
|
end_time_unix_nano = 45;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp5";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 50;
|
||||||
|
end_time_unix_nano = 55;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
};
|
||||||
|
{ trace_id = <bytes len=16>;
|
||||||
|
span_id = <bytes len=8>;
|
||||||
|
trace_state = "";(* absent *)
|
||||||
|
parent_span_id = <bytes len=8>;
|
||||||
|
name = "sp6";
|
||||||
|
kind = Span_kind_unspecified;(* absent *)
|
||||||
|
start_time_unix_nano = 60;
|
||||||
|
end_time_unix_nano = 65;
|
||||||
|
attributes = [];
|
||||||
|
dropped_attributes_count = 0;(* absent *)
|
||||||
|
events = [];
|
||||||
|
dropped_events_count = 0;(* absent *)
|
||||||
|
links = [];
|
||||||
|
dropped_links_count = 0;(* absent *)
|
||||||
|
status = None;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
schema_url = "";(* absent *)
|
||||||
|
}
|
||||||
|
];
|
||||||
|
schema_url = "";(* absent *)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,3 +37,51 @@ let () =
|
||||||
Format.printf "res1: %a@." Proto.Metrics.pp_resource_metrics res1;
|
Format.printf "res1: %a@." Proto.Metrics.pp_resource_metrics res1;
|
||||||
Format.printf "res1: %a@." Proto.Metrics.pp_resource_metrics res2;
|
Format.printf "res1: %a@." Proto.Metrics.pp_resource_metrics res2;
|
||||||
()
|
()
|
||||||
|
|
||||||
|
(* traces *)
|
||||||
|
|
||||||
|
let trace1 : Proto.Trace.resource_spans =
|
||||||
|
let span_id = Span_id.dummy |> Span_id.to_bytes in
|
||||||
|
let trace_id = Trace_id.dummy |> Trace_id.to_bytes in
|
||||||
|
Proto.Trace.make_resource_spans
|
||||||
|
~scope_spans:
|
||||||
|
[
|
||||||
|
Proto.Trace.make_scope_spans
|
||||||
|
~spans:
|
||||||
|
[
|
||||||
|
Proto.Trace.make_span ~trace_id ~span_id ~name:"sp1"
|
||||||
|
~start_time_unix_nano:10L ~end_time_unix_nano:15L ~events:[]
|
||||||
|
~links:[] ~attributes:[] ();
|
||||||
|
Proto.Trace.make_span ~trace_id ~span_id ~name:"sp2"
|
||||||
|
~start_time_unix_nano:20L ~end_time_unix_nano:25L ~events:[]
|
||||||
|
~links:[] ~attributes:[] ~parent_span_id:span_id ();
|
||||||
|
Proto.Trace.make_span ~trace_id ~span_id ~name:"sp3"
|
||||||
|
~start_time_unix_nano:30L ~end_time_unix_nano:35L ~events:[]
|
||||||
|
~links:[] ~attributes:[] ~parent_span_id:span_id ();
|
||||||
|
Proto.Trace.make_span ~trace_id ~span_id ~name:"sp4"
|
||||||
|
~start_time_unix_nano:40L ~end_time_unix_nano:45L ~events:[]
|
||||||
|
~links:[] ~attributes:[] ~parent_span_id:span_id ();
|
||||||
|
Proto.Trace.make_span ~trace_id ~span_id ~name:"sp5"
|
||||||
|
~start_time_unix_nano:50L ~end_time_unix_nano:55L ~events:[]
|
||||||
|
~links:[] ~attributes:[] ~parent_span_id:span_id ();
|
||||||
|
Proto.Trace.make_span ~trace_id ~span_id ~name:"sp6"
|
||||||
|
~start_time_unix_nano:60L ~end_time_unix_nano:65L ~events:[]
|
||||||
|
~links:[] ~attributes:[] ~parent_span_id:span_id ();
|
||||||
|
]
|
||||||
|
();
|
||||||
|
]
|
||||||
|
()
|
||||||
|
|
||||||
|
let str =
|
||||||
|
let enc = Pbrt.Encoder.create () in
|
||||||
|
Proto.Trace.encode_pb_resource_spans trace1 enc;
|
||||||
|
Pbrt.Encoder.to_string enc
|
||||||
|
|
||||||
|
let () = Printf.printf "trace size: %dB\n" (String.length str)
|
||||||
|
|
||||||
|
let () =
|
||||||
|
let dec = Pbrt.Decoder.of_string str in
|
||||||
|
let trace2 = Proto.Trace.decode_pb_resource_spans dec in
|
||||||
|
Format.printf "trace1: %a@." Proto.Trace.pp_resource_spans trace1;
|
||||||
|
Format.printf "trace2: %a@." Proto.Trace.pp_resource_spans trace2;
|
||||||
|
()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue