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: validation integration, part 1 #700

Merged
merged 8 commits into from
Jun 5, 2023
Merged

feat: validation integration, part 1 #700

merged 8 commits into from
Jun 5, 2023

Conversation

kentquirk
Copy link
Contributor

@kentquirk kentquirk commented Jun 4, 2023

Which problem is this PR solving?

This fleshes out the validation config file and makes it really work.

The validation system needed to be part of Refinery itself; I tried putting it in its own library, but it made more sense to make it an integral part of config.

Short description of the changes

  • Moves the validation logic into Config
  • Rename the validation data file and instances of it to metadata and into a validation object
  • Use the object in the convert tool
  • Embed the metadata file into the binary
  • Lots of tests of the validation logic
  • Update the metadata file to include all the validations
  • It successfully checks the complete config file without errors

This does not do rule validation yet -- that's next.

This also does not integrate the validation into Refinery's loading yet, although that is just a few lines of code. That will come after rule validation.

@kentquirk kentquirk requested a review from a team as a code owner June 4, 2023 01:01
Copy link
Contributor

@TylerHelmuth TylerHelmuth left a comment

Choose a reason for hiding this comment

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

LGTM

@echo
@echo "+++ validating sample config"
@echo
go run . validate --input=minimal_config.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
go run . validate --input=minimal_config.yaml
go run . validate --input=minimal_config.yaml

@kentquirk kentquirk merged commit 7bd8c59 into main Jun 5, 2023
@kentquirk kentquirk deleted the kent.validation branch June 5, 2023 19:09
kentquirk added a commit that referenced this pull request Jun 6, 2023
…#701)

Note: this PR is dependent on #700 -- that one should be merged first.

## Which problem is this PR solving?

- Adds complete rules validation to the validation system, plus a few
bonus features.

## Short description of the changes

- Add a rulesMeta.yaml file to describe the rules data.
- Extend the validation system to handle a structure nested more deeply
than the basic config validation, which was only 2 layers deep. This
meant adding objects and arrays of objects.
- Add a few more validation features to support the new semantics.
- Add a "did you mean...?" feature to suggest the proper spelling if
someone gets something wrong. This is particularly useful when you get
the case wrong.
- Generate a .md file from the rules metadata; it's not yet pretty but
it's a good start. Will improve before release.

It's been validated against the converted rules_complete rules file. 

## Example results:
Rule snippet
```
    dataset4:
        RuleBasedSampler:
            Rules:
```
Validation: 
```
Validation Errors in rules file:
  Within sampler dataset4: unknown group RuleBasedSampler; did you mean RulesBasedSampler?
```

Rule snippet
```
Samplers:
    dataset1:
        DynamicSampler:
            ClearFrequency: 1
            SamplerRate: 10
            FieldList:
                - 10
                - request.method
                - http.target
                - response.status_code
            UseTraceLength: "true"
```
Validation: 
```
Validation Errors in rules file:
  Within sampler dataset1: field DynamicSampler.UseTraceLength must be a bool
  Within sampler dataset1: field DynamicSampler.ClearFrequency (1) must be a valid duration like '3m30s' or '100ms'
  Within sampler dataset1: unknown field DynamicSampler.SamplerRate; did you mean SampleRate?
  Within sampler dataset1: field DynamicSampler.FieldList must be a string array but contains non-string 10
  Within sampler dataset1: the group DynamicSampler is missing its required field SampleRate
```

I'm really happy with this -- it makes it almost impossible to make a
major error in your rules.

Next up: run the validators on Refinery startup.

Closes #566 
Closes #559 
Closes #518
Closes #273 
Closes #266
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.

2 participants