mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
feat: add runtime/otel-specific name and version modifiable
this way we can mock them in tests, but we can also change the name "ocaml-otel" to something else, e.g. if we have specific conventions.
This commit is contained in:
parent
ea1c6ba0f5
commit
d9362ae788
5 changed files with 18 additions and 6 deletions
|
|
@ -7,7 +7,8 @@ let make_resource_logs ?service_name ?attrs (logs : Proto.Logs.log_record list)
|
|||
let attributes = OTEL.Globals.mk_attributes ?service_name ?attrs () in
|
||||
let resource = Proto.Resource.make_resource ~attributes () in
|
||||
let ll =
|
||||
Proto.Logs.make_scope_logs ~scope:OTEL.Globals.instrumentation_library
|
||||
Proto.Logs.make_scope_logs
|
||||
~scope:(OTEL.Globals.instrumentation_library ())
|
||||
~log_records:logs ()
|
||||
in
|
||||
Proto.Logs.make_resource_logs ~resource ~scope_logs:[ ll ] ()
|
||||
|
|
@ -15,7 +16,8 @@ let make_resource_logs ?service_name ?attrs (logs : Proto.Logs.log_record list)
|
|||
let make_resource_spans ?service_name ?attrs spans : Proto.Trace.resource_spans
|
||||
=
|
||||
let ils =
|
||||
Proto.Trace.make_scope_spans ~scope:OTEL.Globals.instrumentation_library
|
||||
Proto.Trace.make_scope_spans
|
||||
~scope:(OTEL.Globals.instrumentation_library ())
|
||||
~spans ()
|
||||
in
|
||||
let attributes = OTEL.Globals.mk_attributes ?service_name ?attrs () in
|
||||
|
|
@ -27,7 +29,9 @@ let make_resource_metrics ?service_name ?attrs (l : OTEL.Metrics.t list) :
|
|||
Proto.Metrics.resource_metrics =
|
||||
let open Proto.Metrics in
|
||||
let lm =
|
||||
make_scope_metrics ~scope:OTEL.Globals.instrumentation_library ~metrics:l ()
|
||||
make_scope_metrics
|
||||
~scope:(OTEL.Globals.instrumentation_library ())
|
||||
~metrics:l ()
|
||||
in
|
||||
let attributes = OTEL.Globals.mk_attributes ?service_name ?attrs () in
|
||||
let resource = Proto.Resource.make_resource ~attributes () in
|
||||
|
|
|
|||
|
|
@ -16,8 +16,14 @@ let service_instance_id = ref None
|
|||
@since 0.12 *)
|
||||
let service_version = ref None
|
||||
|
||||
let instrumentation_library =
|
||||
make_instrumentation_scope ~version:"%%VERSION_NUM%%" ~name:"ocaml-otel" ()
|
||||
let instrumentation_name = ref "ocaml-otel"
|
||||
|
||||
let instrumentation_runtime_version = ref "%%VERSION_NUM%%"
|
||||
|
||||
let instrumentation_library () =
|
||||
make_instrumentation_scope
|
||||
~version:!instrumentation_runtime_version
|
||||
~name:!instrumentation_name ()
|
||||
|
||||
(** Global attributes, initially set via OTEL_RESOURCE_ATTRIBUTES and modifiable
|
||||
by the user code. They will be attached to each outgoing metrics/traces. *)
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ let () =
|
|||
Sys.catch_break true;
|
||||
T.Globals.service_name := "t1";
|
||||
T.Globals.service_namespace := Some "ocaml-otel.test";
|
||||
T.Globals.instrumentation_runtime_version := "<fixed>";
|
||||
|
||||
let debug = ref false in
|
||||
let batch_traces = ref 400 in
|
||||
|
|
|
|||
|
|
@ -213,6 +213,7 @@ let tests params signal_batches =
|
|||
]
|
||||
|
||||
let run_tests ~port (cmds : _ list) : unit =
|
||||
Opentelemetry.Globals.instrumentation_runtime_version := "<fixed>";
|
||||
let suites =
|
||||
let open Lwt.Syntax in
|
||||
Lwt_main.run
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
[{ scope =
|
||||
Some(
|
||||
{ name = "ocaml-otel";
|
||||
version = "%%VERSION_NUM%%";
|
||||
version = "<fixed>";
|
||||
attributes = [];
|
||||
dropped_attributes_count = 0 (* absent *);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue