Skip to content

Commit

Permalink
fix NoSuchMethodError in Otel SDK shutdown
Browse files Browse the repository at this point in the history
Apparently, there's more than one okhttp3 on the classpath. We shade ours into
a private copy to eliminate the clash.

```
Exception in thread "okhttp-dispatch-1" java.lang.NoSuchMethodError: 'okhttp3.Headers okhttp3.Response.trailers()'
    at io.opentelemetry.exporter.sender.okhttp.internal.OkHttpGrpcSender.grpcStatus(OkHttpGrpcSender.java:169)
    at io.opentelemetry.exporter.sender.okhttp.internal.OkHttpGrpcSender.access$000(OkHttpGrpcSender.java:64)
    at io.opentelemetry.exporter.sender.okhttp.internal.OkHttpGrpcSender$1.onResponse(OkHttpGrpcSender.java:149)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
```
  • Loading branch information
barend-xebia committed Dec 3, 2024
1 parent 3be76ec commit 2e44bd6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,24 @@ lazy val `spot-complete` = projectMatrix
// The spot-complete subproject has no purpose as a stand-alone JAR file, we only care about the assembly.
Compile / packageBin / artifactName := { (_, _, _) => "_ignore-me.jar" },
Compile / packageBin / publishArtifact := false,
// The scala library is shipped with Spark, we don't need our own copy.
assembly / assemblyOption ~= {
_.withIncludeScala(false)
},
assembly / assemblyMergeStrategy := {
// TODO this okio business may well be wrong. Revisit this once we have an integration test to run.
case "META-INF/versions/9/module-info.class" => MergeStrategy.last
case "META-INF/okio.kotlin_module" => MergeStrategy.last
// We don't need the module files, easiest way out of the name class is to leave them out.
case "META-INF/versions/9/module-info.class" => MergeStrategy.discard
case "META-INF/okio.kotlin_module" => MergeStrategy.discard
case x =>
val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
oldStrategy(x)
}
},
assembly / assemblyShadeRules := Seq(
// The opentelemetry gRPC sender relies on OkHttp. It also exists somewhere else in a Spark classpath, and
// we've seen classpath version issues, specifically NoSuchMethodError. We use shading as a workaround,
// because then we don't have to make any assumptions about our target environment.
ShadeRule.rename("okhttp3.**" -> "spot.shaded.okhttp3.@1", "okio.**" -> "spot.shaded.okio.@1").inAll
),
)

lazy val root = projectMatrix
Expand Down

0 comments on commit 2e44bd6

Please sign in to comment.