Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into debugging-backend
Browse files Browse the repository at this point in the history
* upstream/master: (40 commits)
  chore: add upper bound on pbrt
  fix: regenerate code with a non-pinned ocaml-protoc
  debug git diff
  chore: use protoc 2.4 in CI
  format
  ocamlformat
  add missing proto directory
  refactor tests to avoid circular dependencies
  no open
  move protobuf code to opentelemetry.proto
  trace-collector: Use Trace_core instead of Trace for OCaml v5
  tests: Add every test-dep to every package
  chore: Prepare for v0.6
  chore: Add myself to maintainers
  chore: update CHANGES
  dune fmt
  trace-collector: Pass user-data to OTel metrics
  deps: Update ocaml-trace dep to 0.4
  trace-collector: Support for floats, etc from trace
  (- fix) Use new TLS-module naming from ac.0.1.0
  ...
  • Loading branch information
ELLIOTTCABLE committed Dec 6, 2023
2 parents fa265c6 + e53cffb commit 2a2092d
Show file tree
Hide file tree
Showing 93 changed files with 781 additions and 389 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ jobs:

- run: opam exec -- dune build @install -p opentelemetry,opentelemetry-lwt,opentelemetry-client-ocurl,opentelemetry-cohttp-lwt,opentelemetry-client-cohttp-lwt

- run: opam pin ocaml-protoc 2.3 -y
- run: opam pin ocaml-protoc 2.4 -y

- run: opam exec -- dune build @lint

# check that nothing changed
- run: git diff --quiet --exit-code
- run: git diff --exit-code

- run: opam exec -- dune build @runtest
if: ${{ matrix.os == 'ubuntu-latest' }}
10 changes: 9 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
## next version

## 0.6

- fix ticker thread shutdown
- migrated to OTEL proto files v1.0
- replace `Thread_local` with `ocaml-ambient-context`, allowing for implicit scope in Lwt/Eio contexts (#34)
- update `ocaml-trace` interface to use the new `trace.0.3`-style API (breaking, see #34)

## 0.5

- new implementation for ocurl backend, using ezcurl and queues
- refactor lwt: Use `try%lwt` over `Lwt.catch`
- add `opentelemetry.trace` (optional, depends on `trace`)
- add `opentelemetry.trace` (optional, depends on `ocaml-trace`)

## 0.4

Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ MIT
* [x] batching, perf, etc.
- [ ] async collector relying on ocurl-multi
- [ ] interface with `logs` (carry context around)
- [x] implicit scope (via [ambient-context][])

## Use

For now, instrument manually:
For now, instrument traces/spans, logs, and metrics manually:

```ocaml
module Otel = Opentelemetry
Expand All @@ -45,16 +46,34 @@ let foo () =
]);
do_more_work();
()
```

### Setup

If you're writing a top-level application, you need to perform some initial configuration.

1. Set the [`service_name`][];
2. configure our [ambient-context][] dependency with the appropriate storage for your environment — TLS, Lwt, Eio ... (see [their docs][install-ambient-storage] for more details);
3. and install a [`Collector`][] (usually by calling your collector's `with_setup` function.)

For example, if your application is using Lwt, and you're using `ocurl` as your collector, you might do something like this:

```ocaml
let main () =
Otel.Globals.service_name := "my_service";
Otel.GC_metrics.basic_setup();
Ambient_context.with_storage_provider (Ambient_context_lwt.storage ()) @@ fun () ->
Opentelemetry_client_ocurl.with_setup () @@ fun () ->
(* … *)
foo ();
(* … *)
```
```

[`service_name`]: <https://v3.ocaml.org/p/opentelemetry/0.5/doc/Opentelemetry/Globals/index.html#val-service_name>
[`Collector`]: <https://v3.ocaml.org/p/opentelemetry/0.5/doc/Opentelemetry/Collector/index.html>
[ambient-context]: <https://v3.ocaml.org/p/ambient-context>
[install-ambient-storage]: <https://github.com/ELLIOTTCABLE/ocaml-ambient-context#-as-a-top-level-application>

## Configuration

Expand Down
3 changes: 2 additions & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
(env
(_
(flags :standard -warn-error -a+8 -w +a-4-30-40-41-42-44-48-70 -strict-sequence)))
(flags :standard -warn-error -a+8 -w +a-4-30-40-41-42-44-48-70
-strict-sequence)))
134 changes: 92 additions & 42 deletions dune-project
Original file line number Diff line number Diff line change
@@ -1,76 +1,126 @@
(lang dune 2.7)

(name opentelemetry)

(generate_opam_files true)

(source
(github imandra-ai/ocaml-opentelemetry))

(version 0.5)
(version 0.6)

(authors "the Imandra team and contributors")
(maintainers "the Imandra team and contributors")

(maintainers
"Simon Cruanes <[email protected]>"
"Matt Bray <[email protected]>"
"ELLIOTTCABLE <[email protected]>")

(license MIT)

;(documentation https://url/to/documentation)

(package
(name opentelemetry)
(synopsis "Instrumentation for https://opentelemetry.io")
(depends
(ocaml (>= "4.08"))
ptime
(odoc :with-doc)
(pbrt (>= 2.3)))
(depopts
(trace (>= 0.1)))
(ocaml
(>= "4.08"))
ptime
ambient-context
(odoc :with-doc)
(alcotest :with-test)
(pbrt
(and (>= 2.3) (< 3.0)))
(ocaml-lsp-server :with-dev-setup)
(ocamlformat
(and
:with-dev-setup
(>= 0.24)
(< 0.25))))
(depopts trace)
(conflicts
(trace
(or
(< 0.4)
(>= 0.5))))
(tags
(instrumentation tracing opentelemetry datadog jaeger)))

(package
(name opentelemetry-lwt)
(synopsis "Lwt-compatible instrumentation for https://opentelemetry.io")
(depends
(ocaml (>= "4.08"))
(opentelemetry (= :version))
(cohttp-lwt-unix :with-test)
(odoc :with-doc)
(lwt (>= "5.3"))
(lwt_ppx (>= "2.0")))
(ocaml
(>= "4.08"))
ambient-context
(opentelemetry
(= :version))
(cohttp-lwt-unix :with-test)
(odoc :with-doc)
(lwt
(>= "5.3"))
(lwt_ppx
(>= "2.0"))
(alcotest :with-test))
(tags
(instrumentation tracing opentelemetry datadog lwt)))

(package
(name opentelemetry-client-ocurl)
(depends
(ocaml (>= "4.08"))
(mtime (>= "1.4")) ; for spans
; atomic ; vendored
(opentelemetry (= :version))
(pbrt (>= 2.3))
(odoc :with-doc)
(ezcurl (>= 0.2.3))
ocurl)
(synopsis "Collector client for opentelemetry, using http + ezcurl"))
(name opentelemetry-client-ocurl)
(depends
(ocaml
(>= "4.08"))
(mtime
(>= "1.4"))
; for spans
; atomic ; vendored
(opentelemetry
(= :version))
(pbrt
(and (>= 2.3) (< 3.0)))
(odoc :with-doc)
(ezcurl
(>= 0.2.3))
ocurl
(alcotest :with-test))
(synopsis "Collector client for opentelemetry, using http + ezcurl"))

(package
(name opentelemetry-cohttp-lwt)
(depends
(ocaml (>= "4.08"))
(opentelemetry (= :version))
(opentelemetry-lwt (= :version))
(ocaml
(>= "4.08"))
(opentelemetry
(= :version))
(opentelemetry-lwt
(= :version))
(odoc :with-doc)
(lwt (>= "5.3"))
(cohttp-lwt (>= "4.0.0")))
(lwt
(>= "5.3"))
(cohttp-lwt
(>= "4.0.0"))
(alcotest :with-test))
(synopsis "Opentelemetry tracing for Cohttp HTTP servers"))

(package
(name opentelemetry-client-cohttp-lwt)
(depends
(ocaml (>= "4.08"))
(mtime (>= "1.4")) ; for spans
(opentelemetry (= :version))
(pbrt (>= 2.2))
(odoc :with-doc)
(lwt (>= "5.3"))
(lwt_ppx (>= "2.0"))
cohttp-lwt
cohttp-lwt-unix)
(synopsis "Collector client for opentelemetry, using cohttp + lwt"))
(name opentelemetry-client-cohttp-lwt)
(depends
(ocaml
(>= "4.08"))
(mtime
(>= "1.4"))
; for spans
(opentelemetry
(= :version))
(pbrt
(and (>= 2.2) (< 3.0)))
(odoc :with-doc)
(lwt
(>= "5.3"))
(lwt_ppx
(>= "2.0"))
cohttp-lwt
cohttp-lwt-unix
(alcotest :with-test))
(synopsis "Collector client for opentelemetry, using cohttp + lwt"))
11 changes: 8 additions & 3 deletions opentelemetry-client-cohttp-lwt.opam
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "0.5"
version: "0.6"
synopsis: "Collector client for opentelemetry, using cohttp + lwt"
maintainer: ["the Imandra team and contributors"]
maintainer: [
"Simon Cruanes <[email protected]>"
"Matt Bray <[email protected]>"
"ELLIOTTCABLE <[email protected]>"
]
authors: ["the Imandra team and contributors"]
license: "MIT"
homepage: "https://github.com/imandra-ai/ocaml-opentelemetry"
Expand All @@ -12,12 +16,13 @@ depends: [
"ocaml" {>= "4.08"}
"mtime" {>= "1.4"}
"opentelemetry" {= version}
"pbrt" {>= "2.2"}
"pbrt" {>= "2.2" & < "3.0"}
"odoc" {with-doc}
"lwt" {>= "5.3"}
"lwt_ppx" {>= "2.0"}
"cohttp-lwt"
"cohttp-lwt-unix"
"alcotest" {with-test}
]
build: [
["dune" "subst"] {dev}
Expand Down
11 changes: 8 additions & 3 deletions opentelemetry-client-ocurl.opam
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "0.5"
version: "0.6"
synopsis: "Collector client for opentelemetry, using http + ezcurl"
maintainer: ["the Imandra team and contributors"]
maintainer: [
"Simon Cruanes <[email protected]>"
"Matt Bray <[email protected]>"
"ELLIOTTCABLE <[email protected]>"
]
authors: ["the Imandra team and contributors"]
license: "MIT"
homepage: "https://github.com/imandra-ai/ocaml-opentelemetry"
Expand All @@ -12,10 +16,11 @@ depends: [
"ocaml" {>= "4.08"}
"mtime" {>= "1.4"}
"opentelemetry" {= version}
"pbrt" {>= "2.3"}
"pbrt" {>= "2.3" & < "3.0"}
"odoc" {with-doc}
"ezcurl" {>= "0.2.3"}
"ocurl"
"alcotest" {with-test}
]
build: [
["dune" "subst"] {dev}
Expand Down
9 changes: 7 additions & 2 deletions opentelemetry-cohttp-lwt.opam
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "0.5"
version: "0.6"
synopsis: "Opentelemetry tracing for Cohttp HTTP servers"
maintainer: ["the Imandra team and contributors"]
maintainer: [
"Simon Cruanes <[email protected]>"
"Matt Bray <[email protected]>"
"ELLIOTTCABLE <[email protected]>"
]
authors: ["the Imandra team and contributors"]
license: "MIT"
homepage: "https://github.com/imandra-ai/ocaml-opentelemetry"
Expand All @@ -15,6 +19,7 @@ depends: [
"odoc" {with-doc}
"lwt" {>= "5.3"}
"cohttp-lwt" {>= "4.0.0"}
"alcotest" {with-test}
]
build: [
["dune" "subst"] {dev}
Expand Down
10 changes: 8 additions & 2 deletions opentelemetry-lwt.opam
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
version: "0.5"
version: "0.6"
synopsis: "Lwt-compatible instrumentation for https://opentelemetry.io"
maintainer: ["the Imandra team and contributors"]
maintainer: [
"Simon Cruanes <[email protected]>"
"Matt Bray <[email protected]>"
"ELLIOTTCABLE <[email protected]>"
]
authors: ["the Imandra team and contributors"]
license: "MIT"
tags: ["instrumentation" "tracing" "opentelemetry" "datadog" "lwt"]
Expand All @@ -11,11 +15,13 @@ bug-reports: "https://github.com/imandra-ai/ocaml-opentelemetry/issues"
depends: [
"dune" {>= "2.7"}
"ocaml" {>= "4.08"}
"ambient-context"
"opentelemetry" {= version}
"cohttp-lwt-unix" {with-test}
"odoc" {with-doc}
"lwt" {>= "5.3"}
"lwt_ppx" {>= "2.0"}
"alcotest" {with-test}
]
build: [
["dune" "subst"] {dev}
Expand Down
Loading

0 comments on commit 2a2092d

Please sign in to comment.