logstash icon indicating copy to clipboard operation
logstash copied to clipboard

Generate Dataset code with meaningful fields names

Open andsel opened this issue 1 year 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

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

elastic-sonarqube[bot] avatar Sep 04 '24 08:09 elastic-sonarqube[bot]

:green_heart: Build Succeeded

History

  • :green_heart: Build #1409 succeeded 69c612cbf9867ea635a245e75f80792bae3c3124
  • :broken_heart: Build #1407 failed 703a662bd0e88278ec62be71b74dfc4e4cfd50af
  • :green_heart: Build #1393 succeeded 49e99a277ac8d584254d727967ee8c6741771132

cc @andsel

elasticmachine avatar Sep 04 '24 08:09 elasticmachine