Skip to content

Commit

Permalink
Fixng google java format checkstyle errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ravirajj committed Sep 9, 2019
1 parent 049cfd0 commit 78c45cf
Show file tree
Hide file tree
Showing 20 changed files with 227 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package io.opentracing.contrib.grpc;

import io.opentracing.SpanContext;

/**
* An interface that defines how to get the current active span context
* An interface that defines how to get the current active span context.
*/
public interface ActiveSpanContextSource {

/**
* ActiveSpanContextSource implementation that always returns null as the active span context
* ActiveSpanContextSource implementation that always returns null as the active span context.
*/
ActiveSpanContextSource NONE = new ActiveSpanContextSource() {
@Override
Expand All @@ -32,7 +33,7 @@ public SpanContext getActiveSpanContext() {

/**
* ActiveSpanContextSource implementation that returns the current span context stored in the GRPC
* context under {@link OpenTracingContextKey}
* context under {@link OpenTracingContextKey}.
*/
ActiveSpanContextSource GRPC_CONTEXT = new ActiveSpanContextSource() {
@Override
Expand All @@ -42,6 +43,8 @@ public SpanContext getActiveSpanContext() {
};

/**
* Retrieves the active {@link SpanContext}.
*
* @return the active span context
*/
SpanContext getActiveSpanContext();
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/io/opentracing/contrib/grpc/ActiveSpanSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package io.opentracing.contrib.grpc;

import io.opentracing.Span;

/**
* An interface that defines how to get the current active span
* An interface that defines how to get the current active span.
*/
public interface ActiveSpanSource {

/**
* ActiveSpanSource implementation that always returns null as the active span
* ActiveSpanSource implementation that always returns null as the active span.
*/
ActiveSpanSource NONE = new ActiveSpanSource() {
@Override
Expand All @@ -32,7 +33,7 @@ public Span getActiveSpan() {

/**
* ActiveSpanSource implementation that returns the current span stored in the GRPC context under
* {@link OpenTracingContextKey}
* {@link OpenTracingContextKey}.
*/
ActiveSpanSource GRPC_CONTEXT = new ActiveSpanSource() {
@Override
Expand All @@ -42,7 +43,9 @@ public Span getActiveSpan() {
};

/**
* Retieves the active {@link Span}.
*
* @return the active span
*/
Span getActiveSpan();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
public interface ClientCloseDecorator {

/**
* The method of the implementation is executed inside {@link ForwardingClientCallListener#onClose(Status,
* Metadata)}.
* The method of the implementation is executed inside {@link
* ForwardingClientCallListener#onClose}.
*
* @param span The span created by {@link TracingClientInterceptor}
* @param status The status passed to {@link ForwardingClientCallListener#onClose(Status,
* Metadata)}.
* @param trailers The trailing headers passed to {@link ForwardingClientCallListener#onClose(Status,
* Metadata)}.
* @param status The status passed to {@link ForwardingClientCallListener#onClose}.
* @param trailers The trailing headers passed to {@link ForwardingClientCallListener#onClose}.
*/
void close(Span span, Status status, Metadata trailers);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package io.opentracing.contrib.grpc;

import io.grpc.CallOptions;
import io.grpc.Channel;
import io.grpc.MethodDescriptor;
import io.grpc.ServerCall;
import io.opentracing.Span;
Expand All @@ -27,14 +26,14 @@
public interface ClientSpanDecorator {

/**
* The method of the implementation is executed inside {@link TracingClientInterceptor#interceptCall(MethodDescriptor,
* CallOptions, Channel)}.
* The method of the implementation is executed inside {@link
* TracingClientInterceptor#interceptCall}.
*
* @param span The span created by {@link TracingClientInterceptor}
* @param callOptions The {@link ServerCall} parameter of {@link TracingClientInterceptor#interceptCall(MethodDescriptor,
* CallOptions, Channel)}
* @param method The {@link MethodDescriptor} parameter of {@link TracingClientInterceptor#interceptCall(MethodDescriptor,
* CallOptions, Channel)}
* @param callOptions The {@link ServerCall} parameter of {@link
* TracingClientInterceptor#interceptCall}
* @param method The {@link MethodDescriptor} parameter of {@link
* TracingClientInterceptor#interceptCall}
*/
void interceptCall(Span span, MethodDescriptor method, CallOptions callOptions);
}
77 changes: 39 additions & 38 deletions src/main/java/io/opentracing/contrib/grpc/GrpcFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package io.opentracing.contrib.grpc;

import com.google.common.collect.ImmutableMap;
Expand All @@ -19,50 +20,50 @@

final class GrpcFields {

static final String ERROR = "error";
static final String HEADERS = "headers";
static final String ERROR = "error";
static final String HEADERS = "headers";

static final String CLIENT_CALL_START = "client-call-start";
static final String CLIENT_CALL_CANCEL = "client-call-cancel";
static final String CLIENT_CALL_HALF_CLOSE = "client-call-half-close";
static final String CLIENT_CALL_SEND_MESSAGE = "client-call-send-message";
static final String CLIENT_CALL_START = "client-call-start";
static final String CLIENT_CALL_CANCEL = "client-call-cancel";
static final String CLIENT_CALL_HALF_CLOSE = "client-call-half-close";
static final String CLIENT_CALL_SEND_MESSAGE = "client-call-send-message";

static final String CLIENT_CALL_LISTENER_ON_HEADERS = "client-call-listener-on-headers";
static final String CLIENT_CALL_LISTENER_ON_MESSAGE = "client-call-listener-on-message";
static final String CLIENT_CALL_LISTENER_ON_CLOSE = "client-call-listener-on-close";
static final String CLIENT_CALL_LISTENER_ON_HEADERS = "client-call-listener-on-headers";
static final String CLIENT_CALL_LISTENER_ON_MESSAGE = "client-call-listener-on-message";
static final String CLIENT_CALL_LISTENER_ON_CLOSE = "client-call-listener-on-close";

static final String SERVER_CALL_SEND_HEADERS = "server-call-send-headers";
static final String SERVER_CALL_SEND_MESSAGE = "server-call-send-message";
static final String SERVER_CALL_CLOSE = "server-call-close";
static final String SERVER_CALL_SEND_HEADERS = "server-call-send-headers";
static final String SERVER_CALL_SEND_MESSAGE = "server-call-send-message";
static final String SERVER_CALL_CLOSE = "server-call-close";

static final String SERVER_CALL_LISTENER_ON_MESSAGE = "server-call-listener-on-message";
static final String SERVER_CALL_LISTENER_ON_HALF_CLOSE = "server-call-listener-on-half-close";
static final String SERVER_CALL_LISTENER_ON_CANCEL = "server-call-listener-on-cancel";
static final String SERVER_CALL_LISTENER_ON_COMPLETE = "server-call-listener-on-complete";
static final String SERVER_CALL_LISTENER_ON_MESSAGE = "server-call-listener-on-message";
static final String SERVER_CALL_LISTENER_ON_HALF_CLOSE = "server-call-listener-on-half-close";
static final String SERVER_CALL_LISTENER_ON_CANCEL = "server-call-listener-on-cancel";
static final String SERVER_CALL_LISTENER_ON_COMPLETE = "server-call-listener-on-complete";

static void logClientCallError(Span span, String message, Throwable cause) {
logCallError(span, message, cause, "Client");
}
static void logClientCallError(Span span, String message, Throwable cause) {
logCallError(span, message, cause, "Client");
}

static void logServerCallError(Span span, String message, Throwable cause) {
logCallError(span, message, cause, "Server");
}
static void logServerCallError(Span span, String message, Throwable cause) {
logCallError(span, message, cause, "Server");
}

private static void logCallError(Span span, String message, Throwable cause, String name) {
ImmutableMap.Builder<String, Object> builder = ImmutableMap.<String, Object>builder()
.put(Fields.EVENT, GrpcFields.ERROR);
String causeMessage = null;
if (cause != null) {
builder.put(Fields.ERROR_OBJECT, cause);
causeMessage = cause.getMessage();
}
if (message != null) {
builder.put(Fields.MESSAGE, message);
} else if (causeMessage != null) {
builder.put(Fields.MESSAGE, causeMessage);
} else {
builder.put(Fields.MESSAGE, name + " call failed");
}
span.log(builder.build());
private static void logCallError(Span span, String message, Throwable cause, String name) {
ImmutableMap.Builder<String, Object> builder = ImmutableMap.<String, Object>builder()
.put(Fields.EVENT, GrpcFields.ERROR);
String causeMessage = null;
if (cause != null) {
builder.put(Fields.ERROR_OBJECT, cause);
causeMessage = cause.getMessage();
}
if (message != null) {
builder.put(Fields.MESSAGE, message);
} else if (causeMessage != null) {
builder.put(Fields.MESSAGE, causeMessage);
} else {
builder.put(Fields.MESSAGE, name + " call failed");
}
span.log(builder.build());
}
}
10 changes: 7 additions & 3 deletions src/main/java/io/opentracing/contrib/grpc/GrpcTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package io.opentracing.contrib.grpc;

import io.grpc.Attributes;
Expand Down Expand Up @@ -42,7 +43,8 @@ final class GrpcTags {
/**
* grpc.call_attributes tag.
*/
static final NullableTag<Attributes> GRPC_CALL_ATTRIBUTES = new NullableTag<>("grpc.call_attributes");
static final NullableTag<Attributes> GRPC_CALL_ATTRIBUTES = new NullableTag<>(
"grpc.call_attributes");

/**
* grpc.call_options tag.
Expand Down Expand Up @@ -74,7 +76,8 @@ public void set(Span span, Deadline deadline) {
/**
* grpc.method_name tag.
*/
static final Tag<MethodDescriptor> GRPC_METHOD_NAME = new AbstractTag<MethodDescriptor>("grpc.method_name") {
static final Tag<MethodDescriptor> GRPC_METHOD_NAME = new AbstractTag<MethodDescriptor>(
"grpc.method_name") {
@Override
public void set(Span span, MethodDescriptor method) {
if (method != null) {
Expand All @@ -86,7 +89,8 @@ public void set(Span span, MethodDescriptor method) {
/**
* grpc.method_type tag.
*/
static final Tag<MethodDescriptor> GRPC_METHOD_TYPE = new AbstractTag<MethodDescriptor>("grpc.method_type") {
static final Tag<MethodDescriptor> GRPC_METHOD_TYPE = new AbstractTag<MethodDescriptor>(
"grpc.method_type") {
@Override
public void set(Span span, MethodDescriptor method) {
if (method != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package io.opentracing.contrib.grpc;

import io.grpc.Context;
Expand All @@ -20,8 +21,8 @@
/**
* A {@link io.grpc.Context} key for the current OpenTracing trace state.
*
* Can be used to get the active span, or to set the active span for a scoped unit of work. See the
* <a href="../../../../../../README.rst">grpc-java OpenTracing docs</a> for use cases and
* <p>Can be used to get the active span, or to set the active span for a scoped unit of work. See
* the <a href="../../../../../../README.rst">grpc-java OpenTracing docs</a> for use cases and
* examples.
*/
public class OpenTracingContextKey {
Expand All @@ -32,20 +33,26 @@ public class OpenTracingContextKey {
private static final Context.Key<SpanContext> keyContext = Context.key(KEY_CONTEXT_NAME);

/**
* Retrieves the active span.
*
* @return the active span for the current request
*/
public static Span activeSpan() {
return key.get();
}

/**
* Retrieves the span key.
*
* @return the OpenTracing context key
*/
public static Context.Key<Span> getKey() {
return key;
}

/**
* Retrieves the span context key.
*
* @return the OpenTracing context key for span context
*/
public static Context.Key<SpanContext> getSpanContextKey() {
Expand All @@ -55,4 +62,4 @@ public static Context.Key<SpanContext> getSpanContextKey() {
public static SpanContext activeSpanContext() {
return keyContext.get();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/

package io.opentracing.contrib.grpc;

import io.grpc.MethodDescriptor;
Expand All @@ -34,10 +35,10 @@ public <ReqT, RespT> String constructOperationName(MethodDescriptor<ReqT, RespT>
/**
* Constructs a span's operation name from the RPC's method.
*
* @param method the rpc method to extract a name from
* @param <ReqT> the rpc request type
* @param method the rpc method to extract a name from
* @param <ReqT> the rpc request type
* @param <RespT> the rpc response type
* @return the operation name
*/
<ReqT, RespT> String constructOperationName(MethodDescriptor<ReqT, RespT> method);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import io.grpc.Metadata;
import io.grpc.ServerCall;
import io.grpc.ServerCallHandler;
import io.opentracing.Span;

/**
Expand All @@ -26,14 +25,13 @@
public interface ServerSpanDecorator {

/**
* The method of the implementation is executed inside {@link TracingServerInterceptor#interceptCall(ServerCall,
* Metadata, ServerCallHandler)}.
* The method of the implementation is executed inside {@link
* TracingServerInterceptor#interceptCall}.
*
* @param span The span created by {@link TracingServerInterceptor}
* @param call The {@link ServerCall} parameter of {@link TracingServerInterceptor#interceptCall(ServerCall,
* Metadata, ServerCallHandler)}
* @param headers The {@link Metadata} parameter of {@link TracingServerInterceptor#interceptCall(ServerCall,
* Metadata, ServerCallHandler)}
* @param call The {@link ServerCall} parameter of {@link
* TracingServerInterceptor#interceptCall}
* @param headers The {@link Metadata} parameter of {@link TracingServerInterceptor#interceptCall}
*/
void interceptCall(Span span, ServerCall call, Metadata headers);
}
Loading

0 comments on commit 78c45cf

Please sign in to comment.