-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
We are hosting a grpc service in a generic way except:
There are cases where we're running in the context of a user request, and add some work to a queue. A background thread will process the queue generically, grouping multiple queue entries into an aggregate operation. An example would be communicating something to another service via grpc, but it's more efficient to have a single grpc request with a repeated field for many items, rather than a bunch of individual grpc requests.
In this case, the background processing has its own context, and the individual request contexts are restored when their individual futures are completed.
When using the java agent with grpc instrumentation, we are getting the following error.
"Context ancestry chain length is abnormally long. This suggests an error in application code. Length exceeded: 1000"
I understand this is sort of a expected behavior since there is a bridge between grpc context and otel context. So when different otel contexts create the bridge to the same(default/root) grpc context, it will be messed up.
My question is what is the best practice to handle this kind of "non-context executor"? It makes a lot of sense from application efficiency/perf perspective. But it makes instrumentation hard.