GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat: add opencensus tracing/stats support by suraj-qlogic · Pull Request #130 · googleapis/java-datastore
This repository was archived by the owner on Feb 24, 2026. It is now read-only.
Conversation
Contributor
Fixes #109
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was an error while loading. Please reload this page.
Codecov Report
@@ Coverage Diff @@ ## master #130 +/- ## ============================================ - Coverage 58.30% 57.17% -1.13% Complexity 384 384 ============================================ Files 47 48 +1 Lines 2331 2377 +46 Branches 261 264 +3 ============================================ Hits 1359 1359 - Misses 865 911 +46 Partials 107 107
Continue to review full report at Codecov.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@mayurkale22, would you be able to take a quick look at this PR to see if OpenCensus is being used correctly? Thanks heaps. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d16bb7e to
da7fead
Compare
| <guava.version>29.0-android</guava.version> | ||
| <threeten.version>1.4.4</threeten.version> | ||
| <javax.annotations.version>1.3.2</javax.annotations.version> | ||
| <opencensus.version>0.24.0</opencensus.version> |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I would use latest version: 0.26.0.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Recently google-cloud-shared-dependencies was added in this client which is pull latest version automatically.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| com.google.datastore.v1.BeginTransactionResponse beginTransaction( | ||
| final com.google.datastore.v1.BeginTransactionRequest requestPb) { | ||
| Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_BEGINTRANSACTION); | ||
| Scope scope = traceUtil.getTracer().withSpan(span); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Personally, I prefer to use try-with-resources for scope. It implements AutoClosable, so it'll be closed when the try block ends. Ex:
try (Scope s = tracer.withSpan(span)) { ... rest of the logic }
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| this.datastoreRpc = options.getDatastoreRpcV1(); | ||
| retrySettings = | ||
| MoreObjects.firstNonNull(options.getRetrySettings(), ServiceOptions.getNoRetrySettings()); | ||
| traceUtil = TraceUtil.getInstance(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
just set this in the declaration on line 57
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -131,29 +136,41 @@ public T call() throws DatastoreException { | |||
| @Override | |||
| public <T> T runInTransaction(final TransactionCallable<T> callable) { | |||
| final DatastoreImpl self = this; | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
this self variable seems pointless
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @Override | ||
| public <T> T runInTransaction( | ||
| final TransactionCallable<T> callable, TransactionOptions transactionOptions) { | ||
| final DatastoreImpl self = this; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ditto
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| final TransactionCallable<T> callable, TransactionOptions transactionOptions) { | ||
| final DatastoreImpl self = this; | ||
| Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_TRANSACTION); | ||
| Scope scope = traceUtil.getTracer().withSpan(span); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You can use try with resources for the scope
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| com.google.datastore.v1.RunQueryResponse runQuery( | ||
| final com.google.datastore.v1.RunQueryRequest requestPb) { | ||
| Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_RUNQUERY); | ||
| Scope scope = traceUtil.getTracer().withSpan(span); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You can use try with resources for the scope (unless the order of closing the span would be wrong?)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * Helper class for tracing utility. It is used for instrumenting {@link HttpDatastoreRpc} with Open | ||
| * Census APIs. | ||
| * | ||
| * <p>TraceUtil Instance are created by the {@link TraceUtil#getInstance()} method. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
instances
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| */ | ||
| public class TraceUtil { | ||
| private final Tracer tracer = Tracing.getTracer(); | ||
| private static TraceUtil traceUtil; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
final
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * | ||
| * @return An instance of {@link TraceUtil} | ||
| */ | ||
| public static TraceUtil getInstance() { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
no need, just create a TraceUtil on the field
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // Open Census initialization | ||
| CensusHttpModule censusHttpModule = | ||
| new CensusHttpModule(TraceUtil.getInstance().getTracer(), true); | ||
| delegate = censusHttpModule.getHttpRequestInitializer(delegate); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
try to avoid reassigning local variables
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@mayurkale22 PTAL |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Added one comment, overall LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| EXCEPTION_HANDLER, | ||
| getOptions().getClock()); | ||
| } catch (RetryHelperException e) { | ||
| span.setStatus(Status.UNKNOWN.withDescription(e.getMessage())); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason for Status.UNKNOWN instead of status.INTERNAL? Generally, an example of (UNKNOWN) where this error may be returned is if a Status value received from another address space belongs to an error-space that is not known in this address space. On the other side, Internal errors mean some invariants expected by underlying system has been broken.
Also, DEADLINE_EXCEEDED can be useful in case of retries exceeded.
Having said that, I am not familiar with datastore codebase. Feel free to ignore if you disagree.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@elharo PTAL |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@elharo gentle ping |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
26986bd to
0c18852
Compare
0c18852 to
9d85b03
Compare
|
@BenWhitehead @elharo PTAL |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
🤖 I have created a release \*beep\* \*boop\* --- ## [1.104.0](https://www.github.com/googleapis/java-datastore/compare/v1.103.0...v1.104.0) (2020-06-17) ### Features * add opencensus tracing/stats support for Datastore RPC operations ([#130](https://www.github.com/googleapis/java-datastore/issues/130)) ([5aee52f](https://www.github.com/googleapis/java-datastore/commit/5aee52f5013d6780e523e0c6d7d00a1826b83b9b)) * add support to customize gcloud command of LocalDatastoreHelper ([#137](https://www.github.com/googleapis/java-datastore/issues/137)) ([976d979](https://www.github.com/googleapis/java-datastore/commit/976d9791572117dc703d8d7d6963bdd6603ecd63)) ### Bug Fixes * fix version number in changelog to correctly reflect what was released to maven central ([#145](https://www.github.com/googleapis/java-datastore/issues/145)) ([c509a2a](https://www.github.com/googleapis/java-datastore/commit/c509a2a4229f864edef8681677d73f3c7be1101f)) ### Dependencies * update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.0 ([#161](https://www.github.com/googleapis/java-datastore/issues/161)) ([39c8d72](https://www.github.com/googleapis/java-datastore/commit/39c8d723b318d08ca494b71167eaa80b1df6423d)) * update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.1 ([#163](https://www.github.com/googleapis/java-datastore/issues/163)) ([7bfa07e](https://www.github.com/googleapis/java-datastore/commit/7bfa07eb3a7cf84fcf3e19f6a33914162fa28499)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Add OpenCensus tracing/stats support
There was an error while loading. Please reload this page.