Skip to content

Conversation

@kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Oct 22, 2025

There are two primary aspects to this PR. The first is support for hooks, and the second is support for a Go context like addition to the variation API.

The reason for this addition is that it may not be possible in all environments to automatically get the current span parent using OTEL.

The default context management strategy in OTEL uses thread-local storage, which can cause problems when an async framework is handling multiple requests in a single thread. In that scenario the application manually determines the parent-child relationship (unless they have async aware custom context management).

BEGIN_COMMIT_OVERRIDE
feat: Add support for hooks.
fix: Discard track events when the associated context is invalid.
END_COMMIT_OVERRIDE


Note

Introduce a full hooks system (with hook context) across C++ and C APIs, integrate it into evaluations/tracking, add WithHookContext overloads, drop invalid-context track events, and update build/deps with extensive tests.

  • Hooks framework (C++ core):
    • Add hooks::Hook, HookContext, EvaluationSeriesContext/Data(+Builder), TrackSeriesContext and hook_executor for before/after evaluation and after track.
    • Wire hooks into ClientImpl variation/track paths with method names; execute hooks synchronously.
    • Extend Config/ConfigBuilder to accept std::shared_ptr<hooks::Hook> list.
  • C++ API:
    • Add Track and all *Variation* overloads accepting hooks::HookContext.
  • C bindings:
    • New headers/APIs: hook.h, hook_context.h, evaluation_series_context.h, evaluation_series_data.h, track_series_context.h.
    • Register hooks via LDServerConfigBuilder_Hooks; bridge via CHookWrapper.
    • Add *_WithHookContext functions for track and all variation variants.
  • Events behavior:
    • Discard track events when Context is invalid; log warning.
  • Build/Deps:
    • Include new hook sources in CMakeLists.txt.
    • Update redis-plus-plus FetchContent tag and disable shallow clone.
  • Tests:
    • Add comprehensive C++ and C binding tests for hook ordering, data passing, error handling, and contexts.

Written by Cursor Bugbot for commit 4773e9e. This will update automatically on new commits. Configure here.

@kinyoklion kinyoklion force-pushed the rlamb/add-hooks-support branch from d441c2d to 5cf0bcd Compare October 23, 2025 21:03
@kinyoklion kinyoklion marked this pull request as ready for review October 23, 2025 21:06
@kinyoklion kinyoklion requested a review from a team as a code owner October 23, 2025 21:06
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@kinyoklion kinyoklion marked this pull request as draft October 27, 2025 23:14
@kinyoklion
Copy link
Member Author

bugbot review

cursor[bot]

This comment was marked as outdated.

@kinyoklion kinyoklion marked this pull request as ready for review October 28, 2025 15:33
cursor[bot]

This comment was marked as outdated.

extern "C" {
#endif

typedef struct p_LDServerSDKEvaluationSeriesContext* LDServerSDKEvaluationSeriesContext;
Copy link
Member Author

Choose a reason for hiding this comment

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

So, there was a mistake with the syntax of the clang-tidy suppression in the base binding implementations. Which result in suppressing all tidy messages.

We are not doing that here, and the result is that these opaque struct definitions were encountering: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/reserved-identifier.html

Which isn't going to be a problem because the compiler isn't going to spontaneously reserve these very specific names.

But to appease it here I have started with p_. This first name isn't used by calling code, but we just want it to not look like it should be used either.

cursor[bot]

This comment was marked as outdated.

@kinyoklion kinyoklion merged commit 03e2a59 into main Oct 29, 2025
27 checks passed
@kinyoklion kinyoklion deleted the rlamb/add-hooks-support branch October 29, 2025 16:37
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.

3 participants