Wrap all tracing, profiling, and debugging instrumentation in appropriate conditional compilation blocks (like `MLN_TRACY_ENABLE`) to prevent performance overhead in production builds. When adding trace points:
Wrap all tracing, profiling, and debugging instrumentation in appropriate conditional compilation blocks (like MLN_TRACY_ENABLE
) to prevent performance overhead in production builds. When adding trace points:
Example:
// Good practice - scoped and conditionally compiled
#ifdef MLN_TRACY_ENABLE
{
MLN_TRACE_FUNC()
MLN_ZONE_STR(name) // Adds context about which component is being processed
}
#endif
// For debug IDs or other observability-only fields
class MyClass {
private:
#ifdef MLN_TRACY_ENABLE
int64_t uniqueDebugId{generateDebugId()};
#endif
// other members
};
This approach ensures that observability instrumentation provides maximum value during development and debugging while having zero impact on production performance.
Enter the URL of a public GitHub repository