logstash icon indicating copy to clipboard operation
logstash copied to clipboard

Generate Dataset code with meaningful fields names

Open andsel opened this issue 6 months ago • 2 comments

Release notes

[rn:skip]

What does this PR do?

Updates FieldDefinition to receive the name of the field from construction methods, so that it can be used during the code generation phase, instead of the existing incremental field%n.
Updates ClassFields to propagate the explicit field name down to the FieldDefinitions. Update the DatasetCompiler that add fields to ClassFields to assign a proper name to generated Dataset's fields.

Why is it important/What is the impact to the user?

This PR is intended to help Logstash developers or users that want to better understand the code that's autogenerated to model a pipeline, assigning more meaningful names to the fields.

Checklist

  • [x] My code follows the style guidelines of this project
  • [x] I have commented my code, particularly in hard-to-understand areas
  • ~~[ ] I have made corresponding changes to the documentation~~
  • ~~[ ] I have made corresponding change to the default configuration files (and/or docker env variables)~~
  • ~~[ ] I have added tests that prove my fix is effective or that my feature works~~

Author's Checklist

  • [ ] try some pipelines locally

How to test this PR locally

  • Edit the config/jvm.options adding flags to create files that contains the generated Dataset classes
-Dorg.codehaus.janino.source_debugging.enable=true
-Dorg.codehaus.janino.source_debugging.dir=/path/to/tmpjanino_logstash_datasets
  • run some pipelines and check the outcome in /path/to/tmpjanino_logstash_datasets
  • remember to wipe the output folder after each run
  • verify all field names in generated classes are meaningful in the context they are used

Related issues

  • Closes #16385

Use cases

Screenshots

Logs

andsel avatar Aug 12 '24 13:08 andsel