userver-framework / userver

Production-ready C++ Asynchronous Framework with rich functionality
https://userver.tech
Apache License 2.0
2.37k stars 275 forks source link

feat traces: Improve span naming in distributed tracing for better clarity #678

Closed TertiumOrganum1 closed 6 days ago

TertiumOrganum1 commented 2 weeks ago

Currently, in userver's distributed tracing implementation, not all spans are named in a way that clearly indicates their purpose or the operations they represent. This lack of descriptive naming makes it harder to understand the flow and nature of operations at a glance.

For example, all PostgreSQL-related spans are uniformly named "pg_query", regardless of the specific database operation being performed. This generic naming convention doesn't provide enough context about the actual database actions taking place.

To improve clarity and make the tracing more informative, we should consider renaming these spans to be more specific and descriptive. For instance, PostgreSQL-related spans could be named:

This approach is similar to the naming conventions used in OpenTelemetry instrumentation in some Golang libraries, which provide more meaningful span names out of the box: image image

Compare with userver trace: image

Proposed solution:

  1. Review all automatically created spans in userver
  2. Identify spans with generic or non-descriptive names
  3. Implement a more granular naming scheme for these spans
  4. Update the span creation logic to use these new, more descriptive names

This enhancement would significantly improve the readability and usefulness of userver distributed traces.