Skip to content

Conversation

wazir-ahmed
Copy link
Collaborator

  • Integrate OTel SDK and its dependency into the build system
  • Add necessary configuration and add load/save command
  • Implement core logic for creating spans and build parent-child relationships between spans
  • Add support for span filters

Closes #4999.

wazir-ahmed and others added 9 commits July 1, 2025 20:11
- Upgrade curl to v8.14.0
- Make json easily integrable with cmake projects
- Add abseil-cpp, protobuf and otel-cpp

Signed-off-by: Wazir Ahmed <[email protected]>
Closes #5000.

Signed-off-by: Wazir Ahmed <[email protected]>
- Handle configuration changes
- Span stack per session to handle context switching
- Marcos for creating trace point with session context

Closes #5001.

Signed-off-by: Wazir Ahmed <[email protected]>
Signed-off-by: Wazir Ahmed <[email protected]>
- Add `otel_span_filters` table and handle load/save operations.
- Handle filtering via `OTelTracer` class, treat filters as an allow list.
- Modify `OTelTracer` class to achieve the following.
    - `OTelTracer` should be the only interface other ProxySQL modules
      rely on to do any operation related to telemtry.
    - Spans should be created by calling `OTelTracer::StartSpan()`,
      instead of calling `OTelSpan`'s constructor directly.

Closes #5002.

Signed-off-by: Wazir Ahmed <[email protected]>
@wazir-ahmed wazir-ahmed requested review from renecannao, rahim-kanji, mirostauder and JavierJF and removed request for rahim-kanji and mirostauder July 28, 2025 07:59
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @wazir-ahmed, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces comprehensive OpenTelemetry tracing capabilities to the system. It involves integrating the necessary SDKs and libraries, overhauling significant portions of the build system, and implementing core logic to generate and manage trace spans. The new tracing functionality is fully configurable and supports filtering, with all settings manageable through the admin interface.

Highlights

  • OpenTelemetry Integration: I've integrated the OpenTelemetry C++ SDK along with its core dependencies (Abseil, Protobuf, and nlohmann/json) into the project's build system and codebase. This enables distributed tracing capabilities.
  • Build System Enhancements: Extensive modifications have been made to the Makefiles across the project and its dependencies. This includes adopting CMake for building new external libraries, centralizing compiler flags, and updating include/library paths to accommodate the new tracing infrastructure.
  • Core Tracing Logic: New OTelTracer and OTelSpan classes have been introduced to manage OpenTelemetry configuration, tracer providers, and the lifecycle of individual spans. This includes a custom unsafe_shared_ptr for performance in non-concurrent contexts.
  • Session-Level Tracing: Root spans are now automatically created for each MySQL and PostgreSQL session, providing a foundational tracing context for operations within those sessions. A span stack (OTelSpanStack) is used to manage parent-child relationships between spans.
  • Configurability and Filtering: OpenTelemetry tracing can be configured via new otel_variables in proxysql.cfg. Additionally, a new otel_span_filters table in the admin database allows for fine-grained control over which spans are generated, based on file, line number, and span name. LOAD and SAVE commands are available for managing these settings.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces OpenTelemetry tracing, which is a significant and valuable addition for observability. The changes are extensive, touching the build system, adding new dependencies, and integrating the tracing logic throughout the codebase.

Overall, the implementation is well-structured. I've identified a few critical and high-severity issues related to potential memory leaks, exception safety, and correctness bugs that should be addressed before merging. I've also left some comments on potential improvements and TODOs that were left in the code.

Please review the detailed comments on the specific files. Great work on this feature!

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
6 Security Hotspots
4.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link

sonarqubecloud bot commented Sep 1, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
6 Security Hotspots
4.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add OpenTelemetry Tracing
1 participant