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

Add grpc sent event before sending the message #11413

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,17 @@ public void start(Listener<RESPONSE> responseListener, Metadata headers) {

@Override
public void sendMessage(REQUEST message) {
Span span = Span.fromContext(context);
Attributes attributes =
Attributes.of(MESSAGE_TYPE, SENT, MESSAGE_ID, MESSAGE_ID_UPDATER.incrementAndGet(this));
span.addEvent("message", attributes);

try (Scope ignored = context.makeCurrent()) {
super.sendMessage(message);
} catch (Throwable e) {
instrumenter.end(context, request, Status.UNKNOWN, e);
throw e;
}
Span span = Span.fromContext(context);
Attributes attributes =
Attributes.of(MESSAGE_TYPE, SENT, MESSAGE_ID, MESSAGE_ID_UPDATER.incrementAndGet(this));
span.addEvent("message", attributes);
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking (guessing) that it's better to only emit the event when the message is successfully sent (or if we're going to emit it when it fails to note the failure somehow in the event that is emitted)

I think it's fine to loosen the assertion ordering constraint

}

final class TracingClientCallListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@ TracingServerCallListener start(Metadata headers, ServerCallHandler<REQUEST, RES

@Override
public void sendMessage(RESPONSE message) {
try (Scope ignored = context.makeCurrent()) {
super.sendMessage(message);
}
Span span = Span.fromContext(context);
Attributes attributes =
Attributes.of(MESSAGE_TYPE, SENT, MESSAGE_ID, MESSAGE_ID_UPDATER.incrementAndGet(this));
span.addEvent("message", attributes);

try (Scope ignored = context.makeCurrent()) {
super.sendMessage(message);
}
}

@Override
Expand Down
Loading