-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 initial opencensus instrumentation code in Cloud Storage. #2846
Add initial opencensus instrumentation code in Cloud Storage. #2846
Conversation
// Open Census initialization | ||
censusHttpModule = new CensusHttpModule(tracer, true); | ||
initializer = censusHttpModule.getHttpRequestInitializer(initializer); | ||
batchRequestInitializer = censusHttpModule.getHttpRequestInitializer(null); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -112,7 +129,8 @@ public HttpStorageRpc(StorageOptions options) { | |||
private DefaultRpcBatch(Storage storage) { | |||
this.storage = storage; | |||
batches = new LinkedList<>(); | |||
batches.add(storage.batch()); | |||
// add OpenCensus HttpRequestInitializer | |||
batches.add(storage.batch(batchRequestInitializer)); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -162,12 +180,22 @@ public void addGet(StorageObject storageObject, RpcBatch.Callback<StorageObject> | |||
|
|||
@Override | |||
public void submit() { |
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.
|
||
/** | ||
* An {@link HttpRequestInitializer} implementation to set {@link CensusHttpExecuteInterceptor} as | ||
* intercptor. |
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.
@HailongWen I see the WIP in the title. Is this ready to review now? |
@pongad Yes. Sorry for the confusion. I have changed the title. |
LGTM +1 |
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 as well. @garrettjonesgoogle do you want to take a look?
@@ -162,12 +180,22 @@ public void addGet(StorageObject storageObject, RpcBatch.Callback<StorageObject> | |||
|
|||
@Override | |||
public void submit() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
google-cloud-bom/pom.xml
Outdated
@@ -1052,11 +1052,21 @@ | |||
<artifactId>opencensus-api</artifactId> | |||
<version>${opencensus.version}</version> | |||
</dependency> | |||
<dependency> |
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.
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.
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.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* Add helper class `CensusHttpModule` to do trace context propagation. * Add helper class `HttpStorageRpcSpans` to define and register different span names. * Add instrumentation code in `HttpStorageRpc`. * Update errorprone version to 2.2.0.
bae5c39
to
f14c3bb
Compare
Thank you all for the help and support! |
This PR adds OpenCensus-Java instrumentation to monitor and record events in Cloud Storage client and propagate the trace context via HTTP headers to google service.
Note that there is another PR to instrument underlying library google-http-java-client is also instrumented so as to provide detailed span break down. In case that we don't catch up new release of google-http-java-client, in this PR I still added helper class to do context propagation.
There are 3 major changes in this PR:
CensusHttpModule
to do trace context propagation throughHttpHeaders
. (might be temporary - can be removed if google-http-java-client release new version)HttpStorageRpcSpans
, which contains all span names and a method to register them all for collection.HttpStorageRpc
. The instrumented code starts a newSpan
the main logic of the method begins, set it as current span withTracer.withSpan
. If exception occurs during the execution, the span status will be set toStatus.UNKNOWN
to indicate unparsed exception. The span and its scope will be ended before method exits.All the above
Span
s will be stored into local span store, and can be optionally exported if user explicitly configure an exporter (e.g. stackdriver exporter).Please @hzyi-google and @bogdandrutu kindly help review.