You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a 'Region()' to the 'TraceLogger' interface that starts logging a region
for a given context, created an updated context with region metadata (time
of region start, nesting level), and returns a corresponding "end region"
function used for closing out the region. Implement 'Region()' for the
'Trace2' logger.
Example of adding region tracing to a function 'func myFunc()':
---
func myFunc(ctx context.Context, logger log.TraceLogger) {
ctx, endRegion := logger.Region(ctx, "my_file", "my_func")
defer endRegion()
...the rest of myFunc()...
}
---
While 'endRegion()' can be called manually before each possible 'return',
using 'defer' ensures that the region will exit properly from all 'return's
as well as 'panic'.
Signed-off-by: Victoria Dye <[email protected]>
0 commit comments