aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorzpencer <spencerfang@google.com>2018-09-10 16:35:08 -0700
committerGitHub <noreply@github.com>2018-09-10 16:35:08 -0700
commit95fd47d747433cc6728c1e4481fc1715433799a8 (patch)
tree320f893f615e4219b7a572ce98125ccd65d8f838 /services
parente1c6cadb50312f0dc810541b1e245b9adca89709 (diff)
downloadgrpc-grpc-java-95fd47d747433cc6728c1e4481fc1715433799a8.tar.gz
core, services: remove census from binary logs (#4845)
The exact census span behavior wrt gRPC is not yet defined, so let's punt on tight integration. It may be fine to log grpc-trace-bin on server side because it is a key visible to the application.
Diffstat (limited to 'services')
-rw-r--r--services/src/main/java/io/grpc/services/BinaryLogs.java14
-rw-r--r--services/src/main/java/io/grpc/services/CensusBinaryLogProvider.java52
-rw-r--r--services/src/test/java/io/grpc/services/BinlogHelperTest.java4
-rw-r--r--services/src/test/java/io/grpc/services/CensusBinaryLogProviderTest.java73
4 files changed, 1 insertions, 142 deletions
diff --git a/services/src/main/java/io/grpc/services/BinaryLogs.java b/services/src/main/java/io/grpc/services/BinaryLogs.java
index afe3f2462..de7f79116 100644
--- a/services/src/main/java/io/grpc/services/BinaryLogs.java
+++ b/services/src/main/java/io/grpc/services/BinaryLogs.java
@@ -38,19 +38,5 @@ public final class BinaryLogs {
return new BinaryLogProviderImpl(sink);
}
- /**
- * Same as {@link #createBinaryLog()} except the call IDs are derived from census.
- */
- public static BinaryLog createCensusBinaryLog() throws IOException {
- return new CensusBinaryLogProvider();
- }
-
- /**
- * Same as {@link #createBinaryLog(BinaryLogSink)} except the call IDs are derived from census.
- */
- public static BinaryLog createCensusBinaryLog(BinaryLogSink sink) throws IOException {
- return new CensusBinaryLogProvider(sink);
- }
-
private BinaryLogs() {}
}
diff --git a/services/src/main/java/io/grpc/services/CensusBinaryLogProvider.java b/services/src/main/java/io/grpc/services/CensusBinaryLogProvider.java
deleted file mode 100644
index d6fb7fae8..000000000
--- a/services/src/main/java/io/grpc/services/CensusBinaryLogProvider.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2018 The gRPC Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.grpc.services;
-
-import io.grpc.CallOptions;
-import io.opencensus.trace.Span;
-import io.opencensus.trace.Tracing;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-final class CensusBinaryLogProvider extends BinaryLogProviderImpl {
-
- public CensusBinaryLogProvider() throws IOException {
- super();
- }
-
- public CensusBinaryLogProvider(BinaryLogSink sink) throws IOException {
- super(sink);
- }
-
- CensusBinaryLogProvider(BinaryLogSink sink, String configStr) throws IOException {
- super(sink, configStr);
- }
-
- @Override
- protected CallId getServerCallId() {
- Span currentSpan = Tracing.getTracer().getCurrentSpan();
- return new CallId(
- 0,
- ByteBuffer.wrap(
- currentSpan.getContext().getSpanId().getBytes()).getLong());
- }
-
- @Override
- protected CallId getClientCallId(CallOptions options) {
- return options.getOption(BinaryLogProvider.CLIENT_CALL_ID_CALLOPTION_KEY);
- }
-}
diff --git a/services/src/test/java/io/grpc/services/BinlogHelperTest.java b/services/src/test/java/io/grpc/services/BinlogHelperTest.java
index 148eb171c..5237a0bb9 100644
--- a/services/src/test/java/io/grpc/services/BinlogHelperTest.java
+++ b/services/src/test/java/io/grpc/services/BinlogHelperTest.java
@@ -905,9 +905,7 @@ public final class BinlogHelperTest {
.getClientInterceptor(CALL_ID)
.interceptCall(
method,
- CallOptions.DEFAULT.withOption(
- BinaryLogProvider.CLIENT_CALL_ID_CALLOPTION_KEY, CALL_ID)
- .withDeadlineAfter(1, TimeUnit.SECONDS),
+ CallOptions.DEFAULT.withDeadlineAfter(1, TimeUnit.SECONDS),
new Channel() {
@Override
public <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall(
diff --git a/services/src/test/java/io/grpc/services/CensusBinaryLogProviderTest.java b/services/src/test/java/io/grpc/services/CensusBinaryLogProviderTest.java
deleted file mode 100644
index 8fabbd1f9..000000000
--- a/services/src/test/java/io/grpc/services/CensusBinaryLogProviderTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2018 The gRPC Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.grpc.services;
-
-import static com.google.common.truth.Truth.assertThat;
-import static io.opencensus.trace.unsafe.ContextUtils.CONTEXT_SPAN_KEY;
-
-import io.grpc.BinaryLog.CallId;
-import io.grpc.CallOptions;
-import io.grpc.Context;
-import io.grpc.internal.testing.StatsTestUtils.MockableSpan;
-import java.nio.ByteBuffer;
-import java.util.Random;
-import java.util.concurrent.Callable;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-/**
- * Tests for {@link CensusBinaryLogProvider}.
- */
-@RunWith(JUnit4.class)
-public class CensusBinaryLogProviderTest {
- @Mock
- private BinaryLogSink sink;
-
- public CensusBinaryLogProviderTest() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void serverCallIdFromCensus() throws Exception {
- final MockableSpan mockableSpan = MockableSpan.generateRandomSpan(new Random(0));
- Context context = Context.current().withValue(CONTEXT_SPAN_KEY, mockableSpan);
- context.call(new Callable<Void>() {
- @Override
- public Void call() throws Exception {
- CallId callId = new CensusBinaryLogProvider(sink, "*").getServerCallId();
- assertThat(callId.hi).isEqualTo(0);
- assertThat(ByteBuffer.wrap(mockableSpan.getContext().getSpanId().getBytes()).getLong())
- .isEqualTo(callId.lo);
- return null;
- }
- });
- }
-
- @Test
- public void clientCallId() throws Exception {
- CallId expected = new CallId(1234, 5677);
- CallId actual = new CensusBinaryLogProvider(sink, "*")
- .getClientCallId(
- CallOptions.DEFAULT.withOption(
- BinaryLogProvider.CLIENT_CALL_ID_CALLOPTION_KEY,
- expected));
- assertThat(actual).isEqualTo(expected);
- }
-}