Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

grpc-java page added #228

Merged
merged 3 commits into from Aug 9, 2018
Merged

grpc-java page added #228

merged 3 commits into from Aug 9, 2018

Conversation

odeke-em
Copy link
Member

@odeke-em odeke-em commented Aug 9, 2018

Updates #221

Adapted from
https://medium.com/@orijtech/opencensus-for-java-grpc-developers-23c25de0a057

but quite changed up, for more hands on instructions
along with tabbed runnable code samples and screenshots.

@odeke-em
Copy link
Member Author

odeke-em commented Aug 9, 2018

And for some screenshots

screen shot 2018-08-08 at 6 59 18 pm
screen shot 2018-08-08 at 6 59 28 pm
screen shot 2018-08-08 at 6 59 37 pm
screen shot 2018-08-08 at 6 59 45 pm
screen shot 2018-08-08 at 6 59 52 pm
screen shot 2018-08-08 at 7 00 01 pm
screen shot 2018-08-08 at 7 00 07 pm
screen shot 2018-08-08 at 7 00 16 pm
screen shot 2018-08-08 at 7 00 25 pm
screen shot 2018-08-08 at 7 00 33 pm
screen shot 2018-08-08 at 7 00 38 pm


Using OpenCensus, we can collect traces and metrics of our system and export them to the backend of our choice, to give observability to our distributed systems.

The `grpc-java` implementation has already been instrumented with OpenCensus for tracing and metrics. To enable tracing and metrics, we'll import and use the OpenCensus gRPC plugin.
Copy link
Contributor

@songy23 songy23 Aug 9, 2018

Choose a reason for hiding this comment

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

There's no "OpenCensus gRPC plugin" in Java, gRPC-Java has already been instrumented (in gRPC-core). Application users need to add runtime dependency on OpenCensus-Java impl, then the instrumentation should just work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha, thanks for the correction and suggestion. I'll update that shortly.


We'll instrument the server by tracing as well as tracing gRPC metrics using OpenCensus with imports such as:

Import|Purpose
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you also imported io.opencensus.exporter.trace.stackdriver and io.opencensus.exporter.stats.stackdriver?

Copy link
Member Author

Choose a reason for hiding this comment

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

Roger that, I'll add them.

static class FetchImpl extends FetchGrpc.FetchImplBase {
@Override
public void capitalize(Payload req, StreamObserver<Payload> responseObserver) {
Span span = TutorialServer.tracer.spanBuilder("octutorials.FetchImpl.capitalize").startSpan();
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be better to also put this span into current context, i.e

Span span = ...;
Scope scope = tracer.withSpan(span);
try {
...
} ... 
finally {
  scope.close();
  span.end();
  ...
}

Since in real application, TutorialServer could act as a client and make an RPC to another server.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, in deed, I meant to do that actually, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually that's stale code that I left in that segment in question, down below I changed that up to start a ScopedSpan. I'll update that, thanks.

@odeke-em
Copy link
Member Author

odeke-em commented Aug 9, 2018

@songy23 I've updated with your feedback, thank you and PTAL!

@@ -761,6 +764,16 @@ public class TutorialServer {

##### Instrumenting the client

We'll instrument the server by tracing as well as tracing gRPC metrics using OpenCensus with imports such as:
Copy link
Contributor

Choose a reason for hiding this comment

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

s/server/client

Updates #221

Adapted from
https://medium.com/@orijtech/opencensus-for-java-grpc-developers-23c25de0a057

but quite changed up, for more hands on instructions
along with tabbed runnable code samples and screenshots.
* Weight changes to ensure alphabetic changes between:
"Go" and "Java", lest it organizes them by entry date

* Some typo fixes for Java entries
@odeke-em
Copy link
Member Author

odeke-em commented Aug 9, 2018

Awesome, thanks @songy23 for the review!

@odeke-em odeke-em merged commit 1a6c0b8 into census-instrumentation:master Aug 9, 2018
@odeke-em odeke-em deleted the grpc-java branch September 17, 2018 03:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants