aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorBogdan Drutu <bdrutu@google.com>2017-06-08 17:38:43 -0700
committerGitHub <noreply@github.com>2017-06-08 17:38:43 -0700
commitf27ee518014266152c87b87695964d6dfa54c7ad (patch)
treea3eb24ad75ebdab39bb171b97e00d445dd3dd8ea /api
parent7331a983599bddccc87dd1545301edff795322b2 (diff)
downloadplatform_external_opencensus-java-f27ee518014266152c87b87695964d6dfa54c7ad.tar.gz
platform_external_opencensus-java-f27ee518014266152c87b87695964d6dfa54c7ad.tar.bz2
platform_external_opencensus-java-f27ee518014266152c87b87695964d6dfa54c7ad.zip
Cleanup in config package. (#346)
* Remove unimplemented method from TraceConfig. * Move config implementations to config package. * Add tests for NoopTraceConfig.
Diffstat (limited to 'api')
-rw-r--r--api/src/main/java/io/opencensus/trace/config/TraceConfig.java11
-rw-r--r--api/src/test/java/io/opencensus/trace/config/TraceConfigTest.java47
-rw-r--r--api/src/test/java/io/opencensus/trace/config/TraceParamsTest.java (renamed from api/src/test/java/io/opencensus/trace/TraceParamsTest.java)4
3 files changed, 49 insertions, 13 deletions
diff --git a/api/src/main/java/io/opencensus/trace/config/TraceConfig.java b/api/src/main/java/io/opencensus/trace/config/TraceConfig.java
index 80f206c9..01cb6d04 100644
--- a/api/src/main/java/io/opencensus/trace/config/TraceConfig.java
+++ b/api/src/main/java/io/opencensus/trace/config/TraceConfig.java
@@ -35,14 +35,6 @@ public abstract class TraceConfig {
public abstract void updateActiveTraceParams(TraceParams traceParams);
/**
- * Temporary updates the active {@link TraceParams} for {@code durationNs} nanoseconds.
- *
- * @param traceParams the new active {@code TraceParams}.
- * @param durationNs the duration for how long the new params will be active.
- */
- public abstract void temporaryUpdateActiveTraceParams(TraceParams traceParams, long durationNs);
-
- /**
* Returns the no-op implementation of the {@code TraceConfig}.
*
* @return the no-op implementation of the {@code TraceConfig}.
@@ -60,8 +52,5 @@ public abstract class TraceConfig {
@Override
public void updateActiveTraceParams(TraceParams traceParams) {}
-
- @Override
- public void temporaryUpdateActiveTraceParams(TraceParams traceParams, long durationNs) {}
}
}
diff --git a/api/src/test/java/io/opencensus/trace/config/TraceConfigTest.java b/api/src/test/java/io/opencensus/trace/config/TraceConfigTest.java
new file mode 100644
index 00000000..2bf9356d
--- /dev/null
+++ b/api/src/test/java/io/opencensus/trace/config/TraceConfigTest.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2017, Google Inc.
+ * 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.opencensus.trace.config;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import io.opencensus.trace.Samplers;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Unit tests for {@link TraceConfig}. */
+@RunWith(JUnit4.class)
+public class TraceConfigTest {
+ TraceConfig traceConfig = TraceConfig.getNoopTraceConfig();
+
+ @Test
+ public void activeTraceParams_NoOpImplementation() {
+ assertThat(traceConfig.getActiveTraceParams()).isEqualTo(TraceParams.DEFAULT);
+ }
+
+ @Test
+ public void updateActiveTraceParams_NoOpImplementation() {
+ TraceParams traceParams =
+ TraceParams.DEFAULT
+ .toBuilder()
+ .setSampler(Samplers.alwaysSample())
+ .setMaxNumberOfAttributes(8)
+ .setMaxNumberOfAnnotations(9)
+ .setMaxNumberOfNetworkEvents(10)
+ .setMaxNumberOfLinks(11)
+ .build();
+ traceConfig.updateActiveTraceParams(traceParams);
+ assertThat(traceConfig.getActiveTraceParams()).isEqualTo(TraceParams.DEFAULT);
+ }
+}
diff --git a/api/src/test/java/io/opencensus/trace/TraceParamsTest.java b/api/src/test/java/io/opencensus/trace/config/TraceParamsTest.java
index e21485e1..76d828a9 100644
--- a/api/src/test/java/io/opencensus/trace/TraceParamsTest.java
+++ b/api/src/test/java/io/opencensus/trace/config/TraceParamsTest.java
@@ -11,11 +11,11 @@
* limitations under the License.
*/
-package io.opencensus.trace;
+package io.opencensus.trace.config;
import static com.google.common.truth.Truth.assertThat;
-import io.opencensus.trace.config.TraceParams;
+import io.opencensus.trace.Samplers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;