Hi,
I recently dug into the TRACE_ID_*() code while trying to fix toplevel.flow for TaskScheduler tasks.The TaskAnnotator code uses TRACE_ID_MANGLE() which is documented as making a cross-process unique ID but I don't think it does...TRACE_ID_MANGLE is marked as deprecated in favor of TRACE_ID_{GLOBAL, LOCAL} but there only appears to be users of the LOCAL variant.. and I can't wrap my head around the documentation of what the difference even is between global and local?In the impl, aside from the void* constructor (which merely reinterpret casts), TraceID::ForceMangle and TraceID::DontMangle are the exact same and I don't see logic to merge a process unique token in the ID..?There is "prefix_" code that was added in https://codereview.chromium.org/2504753002 but it still appears to be unused a year later and the documentation appears to hint that one should inject the prefix manually?I'm confused both about what the documentation says it does (for APIs that are documented) and by what the impl looks like it does.Thanks for enlightening me!Gab
TRACE_ID_MANGLE is marked as deprecated in favor of TRACE_ID_{GLOBAL, LOCAL} but there only appears to be users of the LOCAL variant.. and I can't wrap my head around the documentation of what the difference even is between global and local?
There is "prefix_" code that was added in https://codereview.chromium.org/2504753002 but it still appears to be unused a year later and the documentation appears to hint that one should inject the prefix manually?
I'm confused both about what the documentation says it does (for APIs that are documented) and by what the impl looks like it does.
Hi Gab,Below I try to answer some of your question. I'll take a look at your CL later to understand your usecase give more specific comments if needed.TRACE_ID_MANGLE is marked as deprecated in favor of TRACE_ID_{GLOBAL, LOCAL} but there only appears to be users of the LOCAL variant.. and I can't wrap my head around the documentation of what the difference even is between global and local?TRACE_ID_LOCAL andTRACE_ID_GLOBAL macros change the flag value of a TraceID, which results in different JSON outputs. The trace viewer will prepend the PID to local IDs so that they don't collide with IDs from other processes.So, if you need an inter-process ID, e.g. open an async slice in process 1 and close it in process 2, you sould use a global ID:process 1:TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("cat", "name",TRACE_ID_GLOBAL(event_id));process 2:TRACE_EVENT_NESTABLE_ASYNC_END0("cat", "name",TRACE_ID_GLOBAL(event_id));If you have several async events in the same category you can add a scope string to make sure they are not mixed together:TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("cat", "name",TRACE_ID_WITH_SCOPE("scope_1", TRACE_ID_GLOBAL(event_id)));Otherwise, if your events are all from the same process, use TRACE_ID_LOCAL to make sure they do not collide with events from other processes.