-
Notifications
You must be signed in to change notification settings - Fork 453
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 OpenCensus tracing instrumentation in google-http-client module. #393
Add OpenCensus tracing instrumentation in google-http-client module. #393
Conversation
30e4166
to
9b542cf
Compare
Hi @mattwhisenhunt , would you please kindly help on this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Sets the {@link TextFormat} used in context propagation. | ||
* @param textFormat the text format. | ||
*/ | ||
public static void setPropagationTextFormat(@Nullable TextFormat textFormat) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* Sets the {@link TextFormat.Setter} used in context propagation. | ||
* @param textFormatSetter the {@code TextFormat.Setter} for the text format. | ||
*/ | ||
public static void setPropagationTextFormatSetter(@Nullable TextFormat.Setter textFormatSetter) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* {@link TextFormat.Setter} for {@link activeTextFormat}. | ||
*/ | ||
@Nullable | ||
static TextFormat.Setter propagationTextFormatSetter = null; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -854,7 +865,9 @@ public HttpResponse execute() throws IOException { | |||
Preconditions.checkNotNull(requestMethod); | |||
Preconditions.checkNotNull(url); | |||
|
|||
Span span = tracer.spanBuilder(traceSpanNamePrefix + "execute").startSpan(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
public static void propagateTracingContext(HttpHeaders headers) { | ||
Preconditions.checkNotNull(headers); | ||
if (propagationTextFormat != null && propagationTextFormatSetter != null) { | ||
Span span = tracer.getCurrentSpan(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -1057,6 +1076,7 @@ public HttpResponse execute() throws IOException { | |||
} | |||
} | |||
} while (retryRequest); | |||
span.end(OpenCensusUtils.getEndSpanOptions(response == null ? null : response.getStatusCode())); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -977,6 +992,8 @@ public HttpResponse execute() throws IOException { | |||
|
|||
// execute | |||
lowLevelHttpRequest.setTimeout(connectTimeout, readTimeout); | |||
// switch tracing scope to current span | |||
Scope ws = tracer.withSpan(span); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
…r-plugin to v3.8.1 (googleapis#393)
This PR adds OpenCensus-Java instrumentation in to monitor and record events when executing
HttpExecute#execute()
.The instrumentation starts a
Span
when the method begins, and is ended before the method exits. The status of the span will be determined according to the status of the response. ThisSpan
is stored into local span store, and can be optionally exported if user explicitly configure an exporter (e.g. stackdriver exporter).Span
s can have children. In this case, the generatedSpan
in the instrumentation will be parent of all theSpan
s generated by server-side procedure. To link the childrenSpan
with their parent, the context information should be propagated to server side. This is done by using OpenCensus HTTP Util to inject the information into the header in the request.Added
OpenCensusUtils
provides helper methods to perform context propagation, and setting end status of span.The added dependency of
opencensus-api
contains basic no-op implementation. It will be replaced by real implementation if user explicitly adds dependency ofopencensus-impl
oropencensus-impl-lite
(for android and gae) in the classpath.This PR does not contain integration test when
opencensus-impl
is provided. It can be added with the help of maintainers.