Skip to content

Conversation

masseyke
Copy link
Member

DRAFT FOR SHARING CODE ONLY

Prototype of random sampling TTL

masseyke and others added 30 commits October 7, 2025 13:59
…mpling/TransportPutSampleConfigurationAction.java

Co-authored-by: Copilot <[email protected]>
# Conflicts:
#	server/src/main/java/org/elasticsearch/ingest/SamplingService.java
#	server/src/test/java/org/elasticsearch/ingest/UpdateSamplingConfigurationExecutorTests.java
@masseyke masseyke added the :Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP label Oct 10, 2025
@masseyke masseyke requested a review from Copilot October 14, 2025 21:40
Copy link
Contributor

@Copilot 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 implements a random sampling TTL (Time-To-Live) prototype that automatically removes expired sampling configurations. The implementation adds a scheduled job that periodically checks for expired configurations and removes them from the cluster state.

Key changes:

  • Added TTL checking functionality with configurable polling interval
  • Modified SamplingService constructor to accept Settings instead of time supplier
  • Integrated SamplingService into Node lifecycle management

Reviewed Changes

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

Show a summary per file
File Description
SamplingService.java Core implementation of TTL functionality with scheduler and lifecycle management
NodeConstruction.java Updated constructor call to pass settings instead of time supplier
Node.java Added SamplingService to node start/stop/close lifecycle
ClusterSettings.java Registered TTL_POLL_INTERVAL_SETTING as cluster setting
SamplingServiceTests.java Updated test to use new constructor signature
SamplingServiceIT.java Added integration test for TTL functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


private final SetOnce<SchedulerEngine> scheduler = new SetOnce<>();
private SchedulerEngine.Job scheduledJob;
private volatile TimeValue pollInterval = TimeValue.timeValueSeconds(1);
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

The default pollInterval value (1 second) conflicts with the TTL_POLL_INTERVAL_SETTING default (30 minutes). This could cause confusion and should be initialized from the setting's default value.

Suggested change
private volatile TimeValue pollInterval = TimeValue.timeValueSeconds(1);
private volatile TimeValue pollInterval = TTL_POLL_INTERVAL_SETTING.getDefault(Settings.EMPTY);

Copilot uses AI. Check for mistakes.

Comment on lines 53 to 54
"@timestamp",
randomTimeValue().toHumanReadableString(2),
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

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

Using randomTimeValue().toHumanReadableString(2) for @timestamp field is problematic. The toHumanReadableString() method returns human-readable format like '1.5s' which is not a valid timestamp format. This should be an ISO timestamp string or epoch milliseconds.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/Ingest Node Execution or management of Ingest Pipelines including GeoIP v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants