Commit graph

26 commits

Author SHA1 Message Date
Simon Cruanes
40b44349e7
core: add on_init callback to collector 2026-01-14 21:56:09 -05:00
Simon Cruanes
5018a9ead7
refactor core library
much cleaner now, and simpler.

- `span` is an open sum type, so it can carry as much info as we want
from enter to exit. This means most collectors shouldn't even need a
global table for spans!
- merge manual spans and spans. It's just spans now. Keep old
Trace_core.xxx_manual_xxx functions but deprecate them
- add `extension_parameter` to carry additional info to collector (eg
OTEL span kind, TEF sync/async, maybe span links, etc)
- make the collector into a record of callbacks + a state, for
efficiency (but also to make it easier to extend in the future with
callbacks that have a default implementation
)
2026-01-14 20:29:33 -05:00
Simon Cruanes
d9cd7621f5
prepare for 0.10 2025-05-27 09:58:19 -04:00
Simon Cruanes
46242cd817
format 2025-04-11 12:25:47 -04:00
Simon Cruanes
a4ee0d1408
comment 2025-04-09 14:53:39 -04:00
Simon Cruanes
cd6f6f6025
fix 2025-04-09 09:42:24 -04:00
Simon Cruanes
151d80d0f1
breaking: feat(trace): pass a string trace_id in manual spans
- in entering manual spans, we now pass an explicit span_ctx that
  contains a trace_id (bytes) and the parent span id (int64).
- this makes compat with OTEL easier as we want this sort
  of span_ctx to be passed around.
2025-04-09 09:28:09 -04:00
Simon Cruanes
064e6e26bb
prepare for 0.9 2025-01-13 10:17:57 -05:00
Simon Cruanes
4dfa319003
feat: add an extensible sum type for extending the library
libraries and collectors can now define their own "events" that
collectors will handle (or not), without having to contribute them to
ocaml-trace at all.
2024-10-29 09:21:09 -04:00
Simon Cruanes
d3e710605e
update @since next tags 2024-01-24 22:44:28 -05:00
Simon Cruanes
ef15941936
functions to enter/exit implicit spans 2023-12-22 20:10:58 -05:00
Simon Cruanes
f3ae3397de
fix docs 2023-10-11 13:29:37 -04:00
Simon Cruanes
0135a613a9 add ?data to counter_int and counter_float
this makes sense to add metadata in, say, opentelemetry
2023-09-16 21:29:01 -04:00
Simon Cruanes
431811c995
rename add_data_to_current_span; give it span explicitly 2023-09-13 14:43:16 -04:00
Simon Cruanes
e0fe99f500
rename add_data to add_data_to_current_span 2023-09-06 09:50:54 -04:00
Simon Cruanes
4306a635f3
Update src/core/collector.ml
Co-authored-by: ELLIOTTCABLE <github.com@from.ec>
2023-08-30 20:23:53 -04:00
Simon Cruanes
4137985d69
make add_data implicit (no span argument) 2023-08-30 20:23:52 -04:00
Simon Cruanes
c683f6331b
add add_data_to_span and add_data_to_explicit_span 2023-08-30 20:23:51 -04:00
Simon Cruanes
91c9da3b66
prepare for 0.3 2023-08-09 00:29:24 -04:00
Simon Cruanes
0eb6a84982 feat: add ?flavor argument to manual spans. 2023-08-09 00:26:21 -04:00
Simon Cruanes
1b5e827d65 fix inconsistency 2023-08-09 00:26:21 -04:00
Simon Cruanes
50b4691ab6 rename explicit span API 2023-08-09 00:26:21 -04:00
Simon Cruanes
a09a4fc69a refactor collector API as well.
After long discussions with @ELLIOTTCABLE, the collector should only
provide a `with_`-like function for regular spans. This allows
each concurrency library to use its native mechanism for local storage,
which is almost always based on such a scope function.
2023-08-09 00:26:21 -04:00
Simon Cruanes
b44e2f2923 Add explicit spans, for async tracing.
These spans require the user to pass the surrounding span, if any, when
entering a new span. They use the information inside (which is collector
specific) to track what asynchronous task is currently being executed.

Wrappers around `trace`, specific to an async library (e.g. Eio, lwt,
Async, etc.) can then smooth this over by providing a `with_async_span`
construct that uses some implicit contextual storage to carry the
`surrounding` scope around.
2023-08-09 00:26:21 -04:00
Simon Cruanes
ac57085d33 doc 2023-08-09 00:26:21 -04:00
Simon Cruanes
ee2e5dd651
refactor: avoid the cursed stdlib Trace module by adding trace.core
this way, we can actually use only `trace.core` when we also expect to
use compiler-libs.toplevel (which contains a naked `Trace` module, which
would cause .cmi collisions). The library `trace` still exists, and just
forwards to `trace.core`.
2023-06-12 13:12:41 -04:00
Renamed from src/collector.ml (Browse further)