Skip to content

Commit 39b2adc

Browse files
danyal002claude
andcommitted
feat(ffe): send the split serial id on exposure events [EX-3425]
The exposures intake uses the serial id to find the holdout an allocation comes from. The compiler rewrites a holdout into an ordinary allocation before an SDK receives it, so the serial id is the only link back to it. Carry the serial id from the evaluation result through the exposure buffer into the sidecar FFI struct. Serial ids are zero-based per organization, so 0 is a real value and cannot signal absence; the value travels with a separate presence flag, matching the existing FfeResult convention. Serialization, the wire key, and exposure deduplication live in libdatadog and are already done there. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 8d9060c commit 39b2adc

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

components-rs/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ typedef enum ddog_RemoteConfigProduct {
437437
DDOG_REMOTE_CONFIG_PRODUCT_FFE_FLAGS,
438438
DDOG_REMOTE_CONFIG_PRODUCT_LIVE_DEBUGGING,
439439
DDOG_REMOTE_CONFIG_PRODUCT_LIVE_DEBUGGING_SYMBOL_DB,
440+
DDOG_REMOTE_CONFIG_PRODUCT_DEBUG,
440441
} ddog_RemoteConfigProduct;
441442

442443
typedef enum ddog_SpanProbeTarget {
@@ -1246,6 +1247,8 @@ typedef struct ddog_FfeExposure {
12461247
ddog_CharSlice subject_attributes_json;
12471248
ddog_CharSlice allocation_key;
12481249
ddog_CharSlice variant;
1250+
int32_t serial_id;
1251+
bool has_serial_id;
12491252
} ddog_FfeExposure;
12501253

12511254
typedef struct ddog_Slice_FfeExposure {

tracer/ffe.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ typedef struct {
3131
zend_string *subject_attributes_json;
3232
zend_string *allocation_key;
3333
zend_string *variant;
34+
int32_t serial_id;
35+
bool has_serial_id;
3436
} dd_ffe_exposure;
3537

3638
static void dd_ffe_release_metric(dd_ffe_metric *metric) {
@@ -168,7 +170,9 @@ void ddtrace_ffe_record_exposure(
168170
zend_string *targeting_key,
169171
zend_string *subject_attributes_json,
170172
zend_string *allocation_key,
171-
zend_string *variant
173+
zend_string *variant,
174+
int32_t serial_id,
175+
bool has_serial_id
172176
) {
173177
if (ZSTR_LEN(flag_key) == 0 || ZSTR_LEN(variant) == 0) {
174178
return;
@@ -200,6 +204,8 @@ void ddtrace_ffe_record_exposure(
200204
exposure->subject_attributes_json = zend_string_copy(subject_attributes_json);
201205
exposure->allocation_key = zend_string_copy(allocation_key);
202206
exposure->variant = zend_string_copy(variant);
207+
exposure->serial_id = serial_id;
208+
exposure->has_serial_id = has_serial_id;
203209
}
204210

205211
bool ddtrace_ffe_flush_exposures(void) {
@@ -224,6 +230,8 @@ bool ddtrace_ffe_flush_exposures(void) {
224230
.subject_attributes_json = dd_zend_string_to_CharSlice(buffer[i].subject_attributes_json),
225231
.allocation_key = dd_zend_string_to_CharSlice(buffer[i].allocation_key),
226232
.variant = dd_zend_string_to_CharSlice(buffer[i].variant),
233+
.serial_id = buffer[i].serial_id,
234+
.has_serial_id = buffer[i].has_serial_id,
227235
};
228236
}
229237

tracer/ffe.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33

44
#include <stdbool.h>
55
#include <stddef.h>
6+
#include <stdint.h>
67
#include <zend.h>
78

89
bool ddtrace_ffe_record_evaluation_metric(zend_string *flag_key, zend_string *variant, const char *reason, const char *error_type, zend_string *allocation_key);
910
bool ddtrace_ffe_flush_evaluation_metrics(void);
1011

11-
void ddtrace_ffe_record_exposure(zend_string *flag_key, zend_string *targeting_key, zend_string *subject_attributes_json, zend_string *allocation_key, zend_string *variant);
12+
void ddtrace_ffe_record_exposure(zend_string *flag_key, zend_string *targeting_key, zend_string *subject_attributes_json, zend_string *allocation_key, zend_string *variant, int32_t serial_id, bool has_serial_id);
1213
bool ddtrace_ffe_flush_exposures(void);
1314

1415
#endif // DDTRACE_FFE_H

tracer/functions.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1900,7 +1900,9 @@ PHP_FUNCTION(DDTrace_ffe_evaluate) {
19001900
targeting_key,
19011901
subject_attributes_json,
19021902
allocation_key,
1903-
variant
1903+
variant,
1904+
result.serial_id,
1905+
result.has_serial_id
19041906
);
19051907
zend_string_release(subject_attributes_json);
19061908
}

0 commit comments

Comments
 (0)