From 4bc5e2f5d1c48bdeace85c67fb48bbc3c6525429 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 27 Apr 2022 16:53:50 -0400 Subject: [PATCH] update readme --- README.md | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 11d3a00e..6d44d086 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,21 @@ This project provides an API for instrumenting server software using [opentelemetry](https://opentelemetry.io/docs), as well as 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 - [x] basic traces - [x] basic metrics -- [ ] basic logs +- [x] basic logs - [ ] nice API - [x] interface with `lwt` - [x] sync collector relying on ocurl - * [ ] batching, perf, etc. + * [x] batching, perf, etc. - [ ] async collector relying on ocurl-multi - [ ] 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: ```ocaml -module T = Opentelemetry +module Otel = Opentelemetry let (let@) f x = f x -let foo x = - let@ (tr,sp) = T.Trace.with_ - ~service_name:"myservice" "foo" ~attrs:["hello", `String "world"] in - (* … *) - - let gc = Gc.stat() in - T.Metrics.( +let foo () = + let@ scope = Otel.Trace.with_ "foo" + ~attrs:["hello", `String "world"] in + do_work(); + Otel.Metrics.( emit [ - gauge ~name:"foo.gc.major_heap_words" [int gc.Gc.heap_words]; - sum ~name:"foo.gc.minor_allocated" [float gc.Gc.minor_words]; + gauge ~name:"foo.x" [int 42]; ]); + do_more_work(); + () +let main () = + Otel.Globals.service_name := "my_service"; + Otel.GC_metrics.basic_setup(); + + Opentelemetry_client_ocurl.with_setup () @@ fun () -> + (* … *) + foo (); (* … *) ```