You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My vertx kotlin application runs runBlocking code and makes a great number of grpc calls to the server. I'm using javaagent (version 2.4.0) for auto-instrumentation on my client.
Making grpc calls with kotlin grpc stub and collecting flow leads to this error: May 20, 2024 8:21:17 PM io.grpc.Context validateGeneration SEVERE: Context ancestry chain length is abnormally long. This suggests an error in application code. Length exceeded: 1000 java.lang.Exception at io.grpc.Context.validateGeneration(Context.java:1110) at io.grpc.Context.<init>(Context.java:191) at io.grpc.Context.fork(Context.java:404) at io.opentelemetry.javaagent.shaded.instrumentation.grpc.v1_6.internal.ContextStorageBridge.current(ContextStorageBridge.java:138) at io.grpc.Context.current(Context.java:172) at opentelemetry.GrpcClientKotlinStub$Companion$main$1.invokeSuspend(GrpcClientKotlinStub.kt:53) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:99) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104) at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:608) at io.vertx.reactivex.ContextScheduler$ContextWorker$TimedAction.run(ContextScheduler.java:190) at io.vertx.reactivex.ContextScheduler$ContextWorker$TimedAction.lambda$execute$1(ContextScheduler.java:175) at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:191) at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:279) at io.vertx.core.impl.ContextImpl.lambda$internalExecuteBlocking$2(ContextImpl.java:210) at io.opentelemetry.javaagent.bootstrap.executors.ContextPropagatingRunnable.run(ContextPropagatingRunnable.java:37)
During debugging I found out that grpc context is being forked all the time despite the new independent grpc call. Adding io.opentelemetry.context.Context.current().asContextElement() fixes the issue but having kotlinx-coroutines module inside javaagent should be enough
Steps to reproduce
`class GrpcClientKotlinStub {
companion object {
val vertx = Vertx.vertx()
val openTelemetryContext = io.opentelemetry.context.Context.current().asContextElement()
@JvmStatic
fun main(): Unit = runBlocking(vertx.blockingDispatcher(false)) {
val channel = ManagedChannelBuilder
.forAddress("localhost", 8080)
.usePlaintext()
.build()
val count = AtomicInteger()
(1..600).map { n ->
val stub = BofficerApiGrpcKt.BofficerApiCoroutineStub(channel)
println(n)
stub.hello(HelloRequest.getDefaultInstance())
.collect {
count.incrementAndGet()
}
val context2 = Context.current()
val generationField2 = Context::class.java.getDeclaredField("generation")
generationField2.isAccessible = true
println("generation after: ${generationField2.get(context2) as Int}")
}
println("after request, got ${count.get()} items")
channel.shutdown()
}
}
}
fun main() {
GrpcClientKotlinStub.main()
}`
Expected behavior
No problem with making grpc call using kotlin coroutines and opentelemetry at the same time
Actual behavior
Exception in io.grpc.Context validateGeneration due to a great number of forks
Javaagent or library instrumentation version
2.4.0
Environment
JDK: 17.0.6 OS: Ubuntu 20.04.3 LTS
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
My vertx kotlin application runs runBlocking code and makes a great number of grpc calls to the server. I'm using javaagent (version 2.4.0) for auto-instrumentation on my client.
Making grpc calls with kotlin grpc stub and collecting flow leads to this error:
May 20, 2024 8:21:17 PM io.grpc.Context validateGeneration SEVERE: Context ancestry chain length is abnormally long. This suggests an error in application code. Length exceeded: 1000 java.lang.Exception at io.grpc.Context.validateGeneration(Context.java:1110) at io.grpc.Context.<init>(Context.java:191) at io.grpc.Context.fork(Context.java:404) at io.opentelemetry.javaagent.shaded.instrumentation.grpc.v1_6.internal.ContextStorageBridge.current(ContextStorageBridge.java:138) at io.grpc.Context.current(Context.java:172) at opentelemetry.GrpcClientKotlinStub$Companion$main$1.invokeSuspend(GrpcClientKotlinStub.kt:53) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:28) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:99) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104) at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:608) at io.vertx.reactivex.ContextScheduler$ContextWorker$TimedAction.run(ContextScheduler.java:190) at io.vertx.reactivex.ContextScheduler$ContextWorker$TimedAction.lambda$execute$1(ContextScheduler.java:175) at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:191) at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:279) at io.vertx.core.impl.ContextImpl.lambda$internalExecuteBlocking$2(ContextImpl.java:210) at io.opentelemetry.javaagent.bootstrap.executors.ContextPropagatingRunnable.run(ContextPropagatingRunnable.java:37)
During debugging I found out that grpc context is being forked all the time despite the new independent grpc call. Adding
io.opentelemetry.context.Context.current().asContextElement()
fixes the issue but having kotlinx-coroutines module inside javaagent should be enoughSteps to reproduce
`class GrpcClientKotlinStub {
}
fun main() {
GrpcClientKotlinStub.main()
}`
Expected behavior
No problem with making grpc call using kotlin coroutines and opentelemetry at the same time
Actual behavior
Exception in io.grpc.Context validateGeneration due to a great number of forks
Javaagent or library instrumentation version
2.4.0
Environment
JDK: 17.0.6
OS: Ubuntu 20.04.3 LTS
Additional context
No response
The text was updated successfully, but these errors were encountered: