-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tracing: observe modes and other tracing improvements. #5612
tracing: observe modes and other tracing improvements. #5612
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github doesn't let me comment on the commit messages, but you have some typos there. E.g. 'proveder', 'enbaled'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The quality gate in the CI complains that we have 1 new .ml file without .mli. It probably refers to 'tracing_export.ml', if you add an .mli for it, the CI should pass
I think it's |
e01650c
to
847aeba
Compare
Passed BST-BVT 197856 and some manual testing. |
It is not safe to access a global hashtable from multiple threads, even if the operations are read-only (it may be concurrently changed by another thread, which then may result in errors in the racing thread). This means we must always take the mutex, and because OCaml doesn't have a reader-writer mutex, we need to take the exclusive mutex. Eventually we should use a better datastructure here (immutable maps, or lock-free datastructures), but for now fix the datastructure that we currently use to be thread-safe. Signed-off-by: Edwin Török <[email protected]>
In preparation for OCaml 5, on OCaml 4 they'd be equivalent. Note that adding Atomic doesn't make operations on these values always atomic: that is the responsibility of surrounding code. E.g. Atomic.get + Atomic.set is not atomic, because another domain might've raced and changed the value inbetween (so in that case Atomic.compare_and_set should be used). However for global flags that are read multiple times, but set from a central place this isn't a problem. Signed-off-by: Edwin Török <[email protected]>
Sets `observe` to `false` until at least one tracer provider is enabled. If all tracer providers are disabled we set it back to `false`. Prior to this `observe` seemed to be always `true` (apart from unit tests). This would cause `with_tracing` to spam the logs with warnings `No provider found...` until at least one tracer provider is enabled. By setting `observe` to `false` as default and updating it depending on the state of the tracer providers, `with_tracing` should now execute no extra operations. Therefore, we avoid spamming the logs unnecessarily. Signed-off-by: Gabriel Buica <[email protected]>
5a627c8
to
f4eb5f2
Compare
ocaml/tests/test_observer.ml
Outdated
@@ -405,6 +404,13 @@ let test_hashtbl_leaks () = | |||
let test_trace_log_dir = trace_log_dir ~test_name:"test_hashtbl_leaks" () in | |||
let __context = Test_common.make_test_database () in | |||
let self = test_create ~__context ~enabled:true () in | |||
let filter_export_spans span = | |||
match Span.get_name span with | |||
| "Tracing.flush_spans" | "Tracing.File.export" | "Tracing.Http.export" -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are very specific names. Can we be sure they arrive exactly like this? Otherwise it would be good to downcase them before the match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've downcased them before matching.
Create a new unit test file `test_tracing.ml` for the `tracing` library. Add tests for `create`/`set`/`destroy` tracer providers. Now that we change the library to have `observe` modes based on whether or not we have `tracer providers` enabled, we want to make sure that functions on applied on tracer providers set the correct mode for the library. Signed-off-by: Gabriel Buica <[email protected]>
Removes code duplication in `storage_mux.ml` by using the already existing `with_dbg` implementation from `debuginfo` module. This should lower the chances of unintentionally introducing bugs by having to maintain two version of the same functions. e.g. Not using the no op when tracing is disabled and generating unwanted warning messages. Signed-off-by: Gabriel Buica <[email protected]>
Moves the following: - `create` under `TracerProvider`; - `set` under `TracerProvider`; - `destroy` under `TracerProvider; - `get_tracer_providers` unde `TracerProvider`; - `get_tracer` under `Tracer`. Adds documentation for `TracerProvider` module. It kept being confusing of what `Tracing.set` does unless I was going through the implementation again and again. Therefore, I moved some of the functions so that their functionality becomes (hopefully) more intuitive. Signed-off-by: Gabriel Buica <[email protected]>
f4eb5f2
to
43e26f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm: the new unit tests will capture future issues with the observe mode, and passed BVT & BST.
Latest BVT+BST 198401 passed |
As a follow-up to commenting out the warning when no tracer providers were enabled here #5583. This is meant to solve the issue of spamming the logs by properly setting the observe mode inside the library.
This is based on top of #5601 that addresses missing lock in the library.
Some other improvements: