Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix grpc instrumentation of callbacks #4097

Merged
merged 4 commits into from
Sep 13, 2021
Merged

Fix grpc instrumentation of callbacks #4097

merged 4 commits into from
Sep 13, 2021

Conversation

trask
Copy link
Member

@trask trask commented Sep 12, 2021

Resolves #4088

@@ -143,6 +143,124 @@ abstract class AbstractGrpcTest extends InstrumentationSpecification {
paramName << ["some name", "some other name"]
}

def "test callback"() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test using GreeterFutureStub too? It should work but will test the more common usage.

AtomicReference<Throwable> error = new AtomicReference<>()
CountDownLatch latch = new CountDownLatch(1)
runWithSpan("parent") {
def future = client.sayHello(Helloworld.Request.newBuilder().setName("test").build())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth using the idiomatic API

def future = Futures.transform(
  client.sayHelo(...)
  response -> {
    runWithSpan("child");
    return response;
  },
  MoreExecutors.directExecutor());

try {
  response.set(future.get());
 } catch (Throwable t) {
  error.set(t);
}

@trask trask merged commit 098aee0 into open-telemetry:main Sep 13, 2021
@trask trask deleted the grpc-callbacks branch September 13, 2021 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gRPC client interceptor: incorrect parent span attribution for spans following asynchronous calls
4 participants