mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
lwt library
This commit is contained in:
parent
097436f907
commit
aea549862b
4 changed files with 85 additions and 0 deletions
11
dune-project
11
dune-project
|
|
@ -20,6 +20,17 @@
|
|||
(tags
|
||||
(instrumentation tracing opentelemetry datadog jaeger)))
|
||||
|
||||
(package
|
||||
(name opentelemetry-lwt)
|
||||
(synopsis "Lwt-compatible instrumentation for https://opentelemetry.io")
|
||||
(depends
|
||||
(ocaml (>= "4.08"))
|
||||
(dune (>= "2.3"))
|
||||
(opentelemetry (= :version))
|
||||
lwt)
|
||||
(tags
|
||||
(instrumentation tracing opentelemetry datadog lwt)))
|
||||
|
||||
(package
|
||||
(name opentelemetry-client-ocurl)
|
||||
(depends
|
||||
|
|
|
|||
32
opentelemetry-lwt.opam
Normal file
32
opentelemetry-lwt.opam
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# This file is generated by dune, edit dune-project instead
|
||||
opam-version: "2.0"
|
||||
synopsis: "Lwt-compatible instrumentation for https://opentelemetry.io"
|
||||
maintainer: ["the Imandra team"]
|
||||
authors: ["the Imandra team"]
|
||||
license: "MIT"
|
||||
tags: ["instrumentation" "tracing" "opentelemetry" "datadog" "lwt"]
|
||||
homepage: "https://github.com/aestheticintegration/ocaml-opentelemetry"
|
||||
bug-reports:
|
||||
"https://github.com/aestheticintegration/ocaml-opentelemetry/issues"
|
||||
depends: [
|
||||
"ocaml" {>= "4.08"}
|
||||
"dune" {>= "2.3"}
|
||||
"opentelemetry" {= version}
|
||||
"lwt"
|
||||
]
|
||||
build: [
|
||||
["dune" "subst"] {pinned}
|
||||
[
|
||||
"dune"
|
||||
"build"
|
||||
"-p"
|
||||
name
|
||||
"-j"
|
||||
jobs
|
||||
"@install"
|
||||
"@runtest" {with-test}
|
||||
"@doc" {with-doc}
|
||||
]
|
||||
]
|
||||
dev-repo:
|
||||
"git+https://github.com/aestheticintegration/ocaml-opentelemetry.git"
|
||||
5
src/lwt/dune
Normal file
5
src/lwt/dune
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(library
|
||||
(name opentelemetry_lwt)
|
||||
(public_name opentelemetry-lwt)
|
||||
(synopsis "Lwt frontend for opentelemetry")
|
||||
(libraries lwt opentelemetry))
|
||||
37
src/lwt/opentelemetry_lwt.ml
Normal file
37
src/lwt/opentelemetry_lwt.ml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
open Opentelemetry
|
||||
|
||||
module Span_id = Span_id
|
||||
module Trace_id = Trace_id
|
||||
module Span = Span
|
||||
|
||||
module Trace = struct
|
||||
open Proto.Trace
|
||||
include Trace
|
||||
|
||||
(** Emit asynchronously *)
|
||||
let emit (spans:span list) : unit Lwt.t =
|
||||
let fut, wake = Lwt.wait() in
|
||||
let ils =
|
||||
default_instrumentation_library_spans ~spans () in
|
||||
let rs = default_resource_spans ~instrumentation_library_spans:[ils] () in
|
||||
Collector.send_trace [rs]
|
||||
~over:(fun () -> Lwt.wakeup_later wake ())
|
||||
~ret:(fun () -> fut)
|
||||
end
|
||||
|
||||
module Metrics = struct
|
||||
open Proto.Metrics
|
||||
include Metrics
|
||||
|
||||
(** Emit some metrics to the collector. *)
|
||||
let emit (l:t list) : unit Lwt.t =
|
||||
let fut, wake = Lwt.wait() in
|
||||
let lm =
|
||||
default_instrumentation_library_metrics ~metrics:l () in
|
||||
let rm = default_resource_metrics
|
||||
~instrumentation_library_metrics:[lm] () in
|
||||
Collector.send_metrics [rm]
|
||||
~over:(fun () -> Lwt.wakeup_later wake ())
|
||||
~ret:(fun () -> fut)
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue