https://github.com/leostera/telemetry
Lightweight event dispatching for OCaml.
https://github.com/leostera/telemetry
Last synced: 4 months ago
JSON representation
Lightweight event dispatching for OCaml.
- Host: GitHub
- URL: https://github.com/leostera/telemetry
- Owner: leostera
- License: mit
- Created: 2023-11-08T10:23:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-27T20:06:16.000Z (over 2 years ago)
- Last Synced: 2025-03-21T01:11:06.965Z (over 1 year ago)
- Language: OCaml
- Homepage:
- Size: 9.77 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# telemetry
Telemetry is a lightweight library for dynamic dispatching of events, with a
focus on metrics and instrumentation. Any OCaml library can use telemetry to
emit events, then application code and other libraries can then hook into those
events and run custom handlers.
## Getting Started
Install from Opam:
```
opam install telemetry
```
Create some events in your library or application code:
```ocaml
type Telemetry.event += Web_request_done of { latency: int }
Telemetry.emit (Web_request_done { latency = 10 });
```
And now attach listeners:
```ocaml
Telemetry.attach (fun ev ->
match ev with
| Web_request_done {latency} ->
Printf.printf "Web request took %sms" latency
| _ -> ()
);
```