-
Notifications
You must be signed in to change notification settings - Fork 77
Update OtelLogStorageFactory to use last workflow-api changes
#1176
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
Changes from 4 commits
bd132f3
782d9d2
6a9ceae
7a5acad
31cbf17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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> | ||
| <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> | ||
|
|
@@ -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> | ||
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix some "require upper bounds" maven issues. |
||
| </exclusions> | ||
| </dependency> | ||
| <dependency> | ||
|
|
@@ -525,10 +551,6 @@ | |
| <version>1.21.3</version> | ||
| <scope>test</scope> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>org.apache.commons</groupId> | ||
| <artifactId>commons-compress</artifactId> | ||
| </exclusion> | ||
|
||
| <exclusion> | ||
| <groupId>org.slf4j</groupId> | ||
| <artifactId>slf4j-api</artifactId> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the Describable/Descriptor pattern, the |
||
| public final class OtelLogStorageFactory implements LogStorageFactory, OpenTelemetryLifecycleListener { | ||
|
|
||
| private static final Logger logger = Logger.getLogger(OtelLogStorageFactory.class.getName()); | ||
|
|
@@ -41,17 +40,15 @@ | |
| System.setProperty("org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep.USE_WATCHING", "true"); | ||
| } | ||
|
|
||
| @Inject | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't inject anymore with the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was only a problem here because |
||
| 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused method. |
||
| @DataBoundConstructor | ||
| public OtelLogStorageFactory() {} | ||
|
|
||
| /** | ||
| * Create a LogStorage for a given FlowExecutionOwner | ||
|
|
@@ -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; | ||
| } | ||
|
|
@@ -113,8 +110,26 @@ | |
| return otelTraceService; | ||
| } | ||
|
|
||
| @PostConstruct | ||
| public void postConstruct() { | ||
| this.tracer = jenkinsControllerOpenTelemetry.getDefaultTracer(); | ||
|
Comment on lines
-116
to
-118
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Useless with the |
||
| @NonNull | ||
| public Tracer getTracer() { | ||
| if (tracer == null) { | ||
| tracer = getJenkinsControllerOpenTelemetry().getDefaultTracer(); | ||
| } | ||
| return tracer; | ||
| } | ||
|
|
||
| @Extension() | ||
| @Symbol("openTelemetry") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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-apibump.We can file this bump as a separate PR if requested.
There was a problem hiding this comment.
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