Compare commits

..

No commits in common. "b92159c11e61dfa5c24c6c18feb868564b436c8f" and "c442f3b818c029ed57fcff3d19329e27373ae2bc" have entirely different histories.

8 changed files with 14 additions and 23 deletions

View file

@ -11,7 +11,7 @@
-open
Opentelemetry_atomic)
(libraries
(re_export opentelemetry.proto)
opentelemetry.proto
opentelemetry.util
(re_export opentelemetry.atomic)
(re_export opentelemetry.emitter)

View file

@ -16,15 +16,15 @@ type t = Metrics.metric
let pp = Proto.Metrics.pp_metric
(** Number data point, as a float *)
let float ?start_time_unix_nano ?(attrs = []) ?(now = Clock.now_main ())
let float ?start_time_unix_nano ?(attrs = []) ~(now : Timestamp_ns.t)
(d : float) : number_data_point =
let attributes = attrs |> List.map Key_value.conv in
make_number_data_point ?start_time_unix_nano ~time_unix_nano:now ~attributes
~value:(As_double d) ()
(** Number data point, as an int *)
let int ?start_time_unix_nano ?(attrs = []) ?(now = Clock.now_main ()) (i : int)
: number_data_point =
let int ?start_time_unix_nano ?(attrs = []) ~(now : Timestamp_ns.t) (i : int) :
number_data_point =
let attributes = attrs |> List.map Key_value.conv in
make_number_data_point ?start_time_unix_nano ~time_unix_nano:now ~attributes
~value:(As_int (Int64.of_int i))
@ -61,7 +61,7 @@ type histogram_data_point = Metrics.histogram_data_point
length 0)
@param explicit_bounds strictly increasing list of bounds for the buckets *)
let histogram_data_point ?start_time_unix_nano ?(attrs = []) ?(exemplars = [])
~explicit_bounds ?sum ?(now = Clock.now_main ()) ~bucket_counts ~count () :
~explicit_bounds ?sum ~(now : Timestamp_ns.t) ~bucket_counts ~count () :
histogram_data_point =
let attributes = attrs |> List.map Key_value.conv in
make_histogram_data_point ?start_time_unix_nano ~time_unix_nano:now

View file

@ -103,21 +103,17 @@ let add_event' self ev : unit =
let record_exception (self : t) (exn : exn) (bt : Printexc.raw_backtrace) : unit
=
if is_not_dummy self then (
let exn_msg = Printexc.to_string exn in
let ev =
Event.make "exception"
~attrs:
[
"exception.message", `String exn_msg;
"exception.message", `String (Printexc.to_string exn);
"exception.type", `String (Printexc.exn_slot_name exn);
( "exception.stacktrace",
`String (Printexc.raw_backtrace_to_string bt) );
]
in
add_event self ev;
let status = make_status ~code:Status_code_error ~message:exn_msg () in
span_set_status self status
add_event self ev
)
let add_attrs (self : t) (attrs : Key_value.t list) : unit =

View file

@ -94,8 +94,6 @@ val add_event' : t -> (unit -> Event.t) -> unit
it if there is an instrumentation backend. *)
val record_exception : t -> exn -> Printexc.raw_backtrace -> unit
(** Record an exception occurring inside the span. This creates a span event
{b and} also sets the span status to error. *)
val add_links : t -> Span_link.t list -> unit

View file

@ -10,8 +10,6 @@ let dummy : t = { emit = Emitter.dummy; clock = Clock.ptime_clock }
let[@inline] enabled (self : t) = Emitter.enabled self.emit
let[@inline] emit self ms : unit = Emitter.emit self.emit ms
let[@inline] emit1 (self : t) (m : Metrics.t) : unit =
Emitter.emit self.emit [ m ]

View file

@ -21,9 +21,6 @@ val enabled : t -> bool
val of_exporter : Exporter.t -> t
(** Create a meter from an exporter *)
val emit : t -> Metrics.t list -> unit
(** Emit metrics directly, bypassing the instrument registry *)
val emit1 : t -> Metrics.t -> unit
(** Emit a single metric directly, bypassing the instrument registry *)

View file

@ -46,9 +46,6 @@ let get_meter ?name ?version ?(attrs : (string * [< Value.t ]) list = [])
(** Emit with current meter *)
let[@inline] emit (m : Metrics.t) : unit = Emitter.emit (get ()).emit [ m ]
(** Emit a list of metrics with current meter *)
let[@inline] emit_l (ms : Metrics.t list) : unit = Emitter.emit (get ()).emit ms
(** A Meter.t that lazily reads the global at emit time *)
let default_meter : Meter.t = get_meter ()

View file

@ -87,14 +87,19 @@ let with_thunk_and_finally (self : Tracer.t) ?(force_new_trace_id = false)
(* called once we're done, to emit a span *)
let finally res =
let end_time = Clock.now self.clock in
span_set_end_time_unix_nano span end_time;
Proto.Trace.span_set_end_time_unix_nano span end_time;
(match Span.status span with
| Some _ -> ()
| None ->
(match res with
| Ok () -> ()
| Error (e, bt) -> Span.record_exception span e bt));
| Error (e, bt) ->
Span.record_exception span e bt;
let status =
make_status ~code:Status_code_error ~message:(Printexc.to_string e) ()
in
Span.set_status span status));
Emitter.emit self.emit [ span ]
in