Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Fields option for rules #949

Merged
merged 5 commits into from
Dec 14, 2023
Merged

feat: Add Fields option for rules #949

merged 5 commits into from
Dec 14, 2023

Conversation

kentquirk
Copy link
Contributor

@kentquirk kentquirk commented Dec 13, 2023

Which problem is this PR solving?

This adds a new option for Rules -- instead of specifying Field which is a single field name, it's now possible to specify Fields, which takes an array of field names. The evaluator iterates over each field in turn and returns the first field that exists in the incoming span.

This will allow users to write rules that account for field name changes like the upcoming http semantic convention changes.

Short description of the changes

  • Add new Fields element to rules data structure
  • Validate that both Field and Fields do not exist, both in the loading code as well as the validator
  • Modify Init() so that it copies Field to Fields so that the evaluation code is clean
  • Modify evaluation code
  • Write some tests
  • Fix some old tests that didn't call Init()
  • Document this in metadata
  • Add examples to rules_complete
  • Regenerate docs files

fix #952

@kentquirk kentquirk requested a review from a team as a code owner December 13, 2023 23:39
@kentquirk kentquirk added this to the v2.3 milestone Dec 13, 2023
Copy link
Contributor

@MikeGoldsmith MikeGoldsmith left a comment

Choose a reason for hiding this comment

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

Looks great 👍🏻

I've left open query regarding fail on first match vs attempting all field names and a suggestion around simplifying the check when copying field into fields.

config/metadata/rulesMeta.yaml Show resolved Hide resolved
config/sampler_config.go Outdated Show resolved Hide resolved
Co-authored-by: Mike Goldsmith <goldsmith.mike@gmail.com>
@kentquirk kentquirk merged commit ab6268c into main Dec 14, 2023
3 checks passed
@kentquirk kentquirk deleted the kent.multi_column branch December 14, 2023 14:09
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.

Allow users to write rules that account for field name changes
2 participants