Back to all reviewers

Conditional observability instrumentation

maplibre/maplibre-native
Based on 2 comments
C++

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:

Observability C++

Reviewer Prompt

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:

  1. Use proper scoping for trace zones to control their lifetime
  2. Include contextual information with zone annotations to maximize debugging value
  3. Consider the performance impact of unique identifiers and other debug-only information

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.

2
Comments Analyzed
C++
Primary Language
Observability
Category

Source Discussions