Skip to content

Conversation

@renecannao
Copy link
Contributor

Summary

This PR removes abseil, protobuf, and curl from local build dependencies and configures the project to use the system's libraries instead. This significantly reduces build size and build time while using system-maintained, security-patched libraries.

Changes

System Library Integration

  • abseil: Now uses libabsl-dev from the system
  • protobuf: Now uses libprotobuf-dev and protobuf-compiler from the system
  • curl: Now uses libcurl4-openssl-dev from the system

Build Configuration (deps/Makefile)

  • Remove 'abseil', 'protobuf', 'curl' from targets list
  • Remove abseil, protobuf, and curl build targets entirely
  • Update OpenTelemetry to remove abseil and curl dependencies
  • Update clickhouse-cpp to remove abseil CMAKE_PREFIX_PATH
  • Remove cleanup for these dependencies from cleanall target

Path Configuration (include/makefiles_paths.mk)

  • Set ABSL_IDIR and ABSL_LDIR to /usr/include and /usr/lib
  • Set PROTOBUF_IDIR and PROTOBUF_LDIR to /usr/include and /usr/lib
  • Set CURL_IDIR and CURL_LDIR to /usr/include and /usr/lib
  • Update OTEL_IDIR to point to actual source include directories (api, sdk, ext, exporters)
  • Remove obsolete *_ROOT and *_PATH variables for system packages

Linking Updates (src/Makefile)

  • Move -lcurl and -lprotobuf from static to dynamic linking
  • Remove -labsl, -lutf8_range, -lutf8_validity from static linking
  • Update include path handling for OTEL_IDIR to properly expand colon-separated paths
  • Add system library dependencies (-lidn2 for curl)

OpenTelemetry Implementation

  • Complete OpenTelemetry implementation fixes for memory safety, error handling, and thread safety
  • Add OpenTelemetry documentation in otel/ folder
  • Add OpenTelemetry tests (tests/otel/)
  • Fix JSON include issues in tap test files

Benefits

  1. Smaller Build Size: No need to build large dependencies locally (protobuf build was ~3GB, now ~0)
  2. Faster Build Times: Significantly reduced dependency compilation time
  3. System-Maintained Libraries: Uses security-patched, system-maintained versions
  4. Simplified Build Process: Fewer build targets and less complex dependency management
  5. Better Portability: Uses standard system paths instead of hardcoded architecture-specific directories

System Requirements

The following system packages are now required:

  • libabsl-dev (abseil)
  • libprotobuf-dev (protobuf development files)
  • protobuf-compiler (protoc compiler for OpenTelemetry)
  • libcurl4-openssl-dev (curl development files)

These can be installed on Ubuntu/Debian with:

sudo apt install libabsl-dev libprotobuf-dev protobuf-compiler libcurl4-openssl-dev

Testing

  • make build_deps completes successfully
  • make (regular build) completes successfully
  • make debug (debug build) completes successfully
  • Binary links correctly against system libraries:
    • libprotobuf.so.32 => /lib/x86_64-linux-gnu/libprotobuf.so.32
    • libcurl.so.4 => /lib/x86_64-linux-gnu/libcurl.so.4

Remove abseil, protobuf, and curl from local build dependencies and use
the system's libraries instead. This significantly reduces build size and
build time while using system-maintained, security-patched libraries.

This commit includes all changes from otel_2 branch:
- System library integration (abseil, protobuf, curl)
- OpenTelemetry implementation fixes
- Documentation reorganization
- Build improvements and cleanup

Changes:
- Set ABSL_IDIR, ABSL_LDIR to /usr/include and /usr/lib
- Set PROTOBUF_IDIR, PROTOBUF_LDIR to /usr/include and /usr/lib
- Set CURL_IDIR, CURL_LDIR to /usr/include and /usr/lib
- Remove 'abseil', 'protobuf', 'curl' from targets list
- Remove abseil, protobuf, curl build targets
- Update OpenTelemetry to use source include directories
- Update linking to use dynamic linking for system libs
- Add OpenTelemetry documentation in otel/ folder
- Add OpenTelemetry tests
- Fix JSON include issues in tap tests

System packages required:
- libabsl-dev (abseil)
- libprotobuf-dev, protobuf-compiler (protobuf)
- libcurl4-openssl-dev (curl)
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @renecannao, 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 refactors the project's dependency management by transitioning from locally building abseil, protobuf, and curl to utilizing system-provided versions. This change aims to reduce build times and binary size, enhance security through system-maintained libraries, and simplify the overall build configuration. Concurrently, the OpenTelemetry implementation has been significantly hardened with critical fixes for memory safety, error handling, and thread safety, ensuring a more reliable and maintainable tracing solution.

Highlights

  • System Library Adoption: The project now leverages system-installed abseil, protobuf, and curl libraries, eliminating the need for local builds of these dependencies. This significantly reduces build size and time while utilizing security-patched, system-maintained versions.
  • Build Process Streamlining: Build configurations in deps/Makefile and include/makefiles_paths.mk have been updated to remove local build targets and point to system library paths, simplifying the build process and improving portability.
  • OpenTelemetry Implementation Enhancements: The OpenTelemetry integration has received substantial improvements, including memory safety fixes using RAII wrappers, robust error handling in OTelTracer::Setup(), and clearer thread safety documentation for unsafe_shared_ptr.
  • Dynamic Linking for Core Libraries: protobuf and curl are now dynamically linked, reducing the static binary size and improving maintainability by relying on shared system libraries.
  • Comprehensive OpenTelemetry Testing & Documentation: New unit tests have been added for OTelSpan, OTelSpanStack, OTelTracer, and unsafe_shared_ptr, alongside extensive documentation detailing the OpenTelemetry changes, project structure, and verification steps.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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 makes a significant improvement by switching from local builds of abseil, protobuf, and curl to using system-provided libraries. This simplifies the build process, reduces compilation time, and leverages system-maintained packages. Additionally, the PR includes a substantial and valuable refactoring of the OpenTelemetry integration, greatly improving memory safety, exception safety, and robustness through the use of RAII patterns and better error handling. The introduction of unit tests for the OpenTelemetry components is also a great addition.

My review includes two main points:

  1. A suggestion to improve portability in the build files by using pkg-config instead of hardcoded library paths.
  2. A critical fix for a race condition in the management of the global OpenTelemetry tracer instance.

Overall, this is a high-quality contribution that modernizes the dependency management and hardens the tracing implementation.

Comment on lines +117 to 124
void OTelTracer::SetGlobalTracer(OTelTracer* tracer) {
pthread_rwlock_t rwlock_local;
pthread_rwlock_init(&rwlock_local, nullptr);
pthread_rwlock_wrlock(&rwlock_local);
g_global_tracer = tracer;
pthread_rwlock_unlock(&rwlock_local);
pthread_rwlock_destroy(&rwlock_local);
}

Choose a reason for hiding this comment

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

critical

The locking mechanism for the global tracer g_global_tracer is not thread-safe. This function uses a local pthread_rwlock_t, which is created and destroyed within this function call. It does not protect against concurrent calls to SetGlobalTracer, GetGlobalTracer, or the OTelTracer constructor/destructor from different threads.

To fix this, you should use a single static pthread_rwlock_t to protect all accesses to the static g_global_tracer pointer.

Here's a suggested implementation approach:

  1. Define a static lock for the global tracer near g_global_tracer:

    namespace {
        OTelTracer* g_global_tracer = nullptr;
        pthread_rwlock_t g_global_tracer_lock = PTHREAD_RWLOCK_INITIALIZER;
    }
  2. Update SetGlobalTracer to use this static lock:

    void OTelTracer::SetGlobalTracer(OTelTracer* tracer) {
        pthread_rwlock_wrlock(&g_global_tracer_lock);
        g_global_tracer = tracer;
        pthread_rwlock_unlock(&g_global_tracer_lock);
    }
  3. Similarly, GetGlobalTracer should use a read lock, and the constructor/destructor should use a write lock on g_global_tracer_lock when modifying g_global_tracer.

Comment on lines +96 to +100
ABSL_IDIR := /usr/include
ABSL_LDIR := /usr/lib

PROTOBUF_PATH := $(DEPS_PATH)/protobuf/protobuf
PROTOBUF_ROOT := $(PROTOBUF_PATH)/local
PROTOBUF_IDIR := $(PROTOBUF_ROOT)/include
PROTOBUF_LDIR := $(PROTOBUF_ROOT)/lib
PROTOBUF_IDIR := /usr/include
PROTOBUF_LDIR := /usr/lib

Choose a reason for hiding this comment

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

medium

Hardcoding library paths to /usr/include and /usr/lib reduces portability. On many systems, these libraries might be installed in different locations like /usr/local or other custom paths. It's better to use a tool like pkg-config to discover these paths dynamically at build time. This will make the build system more robust and portable across different environments.

For example, you could define the paths like this:

ABSL_IDIR := $(shell pkg-config --cflags-only-I absl_base)
ABSL_LDIR := $(shell pkg-config --libs-only-L absl_base)

PROTOBUF_IDIR := $(shell pkg-config --cflags-only-I protobuf)
PROTOBUF_LDIR := $(shell pkg-config --libs-only-L protobuf)

Note that you might need to adjust the pkg-config package names (absl_base, protobuf) depending on the system. This also applies to CURL_IDIR and CURL_LDIR defined earlier in this file.

Clean up the deps directory by removing:
- deps/protobuf/ directory (using system protobuf now)
- Extracted opentelemetry-cpp and opentelemetry-proto folders
- These will be extracted during build when needed

Only the tarballs and patches remain in deps/opentelemetry/.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

1 participant