mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
carry service_name and attrs when building resources objects
This commit is contained in:
parent
dff5c9668e
commit
135dc327b3
2 changed files with 18 additions and 12 deletions
|
|
@ -6,22 +6,28 @@ type t =
|
|||
| R_spans of Trace.resource_spans list
|
||||
| R_logs of Logs.resource_logs list
|
||||
|
||||
let of_logs logs : t = R_logs [ Util_resources.make_resource_logs logs ]
|
||||
|
||||
open struct
|
||||
let of_x_or_empty ~f l =
|
||||
let of_x_or_empty ?service_name ?attrs ~f l =
|
||||
if l = [] then
|
||||
[]
|
||||
else
|
||||
[ f l ]
|
||||
[ f ?service_name ?attrs l ]
|
||||
end
|
||||
|
||||
let of_logs_or_empty logs = of_x_or_empty ~f:of_logs logs
|
||||
let of_logs ?service_name ?attrs logs : t =
|
||||
R_logs [ Util_resources.make_resource_logs ?service_name ?attrs logs ]
|
||||
|
||||
let of_spans spans : t = R_spans [ Util_resources.make_resource_spans spans ]
|
||||
let of_logs_or_empty ?service_name ?attrs logs =
|
||||
of_x_or_empty ?service_name ?attrs ~f:of_logs logs
|
||||
|
||||
let of_spans_or_empty spans = of_x_or_empty ~f:of_spans spans
|
||||
let of_spans ?service_name ?attrs spans : t =
|
||||
R_spans [ Util_resources.make_resource_spans ?service_name ?attrs spans ]
|
||||
|
||||
let of_metrics m : t = R_metrics [ Util_resources.make_resource_metrics m ]
|
||||
let of_spans_or_empty ?service_name ?attrs spans =
|
||||
of_x_or_empty ?service_name ?attrs ~f:of_spans spans
|
||||
|
||||
let of_metrics_or_empty ms = of_x_or_empty ~f:of_metrics ms
|
||||
let of_metrics ?service_name ?attrs m : t =
|
||||
R_metrics [ Util_resources.make_resource_metrics ?service_name ?attrs m ]
|
||||
|
||||
let of_metrics_or_empty ?service_name ?attrs ms =
|
||||
of_x_or_empty ?service_name ?attrs ~f:of_metrics ms
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
open Common_
|
||||
|
||||
let make_resource_logs (logs : Proto.Logs.log_record list) :
|
||||
Proto.Logs.resource_logs =
|
||||
let attributes = OTEL.Globals.mk_attributes () in
|
||||
let make_resource_logs ?service_name ?attrs (logs : Proto.Logs.log_record list)
|
||||
: Proto.Logs.resource_logs =
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue