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

deprecate pipeline bus v1 #16643

Open
wants to merge 2 commits into
base: 8.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@

package org.logstash.plugins.pipeline;

import co.elastic.logstash.api.DeprecationLogger;
import com.google.common.annotations.VisibleForTesting;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.logstash.ext.JrubyEventExtLibrary;
import org.logstash.log.DefaultDeprecationLogger;

import java.util.Collection;
import java.util.Optional;
Expand All @@ -37,6 +39,7 @@
public interface PipelineBus {

Logger LOGGER = LogManager.getLogger(PipelineBus.class);
DeprecationLogger DEPRECATION_LOGGER = new DefaultDeprecationLogger(LOGGER);

/**
* API-stable entry-point for creating a {@link PipelineBus}
Expand All @@ -45,7 +48,9 @@ public interface PipelineBus {
static PipelineBus create() {
final String pipelineBusImplementation = System.getProperty("logstash.pipelinebus.implementation", "v2");
switch (pipelineBusImplementation) {
case "v1": return new PipelineBusV1();
case "v1":
DEPRECATION_LOGGER.deprecated("The legacy pipeline bus selected with `logstash.pipelinebus.implementation=v1` is deprecated, and will be removed in a future release of Logstash");
Copy link
Member

Choose a reason for hiding this comment

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

It seems like configuring pipeline bus implementation setting itself is or should be deprecated. Maybe the deprecation should be focused on removing that setting rather than the value it is set to.

return new PipelineBusV1();
Copy link
Member

Choose a reason for hiding this comment

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

It looks like in the case we have an "unknown" configuration setting we "default" to v1 still. Maybe as part of calling out v1 is deprecated we can also change that fallback to also be v2.

diff --git a/logstash-core/src/main/java/org/logstash/plugins/pipeline/PipelineBus.java b/logstash-core/src/main/java/org/logstash/plugins/pipeline/PipelineBus.java
index 487793d62..b10fa6729 100644
--- a/logstash-core/src/main/java/org/logstash/plugins/pipeline/PipelineBus.java
+++ b/logstash-core/src/main/java/org/logstash/plugins/pipeline/PipelineBus.java
@@ -54,7 +54,7 @@ public interface PipelineBus {
             case "v2": return new PipelineBusV2();
             default:
                 LOGGER.warn("unknown pipeline-bus implementation: {}", pipelineBusImplementation);
-                return new PipelineBusV1();
+                return new PipelineBusV2();
         }
     }

case "v2": return new PipelineBusV2();
default:
LOGGER.warn("unknown pipeline-bus implementation: {}", pipelineBusImplementation);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.logstash.log;

import org.apache.logging.log4j.core.*;
import org.apache.logging.log4j.test.appender.ListAppender;
import org.junit.rules.ExternalResource;

import java.util.List;

public class LoggingSpyResource extends ExternalResource {

private static final String APPENDER_NAME = "spyAppender";

private final Logger loggerToSpyOn;
private final ListAppender appender = new ListAppender(APPENDER_NAME);

public LoggingSpyResource(final org.apache.logging.log4j.Logger loggerToSpyOn) {
this.loggerToSpyOn = (Logger) loggerToSpyOn;
}

@Override
protected void before() throws Throwable {
appender.start();
loggerToSpyOn.addAppender(appender);
}

@Override
protected void after() {
loggerToSpyOn.removeAppender(appender);
}

public List<LogEvent> getLogEvents() {
return List.copyOf(appender.getEvents());
}
}
Loading
Loading