Skip to content

Moves TimeValue setting to java#18760

Open
andsel wants to merge 5 commits intoelastic:mainfrom
andsel:feature/timevalue_setting_to_java
Open

Moves TimeValue setting to java#18760
andsel wants to merge 5 commits intoelastic:mainfrom
andsel:feature/timevalue_setting_to_java

Conversation

@andsel
Copy link
Contributor

@andsel andsel commented Feb 9, 2026

Release notes

[rn:skip]

What does this PR do?

Moves the Ruby setting class TimeValue setting to Java. It covers the test in unit test while keeping and adapting the original time_value_spec.rb test suite to prove it still works on Ruby code.

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

N/A

Checklist

  • My code follows the style guidelines of this project
  • 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

  • Test using the setting on Logstash run.

How to test this PR locally

Change a setting that leverage this implementation and check it works as expected.

  1. create Logstash pipeline.conf file:

    input {
      generator {
        message => "Hello world!"
      }
    }
    
    output {
      sink {}
    }
    
  2. Update the reload interval setting in config/logstash.yml as:

    config.reload.automatic: true
    config.reload.interval: 30s
  3. run Logstash

    bin/logstash -f /path/to/pipeline.conf
  4. Update the pipeline.conf file, adding a comment for example, and verify in the logs the interval in pipeline reload is greater than 30 seconds.

Related issues

Logs

[2026-02-10T10:41:28,935][INFO ][logstash.javapipeline    ][main] Pipeline `main` is configured with `pipeline.ecs_compatibility: v8` setting. All plugins in this pipeline will default to `ecs_compatibility => v8` unless explicitly configured otherwise.
[2026-02-10T10:41:28,941][INFO ][logstash.javapipeline    ][main] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>12, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>1500, "batch_metric_sampling"=>"minimal", "pipeline.sources"=>["/Users/andrea/workspace/logstash_andsel/simple_generator_pipeline2.conf"], :thread=>"#<Thread:0x88a7390 /Users/andrea/workspace/logstash_andsel/logstash-core/lib/logstash/java_pipeline.rb:147 run>"}
[2026-02-10T10:41:28,955][INFO ][logstash.javapipeline    ][main] Pipeline Java execution initialization time {"seconds"=>0.01}
[2026-02-10T10:41:28,970][INFO ][logstash.javapipeline    ][main] Pipeline started {"pipeline.id"=>"main"}
[2026-02-10T10:41:28,978][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}


[2026-02-10T10:41:57,888][INFO ][logstash.pipelineaction.reload] Reloading pipeline {"pipeline.id"=>:main}
[2026-02-10T10:41:58,054][INFO ][logstash.javapipeline    ][main] Pipeline terminated {"pipeline.id"=>"main"}

@andsel andsel self-assigned this Feb 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /run exhaustive tests : Run the exhaustive tests Buildkite pipeline.

@mergify
Copy link
Contributor

mergify bot commented Feb 9, 2026

This pull request does not have a backport label. Could you fix it @andsel? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

@andsel
Copy link
Contributor Author

andsel commented Feb 10, 2026

run exhaustive tests

@andsel andsel changed the title Feature/timevalue setting to java Moves TimeValue setting to java Feb 10, 2026
subject.set(5)
expect(subject.value).to eq(LogStash::Util::TimeValue.new(5, :nanosecond))
expect(subject.value.to_nanos).to eq(5)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note for reviewer
The verification of deprecation logger switched implementation. However, this case is covered by the JUnit test case

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR moves the TimeValue-typed setting implementation from Ruby into a Java TimeValueSetting, updates Logstash core and x-pack to use it, and adds/updates tests to validate behavior across Java and Ruby.

Changes:

  • Introduces org.logstash.settings.TimeValueSetting (Java) with coercion and deprecation logging behavior.
  • Updates core and x-pack settings registration to use LogStash::Setting::TimeValueSetting.
  • Adds a Java unit test for TimeValueSetting and adapts the existing Ruby spec to target the new class.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
x-pack/spec/config_management/extension_spec.rb Updates spec expectations to reference TimeValueSetting.
x-pack/lib/monitoring/monitoring.rb Switches monitoring time-based settings to TimeValueSetting.
x-pack/lib/geoip_database_management/extension.rb Switches GeoIP poll interval setting to TimeValueSetting.
x-pack/lib/config_management/extension.rb Switches x-pack management poll interval setting to TimeValueSetting.
logstash-core/src/test/java/org/logstash/settings/TimeValueSettingTest.java Adds Java unit tests for default coercion, invalid values, and deprecation logging.
logstash-core/src/main/java/org/logstash/settings/TimeValueSetting.java Adds the new Java implementation of the time-value setting coercion.
logstash-core/spec/logstash/settings/time_value_spec.rb Updates Ruby spec to target TimeValueSetting and removes deprecation logging assertion.
logstash-core/lib/logstash/settings.rb Removes Ruby TimeValue class and imports the Java TimeValueSetting.
logstash-core/lib/logstash/environment.rb Updates built-in settings to use TimeValueSetting for time-based values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@andsel andsel marked this pull request as ready for review February 10, 2026 10:20
@elasticmachine
Copy link

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @andsel

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.

Reimplement LogStash::Setting::TimeValue to Java

2 participants