mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-11 04:58:39 -04:00
update readme
This commit is contained in:
parent
2149bb0714
commit
4bc5e2f5d1
1 changed files with 24 additions and 12 deletions
36
README.md
36
README.md
|
|
@ -5,15 +5,21 @@ This project provides an API for instrumenting server software
|
||||||
using [opentelemetry](https://opentelemetry.io/docs), as well as
|
using [opentelemetry](https://opentelemetry.io/docs), as well as
|
||||||
connectors to talk to opentelemetry software such as [jaeger](https://www.jaegertracing.io/).
|
connectors to talk to opentelemetry software such as [jaeger](https://www.jaegertracing.io/).
|
||||||
|
|
||||||
|
- library `opentelemetry` should be used to instrument your code
|
||||||
|
and possibly libraries. It doesn't communicate with anything except
|
||||||
|
a backend (default: dummy backend)
|
||||||
|
- library `opentelemetry-client-ocurl` is a backend that communicates
|
||||||
|
via http+protobuf with some collector (otelcol, datadog-agent, etc.)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- [x] basic traces
|
- [x] basic traces
|
||||||
- [x] basic metrics
|
- [x] basic metrics
|
||||||
- [ ] basic logs
|
- [x] basic logs
|
||||||
- [ ] nice API
|
- [ ] nice API
|
||||||
- [x] interface with `lwt`
|
- [x] interface with `lwt`
|
||||||
- [x] sync collector relying on ocurl
|
- [x] sync collector relying on ocurl
|
||||||
* [ ] batching, perf, etc.
|
* [x] batching, perf, etc.
|
||||||
- [ ] async collector relying on ocurl-multi
|
- [ ] async collector relying on ocurl-multi
|
||||||
- [ ] interface with `logs` (carry context around)
|
- [ ] interface with `logs` (carry context around)
|
||||||
|
|
||||||
|
|
@ -22,21 +28,27 @@ connectors to talk to opentelemetry software such as [jaeger](https://www.jaeger
|
||||||
For now, instrument manually:
|
For now, instrument manually:
|
||||||
|
|
||||||
```ocaml
|
```ocaml
|
||||||
module T = Opentelemetry
|
module Otel = Opentelemetry
|
||||||
let (let@) f x = f x
|
let (let@) f x = f x
|
||||||
|
|
||||||
let foo x =
|
let foo () =
|
||||||
let@ (tr,sp) = T.Trace.with_
|
let@ scope = Otel.Trace.with_ "foo"
|
||||||
~service_name:"myservice" "foo" ~attrs:["hello", `String "world"] in
|
~attrs:["hello", `String "world"] in
|
||||||
(* … *)
|
do_work();
|
||||||
|
Otel.Metrics.(
|
||||||
let gc = Gc.stat() in
|
|
||||||
T.Metrics.(
|
|
||||||
emit [
|
emit [
|
||||||
gauge ~name:"foo.gc.major_heap_words" [int gc.Gc.heap_words];
|
gauge ~name:"foo.x" [int 42];
|
||||||
sum ~name:"foo.gc.minor_allocated" [float gc.Gc.minor_words];
|
|
||||||
]);
|
]);
|
||||||
|
do_more_work();
|
||||||
|
()
|
||||||
|
|
||||||
|
let main () =
|
||||||
|
Otel.Globals.service_name := "my_service";
|
||||||
|
Otel.GC_metrics.basic_setup();
|
||||||
|
|
||||||
|
Opentelemetry_client_ocurl.with_setup () @@ fun () ->
|
||||||
|
(* … *)
|
||||||
|
foo ();
|
||||||
(* … *)
|
(* … *)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue