Incompatibility with OkHttp 4.x since 1.52.0

Abierto
#8,001 12 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
30/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
java

Línea de trabajo

Comienza con el pom.xml del reproductor y ejecuta mvn install para confirmar el fallo de requireUpperBoundDeps de okhttp 4.12.0 frente a los artefactos de OpenTelemetry. Después, inspecciona las declaraciones de dependencias de Maven para opentelemetry-exporter-sender-okhttp, opentelemetry-sdk-extension-jaeger-remote-sampler y opentelemetry-bom; el resultado debe conservar la compatibilidad con okhttp 4.x y establecer cómo se gestionan los artefactos afectados.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Java
Estrellas
2.5k
Forks
1.1k
Merge medio
5 d 11 h
PR fusionados (30 d)
41

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de open-telemetry/opentelemetry-java

Todos los issues de open-telemetry/opentelemetry-java

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.