grpc-java page added #228
grpc-java page added #228
Conversation
content/gRPC/Java.md
Outdated
|
||
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. |
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.
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.
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.
Gotcha, thanks for the correction and suggestion. I'll update that shortly.
content/gRPC/Java.md
Outdated
|
||
We'll instrument the server by tracing as well as tracing gRPC metrics using OpenCensus with imports such as: | ||
|
||
Import|Purpose |
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 think you also imported io.opencensus.exporter.trace.stackdriver
and io.opencensus.exporter.stats.stackdriver
?
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.
Roger that, I'll add them.
content/gRPC/Java.md
Outdated
static class FetchImpl extends FetchGrpc.FetchImplBase { | ||
@Override | ||
public void capitalize(Payload req, StreamObserver<Payload> responseObserver) { | ||
Span span = TutorialServer.tracer.spanBuilder("octutorials.FetchImpl.capitalize").startSpan(); |
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.
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.
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.
Yeah, in deed, I meant to do that actually, thanks!
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.
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.
@songy23 I've updated with your feedback, thank you and PTAL! |
content/gRPC/Java.md
Outdated
@@ -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: |
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.
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
Awesome, thanks @songy23 for the review! |
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.