diff --git a/src/trace/opentelemetry_trace.ml b/src/trace/opentelemetry_trace.ml index a5251a70..e574cc9b 100644 --- a/src/trace/opentelemetry_trace.ml +++ b/src/trace/opentelemetry_trace.ml @@ -6,19 +6,30 @@ module Well_known = struct end let on_internal_error = ref (fun msg -> Printf.eprintf "error in Opentelemetry_trace: %s\n%!" msg) -type span_info = { - start_time: int64; - name: string; - scope: Otel.Scope.t; - parent: Otel.Span_ctx.t option; -} +module Extensions = struct + type span_info = { + start_time: int64; + name: string; + scope: Otel.Scope.t; + parent: Otel.Span_ctx.t option; + } -type Trace.span += Span_otel of span_info + let scope_of_span_info s = s.scope -type Trace.extension_event += - | Ev_link_span of Trace.span * Trace.span - | Ev_set_span_kind of Trace.span * Otel.Span_kind.t - | Ev_record_exn of Trace.span * exn * Printexc.raw_backtrace + type Trace.span += Span_otel of span_info + + type Trace.extension_event += + | Ev_link_span of Trace.span * Trace.span + | Ev_record_exn of Trace.span * exn * Printexc.raw_backtrace + | Ev_set_span_kind of Trace.span * Otel.Span_kind.t + + type Trace.metric += + | Metric_hist of Opentelemetry_proto.Metrics.histogram_data_point + | Metric_sum_int of int + | Metric_sum_float of float +end + +open Extensions module Internal = struct let enter_span' ?(parent_span : Trace.span option) ~__FUNCTION__ ~__FILE__ diff --git a/src/trace/opentelemetry_trace.mli b/src/trace/opentelemetry_trace.mli index 1e7e145e..b3b15192 100644 --- a/src/trace/opentelemetry_trace.mli +++ b/src/trace/opentelemetry_trace.mli @@ -19,12 +19,26 @@ module Otel := Opentelemetry module Otrace := Trace_core -type Otrace.extension_event += - | Ev_link_span of Otrace.span * Otrace.span - (** Link the two spans together. Both must be currently active spans. *) - | Ev_set_span_kind of Otrace.span * Otel.Span_kind.t - | Ev_record_exn of Otrace.span * exn * Printexc.raw_backtrace - (** Record exception and potentially turn span to an error *) +module Extensions : sig + type span_info + + val scope_of_span_info : span_info -> Otel.Scope.t + + type Otrace.span += Span_otel of span_info + + type Otrace.extension_event += + | Ev_link_span of Otrace.span * Otrace.span + (** Link the two spans together. Both must be currently active spans. + *) + | Ev_record_exn of Otrace.span * exn * Printexc.raw_backtrace + | Ev_set_span_kind of Otrace.span * Otel.Span_kind.t + (** Record exception and potentially turn span to an error *) + + type Otrace.metric += + | Metric_hist of Opentelemetry_proto.Metrics.histogram_data_point + | Metric_sum_int of int + | Metric_sum_float of float +end val on_internal_error : (string -> unit) ref (** Callback to print errors in the library itself (ie bugs) *)