Customizing the Profiling Code
The profiling code is built in the MindIE Motor framework. This operation is optional.
To customize profiling, modify the profiling code in the serving framework by referring to the following sample code. For details about the available APIs, see msServiceProfiler Profiling or msServiceProfiler Profiling.
The following samples use the C++ APIs.
Span data profiling:
1 2 3 4 5 6 7 8 | // Record the start and end time of the execution. auto span = PROF(INFO, SpanStart("exec")); ... // Execute user code. PROF(span.SpanEnd()); // Explicit calls of the SpanEnd function are optional. It runs automatically during destruction to end data profiling. |
Event data profiling:
1 2 | // Record the cache exchange event. PROF(INFO, Event("cacheSwap")); |
Metric data profiling:
1 2 3 4 5 6 | // Common data profiling: 50% usage PROF(INFO, Metric("usage", 0.5).Launch()); // Incremental data profiling: number of requests + 1 PROF(INFO, MetricInc("reqSize", 1).Launch()); // Define the profiling range (global by default): The current size of the third queue is 14. PROF(INFO, Metric("queueSize", 14).MetricScope("queue", 3).Launch()); |
Link data profiling:
1 2 3 | // Link various resources by matching their unique identifiers across different system modules during requests. // reqID_SYS1 and reqID_SYS2 have different system IDs. PROF(INFO, Link("reqID_SYS1", "reqID_SYS2")); |
Attribute data profiling:
1 2 3 4 5 6 | // You can add attributes in chain mode even if previous operations are not finished yet. PROF(INFO, Attr("attr", "attrValue").Attr("numAttr", 66.6).Event("test")); // Set the profiling level for each attribute as needed. PROF(INFO, Attr<msServiceProfiler::VERBOSE>("verboseAttr", 1000).Event("test")); // Other attributes like Domain and Res (usually the request ID) can also be chained together. PROF(INFO, Domain("http").Res(reqId).Attr("attr", "attrValue").Event("test")); |
Parent topic: Extended Functions