mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
small refactor
This commit is contained in:
parent
e0560ac730
commit
6e07d48d5d
1 changed files with 9 additions and 6 deletions
|
|
@ -2,14 +2,19 @@
|
||||||
|
|
||||||
open Common_
|
open Common_
|
||||||
|
|
||||||
|
open struct
|
||||||
|
let mk_resources ?service_name ?attrs () =
|
||||||
|
let attributes = OTEL.Globals.mk_attributes ?service_name ?attrs () in
|
||||||
|
Proto.Resource.make_resource ~attributes ()
|
||||||
|
end
|
||||||
|
|
||||||
let make_resource_logs ?service_name ?attrs (logs : Proto.Logs.log_record list)
|
let make_resource_logs ?service_name ?attrs (logs : Proto.Logs.log_record list)
|
||||||
: Proto.Logs.resource_logs =
|
: Proto.Logs.resource_logs =
|
||||||
let attributes = OTEL.Globals.mk_attributes ?service_name ?attrs () in
|
|
||||||
let resource = Proto.Resource.make_resource ~attributes () in
|
|
||||||
let ll =
|
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 ()
|
~log_records:logs ()
|
||||||
in
|
in
|
||||||
|
let resource = mk_resources ?service_name ?attrs () in
|
||||||
Proto.Logs.make_resource_logs ~resource ~scope_logs:[ ll ] ()
|
Proto.Logs.make_resource_logs ~resource ~scope_logs:[ ll ] ()
|
||||||
|
|
||||||
let make_resource_spans ?service_name ?attrs spans : Proto.Trace.resource_spans
|
let make_resource_spans ?service_name ?attrs spans : Proto.Trace.resource_spans
|
||||||
|
|
@ -18,8 +23,7 @@ let make_resource_spans ?service_name ?attrs spans : Proto.Trace.resource_spans
|
||||||
Proto.Trace.make_scope_spans ~scope:OTEL.Globals.instrumentation_library
|
Proto.Trace.make_scope_spans ~scope:OTEL.Globals.instrumentation_library
|
||||||
~spans ()
|
~spans ()
|
||||||
in
|
in
|
||||||
let attributes = OTEL.Globals.mk_attributes ?service_name ?attrs () in
|
let resource = mk_resources ?service_name ?attrs () in
|
||||||
let resource = Proto.Resource.make_resource ~attributes () in
|
|
||||||
Proto.Trace.make_resource_spans ~resource ~scope_spans:[ ils ] ()
|
Proto.Trace.make_resource_spans ~resource ~scope_spans:[ ils ] ()
|
||||||
|
|
||||||
(** Aggregate metrics into a {!Proto.Metrics.resource_metrics} *)
|
(** Aggregate metrics into a {!Proto.Metrics.resource_metrics} *)
|
||||||
|
|
@ -29,6 +33,5 @@ let make_resource_metrics ?service_name ?attrs (l : OTEL.Metrics.t list) :
|
||||||
let lm =
|
let lm =
|
||||||
make_scope_metrics ~scope:OTEL.Globals.instrumentation_library ~metrics:l ()
|
make_scope_metrics ~scope:OTEL.Globals.instrumentation_library ~metrics:l ()
|
||||||
in
|
in
|
||||||
let attributes = OTEL.Globals.mk_attributes ?service_name ?attrs () in
|
let resource = mk_resources ?service_name ?attrs () in
|
||||||
let resource = Proto.Resource.make_resource ~attributes () in
|
|
||||||
Proto.Metrics.make_resource_metrics ~scope_metrics:[ lm ] ~resource ()
|
Proto.Metrics.make_resource_metrics ~scope_metrics:[ lm ] ~resource ()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue