Incompatibility with OkHttp 4.x since 1.52.0

未关闭
#8,001 12 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java

调研方向

从 reproducer 的 pom.xml 开始,运行 mvn install,以确认 okhttp 4.12.0 相对于 OpenTelemetry artifacts 的 requireUpperBoundDeps 失败。然后检查 opentelemetry-exporter-sender-okhttp、opentelemetry-sdk-extension-jaeger-remote-sampler 和 opentelemetry-bom 的 Maven 依赖声明;完成后应保留与 okhttp 4.x 的兼容性,并确定受影响 artifacts 的管理方式。

由索引模型根据 Issue 内容生成。

描述

Bug

Describe the bug

Since v1.52.0, opentelemetry-exporter-sender-okhttp and opentelemetry-sdk-extension-jaeger-remote-sampler started to depend on okhttp 5.x. If my application still needs depend on okhttp 4.x, I will not be able to upgrade to newer versions of opentelemetry.

Furthermore, if any of my dependencies (e.g. google-cloud-storage) upgraded any opentelemetry artifacts beyond 1.52.0, I will not be able to upgrade them as well if I use opentelemetry-bom 1.51.0. This is because both aforementioned artifacts are in the bom.

Steps to reproduce
Given the following pom configuration

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.opentelemetry</groupId>
                <artifactId>opentelemetry-bom</artifactId>
                <version>1.52.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>

    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-exporter-sender-okhttp</artifactId>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.12.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.6.2</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <configuration>
                            <rules>
                                <requireUpperBoundDeps>
                                </requireUpperBoundDeps>
                            </rules>
                        </configuration>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

running mvn install would produce the following upper bound dependencies error

[ERROR] Require upper bound dependencies error for com.squareup.okhttp3:okhttp:4.12.0. Paths to dependency are:
[ERROR] +-org.example:testOtelOKHttp:1.0-SNAPSHOT
[ERROR]   +-com.squareup.okhttp3:okhttp:4.12.0
[ERROR] and
[ERROR] +-org.example:testOtelOKHttp:1.0-SNAPSHOT
[ERROR]   +-io.opentelemetry:opentelemetry-exporter-sender-okhttp:1.52.0
[ERROR]     +-com.squareup.okhttp3:okhttp:5.1.0 [runtime]

What did you expect to see?
I can continue to use okhttp 4.x and opentelemetry 1.52.0+ without being forced to upgrade my application.

What version and what artifacts are you using?
Artifacts: opentelemetry-exporter-sender-okhttp, opentelemetry-sdk-extension-jaeger-remote-sampler, opentelemetry-bom
Version: v1.52.0
How did you reference these artifacts? pom.xml

Environment
Compiler: Temurin-24.0.1
OS: MacOS 15.7.3

Workarounds

  1. Ignoring the enforcer errors and force okhttp version to 4.12.0. This could potentially work if opentelemetry-exporter-sender-okhttp does not use any new features from 5.x, otherwise there could be runtime errors. However, even if it works, force downgrading major versions is risky and error prone. It would break if someone starts to use new features from 5.x accidentally.
  2. Only downgrade opentelemetry-exporter-sender-okhttp to 1.51.0, still use opentelemetry-bom 1.52.0 to manage other opentelemetry artifacts such as opentelemetry-api. However, this requires more work like downgrading versions of transitive dependency kotlin-stdlib-jdk8. Managing different versions of opentelemetry artifacts is also costly and error prone in large corps with thousands of repos.

Possible solutions
Downgrade okhttp to 4.12.0 to maintain backward compatibility. Only upgrade it to the next major version if needed.

In addition, consider removing exporters such as opentelemetry-exporter-sender-okhttp and opentelemetry-sdk-extension-jaeger-remote-sampler from opentelemetry-bom. The problem of them being included in the bom is that, if a third party library is only dependent on opentelemetry-api and upgraded it to the latest, it would force the users of the third party library to bump opentelemetry-bom and all transitive dependencies included in it. IMO, the opentelemetry-bom should only manage core libraries with minimum transitive dependencies. The exporters should follow a different version strategy as well.

Separately, regarding the general upgrading strategy of transitive dependencies. I think it's OK to keep them up to date if there are no breaking changes, since people can always upgrade them to latest if needed. However, for major version bump (okhttp 4.x to 5.x) that contains a lot of breaking changes, upgrading it should be very careful since users of opentelemetry would be forced to upgrade their codebase. Depending on the scenario, upgrading major versions of transitive dependencies may warrant a major version bump.

主要语言
Java
星标
2.5k
派生
1.1k
平均合并
5 天 11 小时
30 天内合并 PR
41

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

open-telemetry/opentelemetry-java 的其他 Issue

查看 open-telemetry/opentelemetry-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。