Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
34 changes: 28 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
<properties>
<revision>3</revision>
<changelist>999999-SNAPSHOT</changelist>
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<jenkins.baseline>2.504</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.1</jenkins.version>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This bump is required due to the workflow-api bump.
We can file this bump as a separate PR if requested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems it's already been filed: #1168

<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<opentelemetry.version>1.49.0</opentelemetry.version>
<jenkins-opentelemetry.version>1.49.0.75.v66006f513b_1f</jenkins-opentelemetry.version>
Expand Down Expand Up @@ -149,6 +149,22 @@
<artifactId>parsson</artifactId>
<version>1.1.7</version>
</dependency>
<dependency>
<!-- depends on https://github.com/jenkinsci/workflow-api-plugin/pull/417 -->
<!-- TODO remove when in bom -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>1409.v96d6da_eed7f7</version>
</dependency>
<dependency>
<!-- depends on https://github.com/jenkinsci/workflow-api-plugin/pull/417 -->
<!-- TODO remove when in bom -->
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>1409.v96d6da_eed7f7</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -176,6 +192,16 @@
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</exclusion>
<exclusion>
<!-- provided by org.jenkins-ci.plugins:jackson2-api -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<!-- provided by org.jenkins-ci.plugins:jackson2-api -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
Comment on lines +201 to +210
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix some "require upper bounds" maven issues.

</exclusions>
</dependency>
<dependency>
Expand Down Expand Up @@ -525,10 +551,6 @@
<version>1.21.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</exclusion>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to remove this exclusion due to https://issues.jenkins.io/browse/JENKINS-73355.
This dependency is mandatory for testcontainers.
This library has a test scope and is not bundled in the final HPI.

<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.model.Queue;
import hudson.model.Run;
import io.jenkins.plugins.opentelemetry.JenkinsControllerOpenTelemetry;
Expand All @@ -19,19 +18,19 @@
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.log.BrokenLogStorage;
import org.jenkinsci.plugins.workflow.log.LogStorage;
import org.jenkinsci.plugins.workflow.log.LogStorageFactory;
import org.jenkinsci.plugins.workflow.log.LogStorageFactoryDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Binds Otel Logs to Pipeline logs.
* <p>
* See <a href="https://github.com/jenkinsci/pipeline-cloudwatch-logs-plugin/blob/pipeline-cloudwatch-logs-0.2/src/main/java/io/jenkins/plugins/pipeline_cloudwatch_logs/PipelineBridge.java">Pipeline Cloudwatch Logs - PipelineBridge</a>
*/
@Extension
Copy link
Contributor Author

@jgreffe jgreffe Aug 8, 2025

Choose a reason for hiding this comment

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

With the Describable/Descriptor pattern, the @Extension is not supported anymore on the factory.

public final class OtelLogStorageFactory implements LogStorageFactory, OpenTelemetryLifecycleListener {

private static final Logger logger = Logger.getLogger(OtelLogStorageFactory.class.getName());
Expand All @@ -41,17 +40,15 @@
System.setProperty("org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep.USE_WATCHING", "true");
}

@Inject
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't inject anymore with the @Extension removal.

Copy link
Contributor

Choose a reason for hiding this comment

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

We use @Inject ~30 times in this plugin, is there a problem now with @Inject?

Copy link
Member

Choose a reason for hiding this comment

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

It was only a problem here because LogStorageFactory is no longer an ExtensionPoint after the upstream changes and so the implementations are no longer singleton @Extensions and so dependency injection doesn't work. In other contexts, @Inject is fine.

JenkinsControllerOpenTelemetry jenkinsControllerOpenTelemetry;
private JenkinsControllerOpenTelemetry jenkinsControllerOpenTelemetry;

@Nullable
private OtelTraceService otelTraceService;

private Tracer tracer;

static OtelLogStorageFactory get() {
return ExtensionList.lookupSingleton(OtelLogStorageFactory.class);
}
Comment on lines -52 to -54
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unused method.

@DataBoundConstructor
public OtelLogStorageFactory() {}

/**
* Create a LogStorage for a given FlowExecutionOwner
Expand Down Expand Up @@ -86,7 +83,7 @@
if (exec instanceof Run<?, ?> run && run.getAction(MonitoringAction.class) != null) {
// it's a pipeline with monitoring data
logger.log(Level.FINEST, () -> "forExec(" + run + ")");
ret = new OtelLogStorage(run, getOtelTraceService(), tracer);
ret = new OtelLogStorage(run, getOtelTraceService(), getTracer());
}
return ret;
}
Expand All @@ -113,8 +110,26 @@
return otelTraceService;
}

@PostConstruct
public void postConstruct() {
this.tracer = jenkinsControllerOpenTelemetry.getDefaultTracer();
Comment on lines -116 to -118
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Useless with the @Extension removal.

@NonNull
public Tracer getTracer() {
if (tracer == null) {

Check warning on line 115 in src/main/java/io/jenkins/plugins/opentelemetry/job/log/OtelLogStorageFactory.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 115 is only partially covered, one branch is missing
tracer = getJenkinsControllerOpenTelemetry().getDefaultTracer();
}
return tracer;
}

@Extension()
@Symbol("openTelemetry")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Describable/Descriptor pattern, the symbol "openTelemetry" is used for CasC configuration.

public static final class DescriptorImpl extends LogStorageFactoryDescriptor<OtelLogStorageFactory> {
@NonNull
@Override
public String getDisplayName() {
return "OpenTelemetry";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Displayed in the new "Pipeline logging" global UI configuration, see jenkinsci/workflow-api-plugin#417

}

@Override
public LogStorageFactory getDefaultInstance() {
return new OtelLogStorageFactory();
}
}
}
Loading