feat: add dep on hmap, add standard keys

This commit is contained in:
Simon Cruanes 2024-02-26 10:17:45 -05:00
parent 5b0bc6162e
commit 1cb53c3406
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
4 changed files with 13 additions and 1 deletions

View file

@ -27,6 +27,7 @@
(ocaml (ocaml
(>= "4.08")) (>= "4.08"))
ptime ptime
hmap
ambient-context ambient-context
(odoc :with-doc) (odoc :with-doc)
(alcotest :with-test) (alcotest :with-test)

View file

@ -16,6 +16,7 @@ depends: [
"dune" {>= "2.9"} "dune" {>= "2.9"}
"ocaml" {>= "4.08"} "ocaml" {>= "4.08"}
"ptime" "ptime"
"hmap"
"ambient-context" "ambient-context"
"odoc" {with-doc} "odoc" {with-doc}
"alcotest" {with-test} "alcotest" {with-test}

View file

@ -3,5 +3,5 @@
(synopsis "API for opentelemetry instrumentation") (synopsis "API for opentelemetry instrumentation")
(flags :standard -warn-error -a+8) (flags :standard -warn-error -a+8)
(libraries opentelemetry.proto ambient-context ptime ptime.clock.os pbrt threads (libraries opentelemetry.proto ambient-context ptime ptime.clock.os pbrt threads
opentelemetry.atomic) opentelemetry.atomic hmap)
(public_name opentelemetry)) (public_name opentelemetry))

View file

@ -326,6 +326,11 @@ end = struct
let pp fmt t = Format.fprintf fmt "%s" (to_hex t) let pp fmt t = Format.fprintf fmt "%s" (to_hex t)
end end
(** Hmap key to carry around a {!Trace_id.t}, to remember what the current
trace is.
@since NEXT_RELEASE *)
let k_trace_id : Trace_id.t Hmap.key = Hmap.Key.create ()
(** Unique ID of a span. *) (** Unique ID of a span. *)
module Span_id : sig module Span_id : sig
type t type t
@ -479,6 +484,11 @@ end = struct
| Error msg -> invalid_arg @@ spf "invalid w3c trace context: %s" msg | Error msg -> invalid_arg @@ spf "invalid w3c trace context: %s" msg
end end
(** Hmap key to carry around a {!Span_ctx.t}, e.g. to remember what the current
parent span is.
@since NEXT_RELEASE *)
let k_span_ctx : Span_ctx.t Hmap.key = Hmap.Key.create ()
(** {2 Attributes and conventions} *) (** {2 Attributes and conventions} *)
module Conventions = struct module Conventions = struct