jenkinsci / opentelemetry-plugin

Monitor and observe Jenkins with OpenTelemetry.
https://plugins.jenkins.io/opentelemetry/
Apache License 2.0
93 stars 47 forks source link

TeeBuildListener incompatible with OutputStreamTaskListener #749

Closed ukinimod closed 6 months ago

ukinimod commented 7 months ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.414.3 OS: Linux - 6.2.0-36-generic Java: 11.0.20.1 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- Office-365-Connector:4.20.0 SquishPlugin:8.6 active-directory:2.34 analysis-model-api:11.11.0 ant:497.v94e7d9fffa_b_9 antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 authentication-tokens:1.53.v1c90fd9191a_b_ blueocean:1.27.8 blueocean-bitbucket-pipeline:1.27.8 blueocean-commons:1.27.8 blueocean-config:1.27.8 blueocean-core-js:1.27.8 blueocean-dashboard:1.27.8 blueocean-display-url:2.4.2 blueocean-events:1.27.8 blueocean-git-pipeline:1.27.8 blueocean-github-pipeline:1.27.8 blueocean-i18n:1.27.8 blueocean-jwt:1.27.8 blueocean-personalization:1.27.8 blueocean-pipeline-api-impl:1.27.8 blueocean-pipeline-editor:1.27.8 blueocean-pipeline-scm-api:1.27.8 blueocean-rest:1.27.8 blueocean-rest-impl:1.27.8 blueocean-web:1.27.8 bootstrap5-api:5.3.2-2 bouncycastle-api:2.29 branch-api:2.1128.v717130d4f816 build-blocker-plugin:1.7.9 build-monitor-plugin:1.14-745.ve2023a_305f40 build-timeout:1.31 build-timestamp:1.0.3 caffeine-api:3.1.8-133.v17b_1ff2e0599 checks-api:2.0.2 clone-workspace-scm:84.v147686859e1c cloudbees-bitbucket-branch-source:848.v42c6a_317eda_e cloudbees-disk-usage-simple:187.v6378d330d1d4 cloudbees-folder:6.858.v898218f3609d cobertura:1.17 code-coverage-api:4.99.0 command-launcher:100.v2f6722292ee8 commons-httpclient3-api:3.1-3 commons-lang3-api:3.13.0-62.v7d18e55f51e2 commons-text-api:1.10.0-78.v3e7b_ea_d5a_fe1 configuration-as-code:1714.v09593e830cfa coverage:1.2.0 credentials:1307.v3757c78f17c3 credentials-binding:642.v737c34dea_6c2 dashboard-view:2.495.v07e81500c3f2 data-tables-api:1.13.6-5 description-setter:1.10 display-url-api:2.200.vb_9327d658781 docker-commons:439.va_3cb_0a_6a_fb_29 docker-workflow:572.v950f58993843 downstream-ext:73.vdda_16e6eb_0da dtkit-api:3.0.2 durable-task:523.va_a_22cf15d5e0 echarts-api:5.4.0-7 email-ext:2.102 favorite:2.4.3 file-parameters:316.va_83a_1221db_a_7 font-awesome-api:6.4.2-1 forensics-api:2.3.0 git:5.2.0 git-client:4.5.0 github:1.37.3.1 github-api:1.316-451.v15738eef3414 github-branch-source:1741.va_3028eb_9fd21 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 htmlpublisher:1.32 http_request:1.18 instance-identity:173.va_37c494ec4e5 ionicons-api:56.v1b_1c8c49374e jackson2-api:2.15.3-366.vfe8d1fa_f8c87 jakarta-activation-api:2.0.1-3 jakarta-mail-api:2.0.1-3 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.9-1 jdk-tool:66.vd8fa_64ee91b_d jenkins-design-language:1.27.8 jjwt-api:0.11.5-77.v646c772fddb_0 jobConfigHistory:1229.v3039470161a_d jquery3-api:3.7.1-1 junit:1240.vf9529b_881428 ldap:711.vb_d1a_491714dc lockable-resources:1185.v0c528656ce04 mailer:463.vedf8358e006b_ mapdb-api:1.0.9-28.vf251ce40855d matrix-auth:3.2.1 matrix-project:818.v7eb_e657db_924 metrics:4.2.18-442.v02e107157925 mina-sshd-api-common:2.11.0-86.v836f585d47fa_ mina-sshd-api-core:2.11.0-86.v836f585d47fa_ monitoring:1.95.0 nodelabelparameter:1.12.0 okhttp-api:4.11.0-157.v6852a_a_fa_ec11 opentelemetry:2.18.0 pam-auth:1.10 parameterized-scheduler:255.v73827fcdf618 pipeline-build-step:516.v8ee60a_81c5b_9 pipeline-github-lib:42.v0739460cda_c4 pipeline-graph-analysis:202.va_d268e64deb_3 pipeline-groovy-lib:689.veec561a_dee13 pipeline-input-step:477.v339683a_8d55e pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2150.v4cfd8916915c pipeline-model-definition:2.2150.v4cfd8916915c pipeline-model-extensions:2.2150.v4cfd8916915c pipeline-rest-api:2.33 pipeline-stage-step:305.ve96d0205c1c6 pipeline-stage-tags-metadata:2.2150.v4cfd8916915c pipeline-stage-view:2.33 pipeline-utility-steps:2.16.0 plain-credentials:143.v1b_df8b_d3b_e48 plugin-util-api:3.6.0 prism-api:1.29.0-8 prometheus:2.3.3 pubsub-light:1.18 scm-api:676.v886669a_199a_a_ script-security:1275.v23895f409fb_d snakeyaml-api:2.2-111.vc6598e30cc65 sse-gateway:1.26 ssh-agent:333.v878b_53c89511 ssh-credentials:308.ve4497b_ccd8f4 ssh-slaves:2.916.vd17b_43357ce4 sshd:3.303.vefc7119b_ec23 startup-trigger-plugin:2.9.4 stash-pullrequest-builder:1.17 stashNotifier:1.439.v202358346a_7d structs:325.vcb_307d2a_2782 subversion:2.17.3 support-core:1362.vf5fe14238165 timestamper:1.26 token-macro:384.vf35b_f26814ec translation:1.16 trilead-api:2.84.v72119de229b_7 update-sites-manager:2.0.0 variant:60.v7290fc0eb_b_cd warnings-ng:10.5.1 windows-slaves:1.8.1 workflow-aggregator:596.v8c21c963d92d workflow-api:1283.v99c10937efcb_ workflow-basic-steps:1042.ve7b_140c4a_e0c workflow-cps:3806.va_3a_6988277b_2 workflow-durable-task-step:1289.v4d3e7b_01546b_ workflow-job:1360.vc6700e3136f5 workflow-multibranch:756.v891d88f2cd46 workflow-scm-step:415.v434365564324 workflow-step-api:639.v6eca_cd8c04a_a_ workflow-support:865.v43e78cc44e0d xunit:3.1.3 xvnc:1.28 ``` Configuration of otel Plugin ``` text otel.exporter.otlp.protocol=grpc otel.instrumentation.jenkins.web.enabled=false otel.logs.exporter=otlp otel.logs.mirror_to_disk=true otel.metrics.exporter=none ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Docker with Linux - 6.2.0-36-generic

Reproduction steps

  1. Configure Logging in OTel
  2. Run Job
  3. See System logs on Warn level

Expected Results

No Warning should be emitted

Actual Results

System Log contains:

[...] WARNING org.jenkinsci.plugins.workflow.log.OutputStreamTaskListener getOutputStream
Unexpected PrintStream subclass io.jenkins.plugins.opentelemetry.job.log.util.TeePrintStream which might override write(…); error handling is degraded unless OutputStreamTaskListener is used: io.jenkins.plugins.opentelemetry.job.log.util.TeeBuildListener

Anything else?

No response

cyrille-leclerc commented 7 months ago

We are aware of this warning message. Unfortunately, it's not easy to tacklee it at the moment as we are still compatible with older versions of Jenkins Core that didn't have this warning message so we didn't explore the problem.

Do you face problems related to this warning?

ukinimod commented 7 months ago

We don't face critical problems. Due to the high amount of messages and the way the OTel Plugin (as far as I know it ships logs of default log recorder) and the Jenkins logging works (default log recorder cannot be configured to set the level of the OutputStreamTaskListener logger to ERROR), we had to deactivate WARN messages for Jenkins completely to save bandwidth and disk space. Of course, this is a workaround that we don't want to keep. If there is anything I can do to solve the problem in the plugin or to create a temporary workaround, I would gladly assist.

DuMaM commented 6 months ago

In our case, it's about 40k-60k warnings per day, so it's starting to affect on performance of our Jenkins instance. Furthermore, we upgraded the core from 2.375 to 2.414, and It's still present.

cyrille-leclerc commented 6 months ago

Warning message was

Then warning was supposed to be removed for core implementations in July 30th 2023 in https://github.com/jenkinsci/workflow-api-plugin/releases/tag/1251.vd4889a_b_0a_065

With current pom.xml, we are on workflow-api:jar:1213.xxx and we need at least v1248.xxx

io.jenkins.plugins:opentelemetry:hpi:2.19.1-SNAPSHOT
+- io.opentelemetry:opentelemetry-api:jar:1.33.0:compile
|  \- io.opentelemetry:opentelemetry-context:jar:1.33.0:compile
+- io.opentelemetry:opentelemetry-api-events:jar:1.33.0-alpha:compile
+- io.opentelemetry:opentelemetry-sdk:jar:1.33.0:compile
|  +- io.opentelemetry:opentelemetry-sdk-common:jar:1.33.0:compile
|  \- io.opentelemetry:opentelemetry-sdk-logs:jar:1.33.0:compile
+- io.opentelemetry.semconv:opentelemetry-semconv:jar:1.23.1-alpha:compile
+- io.opentelemetry:opentelemetry-sdk-trace:jar:1.33.0:compile
+- io.opentelemetry:opentelemetry-sdk-metrics:jar:1.33.0:compile
|  \- io.opentelemetry:opentelemetry-extension-incubator:jar:1.33.0-alpha:runtime
+- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:jar:1.33.0:compile
+- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:jar:1.33.0:compile
+- io.opentelemetry:opentelemetry-extension-trace-propagators:jar:1.33.0:compile
+- io.opentelemetry.instrumentation:opentelemetry-resources:jar:1.32.0-alpha:compile
|  +- io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:jar:1.32.0:compile
|  \- io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv:jar:1.32.0-alpha:compile
+- io.opentelemetry.instrumentation:opentelemetry-runtime-telemetry-java8:jar:1.32.0-alpha:compile
+- io.opentelemetry.contrib:opentelemetry-aws-resources:jar:1.32.0-alpha:compile
+- io.opentelemetry:opentelemetry-exporter-otlp:jar:1.33.0:compile
|  +- io.opentelemetry:opentelemetry-exporter-otlp-common:jar:1.33.0:runtime
|  |  \- io.opentelemetry:opentelemetry-exporter-common:jar:1.33.0:runtime
|  \- io.opentelemetry:opentelemetry-exporter-sender-okhttp:jar:1.33.0:runtime
+- io.opentelemetry:opentelemetry-exporter-prometheus:jar:1.33.0-alpha:compile
+- io.opentelemetry:opentelemetry-exporter-logging:jar:1.33.0:compile
+- jakarta.json:jakarta.json-api:jar:2.1.3:compile
+- org.eclipse.parsson:parsson:jar:1.1.4:compile
+- io.prometheus:simpleclient_httpserver:jar:0.16.0:compile
|  +- io.prometheus:simpleclient:jar:0.16.0:compile
|  |  +- io.prometheus:simpleclient_tracer_otel:jar:0.16.0:compile
|  |  |  \- io.prometheus:simpleclient_tracer_common:jar:0.16.0:compile
|  |  \- io.prometheus:simpleclient_tracer_otel_agent:jar:0.16.0:compile
|  \- io.prometheus:simpleclient_common:jar:0.16.0:compile
+- io.jenkins.plugins:okhttp-api:jar:4.10.0-132.v7a_7b_91cef39c:compile
|  +- com.squareup.okio:okio:jar:3.3.0:compile
|  |  \- com.squareup.okio:okio-jvm:jar:3.3.0:compile
|  +- com.squareup.okhttp3:okhttp:jar:4.10.0:compile
|  +- com.squareup.okhttp3:logging-interceptor:jar:4.10.0:compile
|  +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.8.10:compile
|  +- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.8.10:compile
|  +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.8.10:compile
|  \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.8.10:compile
+- com.google.errorprone:error_prone_annotations:jar:2.23.0:compile
+- org.jenkins-ci.plugins:jackson2-api:jar:2.15.1-344.v6eb_55303dc3e:compile
|  +- com.fasterxml.jackson.core:jackson-databind:jar:2.15.1:compile
|  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.15.1:compile
|  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.15.1:compile
|  +- com.fasterxml.jackson.datatype:jackson-datatype-json-org:jar:2.15.1:compile
|  +- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.15.1:compile
|  +- com.fasterxml.jackson.core:jackson-core:jar:2.15.1:compile
|  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.15.1:compile
|  +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.15.1:compile
|  +- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.15.1:compile
|  +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.15.1:compile
|  |  +- org.codehaus.woodstox:stax2-api:jar:4.2.1:compile
|  |  \- com.fasterxml.woodstox:woodstox-core:jar:6.5.1:compile
|  +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.15.1:compile
|  +- io.jenkins.plugins:javax-activation-api:jar:1.2.0-6:compile
|  |  \- com.sun.activation:javax.activation:jar:1.2.0:compile
|  +- io.jenkins.plugins:jaxb:jar:2.3.8-1:compile
|  |  +- com.sun.xml.bind:jaxb-impl:jar:2.3.8:compile
|  |  \- javax.xml.bind:jaxb-api:jar:2.3.1:compile
|  \- io.jenkins.plugins:snakeyaml-api:jar:1.33-95.va_b_a_e3e47b_fa_4:compile
|     \- org.yaml:snakeyaml:jar:1.33:compile
+- org.jenkins-ci.plugins:credentials:jar:1254.vb_96f366e7b_a_d:compile
|  \- org.jenkins-ci.plugins:structs:jar:324.va_f5d6774f3a_d:compile
+- org.jenkins-ci.plugins:plain-credentials:jar:143.v1b_df8b_d3b_e48:compile
+- org.jenkins-ci.plugins.workflow:workflow-job:jar:1295.v395eb_7400005:compile
|  +- io.jenkins.plugins:ionicons-api:jar:45.vf54fca_5d2154:compile
|  +- org.jenkins-ci.plugins.workflow:workflow-step-api:jar:639.v6eca_cd8c04a_a_:compile
|  +- org.jenkins-ci.plugins.workflow:workflow-api:jar:1213.v646def1087f9:compile
|  \- org.jenkins-ci.plugins.workflow:workflow-support:jar:839.v35e2736cfd5c:compile
|     \- org.jboss.marshalling:jboss-marshalling-river:jar:2.1.0.Final:compile
|        \- org.jboss.marshalling:jboss-marshalling:jar:2.1.0.Final:compile
...
cyrille-leclerc commented 6 months ago

@kuisathaverat I propose we bump our dependency on Jenkins Core from 2.387.x to the following LTS, 2.401.x to be able to work on this problem of TeeBuildListener vs OutputStreamTaskListener

kuisathaverat commented 6 months ago

Sure, 2.401.x is fine. I have to fix a couple of bugs first and enable the logs test again.

cyrille-leclerc commented 6 months ago

FYI I'll open a PR, the fix is almost implemented.

DuMaM commented 6 months ago

thanks :)