From a8f342e4c917af19160d4a3c39c890f134af0ed1 Mon Sep 17 00:00:00 2001 From: Karl Stenerud Date: Fri, 24 Oct 2025 16:18:39 +0200 Subject: [PATCH 1/2] Add support for feature flag matching --- .../fbs/logging/v1/buffer_log.fbs | 3 +++ .../protobuf/matcher/v1/log_matcher.proto | 10 ++++++++++ .../protobuf/workflow/v1/workflow.proto | 16 ++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/src/bitdrift_public/fbs/logging/v1/buffer_log.fbs b/src/bitdrift_public/fbs/logging/v1/buffer_log.fbs index e7ba21b..b92ea9b 100644 --- a/src/bitdrift_public/fbs/logging/v1/buffer_log.fbs +++ b/src/bitdrift_public/fbs/logging/v1/buffer_log.fbs @@ -36,6 +36,9 @@ enum LogType: uint32 { // Span start/end pairs. Span = 8, + + // Feature flag changes. + FeatureFlags = 9, } table Log { diff --git a/src/bitdrift_public/protobuf/matcher/v1/log_matcher.proto b/src/bitdrift_public/protobuf/matcher/v1/log_matcher.proto index 7de2c59..3ed41b6 100644 --- a/src/bitdrift_public/protobuf/matcher/v1/log_matcher.proto +++ b/src/bitdrift_public/protobuf/matcher/v1/log_matcher.proto @@ -95,10 +95,20 @@ message LogMatcher { } } + message FeatureFlagMatch { + string flag_name = 1 [(validate.rules).string = {min_len: 1, max_len: 64}]; + oneof value_match { + option (validate.required) = true; + StringValueMatch string_value_match = 2; + IsSetMatch is_set_match = 3; + } + } + oneof match_type { option (validate.required) = true; MessageMatch message_match = 1; TagMatch tag_match = 2; + FeatureFlagMatch feature_flag_match = 3; } } diff --git a/src/bitdrift_public/protobuf/workflow/v1/workflow.proto b/src/bitdrift_public/protobuf/workflow/v1/workflow.proto index f327d5b..5c4ad23 100644 --- a/src/bitdrift_public/protobuf/workflow/v1/workflow.proto +++ b/src/bitdrift_public/protobuf/workflow/v1/workflow.proto @@ -376,6 +376,8 @@ message Workflow { // The tag value is the body of the log. If the body is not present, no tag is added. bool log_body_extracted = 4; + + FeatureFlagExtracted feature_flag_extracted = 5; } } @@ -425,4 +427,18 @@ message Workflow { Exact exact = 2; } } + + // A value extracted from the feature flags. + message FeatureFlagExtracted { + string name = 1 [(validate.rules).string = {min_len: 1}]; + + message Exact { + }; + + // For now we only support exact match, but in the future we might support more complex + // extraction logic like regex captures. If not specified, the default is exact match. + oneof extraction_type { + Exact exact = 2; + } + } } From c37c1d19e462486009156b324d4cdc299bf4a1a7 Mon Sep 17 00:00:00 2001 From: Snow Pettersen Date: Fri, 31 Oct 2025 05:59:24 -0700 Subject: [PATCH 2/2] comments, remove fb --- src/bitdrift_public/fbs/logging/v1/buffer_log.fbs | 3 --- src/bitdrift_public/protobuf/matcher/v1/log_matcher.proto | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bitdrift_public/fbs/logging/v1/buffer_log.fbs b/src/bitdrift_public/fbs/logging/v1/buffer_log.fbs index b92ea9b..e7ba21b 100644 --- a/src/bitdrift_public/fbs/logging/v1/buffer_log.fbs +++ b/src/bitdrift_public/fbs/logging/v1/buffer_log.fbs @@ -36,9 +36,6 @@ enum LogType: uint32 { // Span start/end pairs. Span = 8, - - // Feature flag changes. - FeatureFlags = 9, } table Log { diff --git a/src/bitdrift_public/protobuf/matcher/v1/log_matcher.proto b/src/bitdrift_public/protobuf/matcher/v1/log_matcher.proto index 3ed41b6..c308cd8 100644 --- a/src/bitdrift_public/protobuf/matcher/v1/log_matcher.proto +++ b/src/bitdrift_public/protobuf/matcher/v1/log_matcher.proto @@ -95,11 +95,18 @@ message LogMatcher { } } + // Base matcher for evaluating the value of a feature flag. message FeatureFlagMatch { string flag_name = 1 [(validate.rules).string = {min_len: 1, max_len: 64}]; + oneof value_match { option (validate.required) = true; + + // Matches against the string value of the feature flag variant. If the variant + // is not set we'll match against the empty string. StringValueMatch string_value_match = 2; + + // Matches if the feature flag is set (regardless of variant). IsSetMatch is_set_match = 3; } }