GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@suraj-qlogic

@suraj-qlogic suraj-qlogic commented May 19, 2020

Copy link
Copy Markdown
Contributor

Fixes #109

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 19, 2020
@codecov

codecov Bot commented May 19, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Merging #130 into master will decrease coverage by 1.12%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             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              
Impacted Files Coverage Δ Complexity Δ
...java/com/google/cloud/datastore/DatastoreImpl.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ain/java/com/google/cloud/datastore/TraceUtil.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...oogle/cloud/datastore/spi/v1/HttpDatastoreRpc.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d572efb...9d85b03. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@suraj-qlogic
suraj-qlogic requested a review from BenWhitehead May 19, 2020 06:26
@skuruppu

skuruppu commented May 20, 2020

Copy link
Copy Markdown

@mayurkale22, would you be able to take a quick look at this PR to see if OpenCensus is being used correctly? Thanks heaps.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@suraj-qlogic
suraj-qlogic force-pushed the java-datastore-109 branch from d16bb7e to da7fead Compare May 20, 2020 06:18
mayurkale22
mayurkale22 reviewed May 20, 2020
View reviewed changes
Comment thread pom.xml Outdated
<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>

@mayurkale22 mayurkale22 May 20, 2020

Copy link
Copy Markdown

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.

I would use latest version: 0.26.0.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Recently google-cloud-shared-dependencies was added in this client which is pull latest version automatically.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java Outdated
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);

@mayurkale22 mayurkale22 May 20, 2020

Copy link
Copy Markdown

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
elharo
elharo reviewed May 20, 2020
View reviewed changes
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java Outdated
this.datastoreRpc = options.getDatastoreRpcV1();
retrySettings =
MoreObjects.firstNonNull(options.getRetrySettings(), ServiceOptions.getNoRetrySettings());
traceUtil = TraceUtil.getInstance();

@elharo elharo May 20, 2020

Copy link
Copy Markdown
Contributor

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.

just set this in the declaration on line 57

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java Outdated
@@ -131,29 +136,41 @@ public T call() throws DatastoreException {
@Override
public <T> T runInTransaction(final TransactionCallable<T> callable) {
final DatastoreImpl self = this;

@elharo elharo May 20, 2020

Copy link
Copy Markdown
Contributor

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.

this self variable seems pointless

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java Outdated
@Override
public <T> T runInTransaction(
final TransactionCallable<T> callable, TransactionOptions transactionOptions) {
final DatastoreImpl self = this;

@elharo elharo May 20, 2020

Copy link
Copy Markdown
Contributor

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.

ditto

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java Outdated
final TransactionCallable<T> callable, TransactionOptions transactionOptions) {
final DatastoreImpl self = this;
Span span = traceUtil.startSpan(TraceUtil.SPAN_NAME_TRANSACTION);
Scope scope = traceUtil.getTracer().withSpan(span);

@elharo elharo May 20, 2020

Copy link
Copy Markdown
Contributor

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.

You can use try with resources for the scope

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java Outdated
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);

@elharo elharo May 20, 2020

Copy link
Copy Markdown
Contributor

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.

You can use try with resources for the scope (unless the order of closing the span would be wrong?)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/TraceUtil.java Outdated
* 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.

@elharo elharo May 20, 2020

Copy link
Copy Markdown
Contributor

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.

instances

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/TraceUtil.java Outdated
*/
public class TraceUtil {
private final Tracer tracer = Tracing.getTracer();
private static TraceUtil traceUtil;

@elharo elharo May 20, 2020

Copy link
Copy Markdown
Contributor

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.

final

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/TraceUtil.java
*
* @return An instance of {@link TraceUtil}
*/
public static TraceUtil getInstance() {

@elharo elharo May 20, 2020

Copy link
Copy Markdown
Contributor

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.

no need, just create a TraceUtil on the field

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/HttpDatastoreRpc.java Outdated
// Open Census initialization
CensusHttpModule censusHttpModule =
new CensusHttpModule(TraceUtil.getInstance().getTracer(), true);
delegate = censusHttpModule.getHttpRequestInitializer(delegate);

@elharo elharo May 20, 2020

Copy link
Copy Markdown
Contributor

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.

try to avoid reassigning local variables

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@suraj-qlogic suraj-qlogic May 21, 2020

Copy link
Copy Markdown
Contributor Author

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.

Done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@suraj-qlogic
suraj-qlogic requested a review from elharo May 21, 2020 05:37
@suraj-qlogic

suraj-qlogic commented May 21, 2020

Copy link
Copy Markdown
Contributor Author

@mayurkale22 PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mayurkale22
mayurkale22 approved these changes May 21, 2020
View reviewed changes

@mayurkale22 mayurkale22 left a comment

Copy link
Copy Markdown

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.

Added one comment, overall LGTM.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java
EXCEPTION_HANDLER,
getOptions().getClock());
} catch (RetryHelperException e) {
span.setStatus(Status.UNKNOWN.withDescription(e.getMessage()));

@mayurkale22 mayurkale22 May 21, 2020

Copy link
Copy Markdown

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.

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.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@suraj-qlogic

suraj-qlogic commented May 22, 2020

Copy link
Copy Markdown
Contributor Author

@elharo PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@suraj-qlogic

suraj-qlogic commented May 28, 2020

Copy link
Copy Markdown
Contributor Author

@elharo gentle ping

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@suraj-qlogic
suraj-qlogic force-pushed the java-datastore-109 branch from 26986bd to 0c18852 Compare May 29, 2020 11:37
@suraj-qlogic suraj-qlogic self-assigned this May 29, 2020
suraj-qlogic added 2 commits June 4, 2020 12:14
@suraj-qlogic
feat: add opencensus tracing/stats support
c6806ab
@suraj-qlogic
feat: fix review changes
9d85b03
@suraj-qlogic
suraj-qlogic force-pushed the java-datastore-109 branch from 0c18852 to 9d85b03 Compare June 4, 2020 06:49
@suraj-qlogic

suraj-qlogic commented Jun 4, 2020

Copy link
Copy Markdown
Contributor Author

@BenWhitehead @elharo PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

BenWhitehead
BenWhitehead suggested changes Jun 4, 2020
View reviewed changes
Comment thread google-cloud-datastore/src/main/java/com/google/cloud/datastore/TraceUtil.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@suraj-qlogic
suraj-qlogic requested a review from BenWhitehead June 8, 2020 03:05
BenWhitehead
BenWhitehead approved these changes Jun 8, 2020
View reviewed changes
@BenWhitehead
BenWhitehead merged commit 5aee52f into googleapis:master Jun 8, 2020
gcf-merge-on-green Bot pushed a commit that referenced this pull request Jun 17, 2020
@release-please
chore: release 1.104.0 (#154)
e72ee3c
🤖 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).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@elharo elharo Awaiting requested review from elharo
2 more reviewers
@BenWhitehead BenWhitehead BenWhitehead approved these changes
@mayurkale22 mayurkale22 mayurkale22 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@suraj-qlogic suraj-qlogic

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add OpenCensus tracing/stats support

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@suraj-qlogic @skuruppu @elharo @BenWhitehead @mayurkale22 @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.