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

Add parsing for nested json fields in the rules sampler #418

Merged
merged 6 commits into from
Mar 29, 2022

Conversation

ecobrien29
Copy link
Contributor

@ecobrien29 ecobrien29 commented Mar 7, 2022

Which problem is this PR solving?

Adds support for checking nested JSON when validating rules. The option can be enabled using the CheckNestedFields configuration option.

Short description of the changes

  • Adds a json parser module to allow retrieval of nested fields for the rules sampler. If the field is not found in the top level of the span, it calls the get function to check if it exists in the nested json.

@ecobrien29 ecobrien29 requested a review from a team March 7, 2022 19:17
@MikeGoldsmith MikeGoldsmith self-assigned this Mar 8, 2022
@MikeGoldsmith MikeGoldsmith added type: enhancement New feature or request version: bump minor A PR that adds behavior, but is backwards-compatible. labels Mar 8, 2022
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.

I like the overall solution but I'm concerned with enabling JSON parsing of span data for all condition failures. This should be configuration driven to enable his behaviour.

sample/rules.go Outdated
@@ -70,6 +72,16 @@ func (s *RulesBasedSampler) GetSampleRate(trace *types.Trace) (rate uint, keep b
for _, span := range trace.GetSpans() {
var match bool
value, exists := span.Data[condition.Field]
if !exists {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm concerned this would impact users that does not want to pay the cost of attempting to JSON parse span data when trying to resolve rule conditions.

I think we should look into adding an opt-in configuration option to enable this behaviour. Default would be disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. I can add an optional parameter in the rules config file to enable it (similar to the AddSampleRateKeyToTrace and UseTraceLength fields), unless you think there is a better place for it.

@MikeGoldsmith MikeGoldsmith added the status: revision needed Waiting for response to changes requested. label Mar 8, 2022
@vreynolds vreynolds removed the status: revision needed Waiting for response to changes requested. label Mar 14, 2022
@ecobrien29
Copy link
Contributor Author

I made the requested changes and tested with the refinery I have running with the nested fields parameter both enabled and disabled. The nested traces were correctly sampled when enabled and didn't affect normal sampling rules.

@vreynolds
Copy link
Contributor

Thanks @ecobrien29! We've had a busy couple weeks, but we'll take another look as soon as we can!

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 good, thank you for the follow-up and sorry for the delay in getting back to you.

@MikeGoldsmith MikeGoldsmith merged commit 153a398 into honeycombio:main Mar 29, 2022
ghost pushed a commit to opsramp/tracing-proxy that referenced this pull request Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request version: bump minor A PR that adds behavior, but is backwards-compatible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow nested JSON fields for rules sampling config
3 participants