aboutsummaryrefslogtreecommitdiff
path: root/impl_lite
diff options
context:
space:
mode:
Diffstat (limited to 'impl_lite')
-rw-r--r--impl_lite/README.md6
-rw-r--r--impl_lite/build.gradle12
-rw-r--r--impl_lite/src/main/java/io/opencensus/impllite/metrics/MetricsComponentImplLite.java29
-rw-r--r--impl_lite/src/main/java/io/opencensus/impllite/stats/StatsComponentImplLite.java31
-rw-r--r--impl_lite/src/main/java/io/opencensus/impllite/tags/TagsComponentImplLite.java23
-rw-r--r--impl_lite/src/main/java/io/opencensus/impllite/trace/TraceComponentImplLite.java65
-rw-r--r--impl_lite/src/main/java/io/opencensus/trace/TraceComponentImplLite.java66
-rw-r--r--impl_lite/src/test/java/io/opencensus/impllite/metrics/MetricsTest.java42
-rw-r--r--impl_lite/src/test/java/io/opencensus/impllite/stats/StatsTest.java41
-rw-r--r--impl_lite/src/test/java/io/opencensus/impllite/tags/TagsTest.java41
-rw-r--r--impl_lite/src/test/java/io/opencensus/impllite/trace/TraceComponentImplLiteTest.java52
11 files changed, 408 insertions, 0 deletions
diff --git a/impl_lite/README.md b/impl_lite/README.md
new file mode 100644
index 00000000..ad7bb9b1
--- /dev/null
+++ b/impl_lite/README.md
@@ -0,0 +1,6 @@
+OpenCensus Android implementation
+======================================================
+
+* Android compatible.
+* StatsManager specifies the stats implementation classes that should be used
+ with Android.
diff --git a/impl_lite/build.gradle b/impl_lite/build.gradle
new file mode 100644
index 00000000..b8692fdf
--- /dev/null
+++ b/impl_lite/build.gradle
@@ -0,0 +1,12 @@
+description = 'OpenCensus Lite Implementation'
+
+dependencies {
+ compile project(':opencensus-api'),
+ project(':opencensus-impl-core')
+
+ testCompile project(':opencensus-api'),
+ project(':opencensus-impl-core')
+
+ signature "org.codehaus.mojo.signature:java17:1.0@signature"
+ signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
+}
diff --git a/impl_lite/src/main/java/io/opencensus/impllite/metrics/MetricsComponentImplLite.java b/impl_lite/src/main/java/io/opencensus/impllite/metrics/MetricsComponentImplLite.java
new file mode 100644
index 00000000..6161c12a
--- /dev/null
+++ b/impl_lite/src/main/java/io/opencensus/impllite/metrics/MetricsComponentImplLite.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2018, OpenCensus 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.opencensus.impllite.metrics;
+
+import io.opencensus.implcore.common.MillisClock;
+import io.opencensus.implcore.metrics.MetricsComponentImplBase;
+import io.opencensus.metrics.MetricsComponent;
+
+/** Android-compatible implementation of {@link MetricsComponent}. */
+public final class MetricsComponentImplLite extends MetricsComponentImplBase {
+
+ public MetricsComponentImplLite() {
+ super(MillisClock.getInstance());
+ }
+}
diff --git a/impl_lite/src/main/java/io/opencensus/impllite/stats/StatsComponentImplLite.java b/impl_lite/src/main/java/io/opencensus/impllite/stats/StatsComponentImplLite.java
new file mode 100644
index 00000000..a58a9d3e
--- /dev/null
+++ b/impl_lite/src/main/java/io/opencensus/impllite/stats/StatsComponentImplLite.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2017, OpenCensus 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.opencensus.impllite.stats;
+
+import io.opencensus.implcore.common.MillisClock;
+import io.opencensus.implcore.internal.SimpleEventQueue;
+import io.opencensus.implcore.stats.StatsComponentImplBase;
+import io.opencensus.stats.StatsComponent;
+
+/** Android-compatible implementation of {@link StatsComponent}. */
+public final class StatsComponentImplLite extends StatsComponentImplBase {
+
+ public StatsComponentImplLite() {
+ // TODO(sebright): Use a more efficient queue implementation.
+ super(new SimpleEventQueue(), MillisClock.getInstance());
+ }
+}
diff --git a/impl_lite/src/main/java/io/opencensus/impllite/tags/TagsComponentImplLite.java b/impl_lite/src/main/java/io/opencensus/impllite/tags/TagsComponentImplLite.java
new file mode 100644
index 00000000..dc0d900c
--- /dev/null
+++ b/impl_lite/src/main/java/io/opencensus/impllite/tags/TagsComponentImplLite.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2017, OpenCensus 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.opencensus.impllite.tags;
+
+import io.opencensus.implcore.tags.TagsComponentImplBase;
+import io.opencensus.tags.TagsComponent;
+
+/** Android-compatible implementation of {@link TagsComponent}. */
+public final class TagsComponentImplLite extends TagsComponentImplBase {}
diff --git a/impl_lite/src/main/java/io/opencensus/impllite/trace/TraceComponentImplLite.java b/impl_lite/src/main/java/io/opencensus/impllite/trace/TraceComponentImplLite.java
new file mode 100644
index 00000000..8c067557
--- /dev/null
+++ b/impl_lite/src/main/java/io/opencensus/impllite/trace/TraceComponentImplLite.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2017, OpenCensus 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.opencensus.impllite.trace;
+
+import io.opencensus.common.Clock;
+import io.opencensus.implcore.common.MillisClock;
+import io.opencensus.implcore.internal.SimpleEventQueue;
+import io.opencensus.implcore.trace.TraceComponentImplBase;
+import io.opencensus.implcore.trace.internal.RandomHandler.SecureRandomHandler;
+import io.opencensus.trace.TraceComponent;
+import io.opencensus.trace.Tracer;
+import io.opencensus.trace.config.TraceConfig;
+import io.opencensus.trace.export.ExportComponent;
+import io.opencensus.trace.propagation.PropagationComponent;
+
+/** Android-compatible implementation of the {@link TraceComponent}. */
+public final class TraceComponentImplLite extends TraceComponent {
+ private final TraceComponentImplBase traceComponentImplBase;
+
+ /** Public constructor to be used with reflection loading. */
+ public TraceComponentImplLite() {
+ traceComponentImplBase =
+ new TraceComponentImplBase(
+ MillisClock.getInstance(), new SecureRandomHandler(), new SimpleEventQueue());
+ }
+
+ @Override
+ public Tracer getTracer() {
+ return traceComponentImplBase.getTracer();
+ }
+
+ @Override
+ public PropagationComponent getPropagationComponent() {
+ return traceComponentImplBase.getPropagationComponent();
+ }
+
+ @Override
+ public Clock getClock() {
+ return traceComponentImplBase.getClock();
+ }
+
+ @Override
+ public ExportComponent getExportComponent() {
+ return traceComponentImplBase.getExportComponent();
+ }
+
+ @Override
+ public TraceConfig getTraceConfig() {
+ return traceComponentImplBase.getTraceConfig();
+ }
+}
diff --git a/impl_lite/src/main/java/io/opencensus/trace/TraceComponentImplLite.java b/impl_lite/src/main/java/io/opencensus/trace/TraceComponentImplLite.java
new file mode 100644
index 00000000..5e80b93a
--- /dev/null
+++ b/impl_lite/src/main/java/io/opencensus/trace/TraceComponentImplLite.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2017, OpenCensus 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.opencensus.trace;
+
+import io.opencensus.common.Clock;
+import io.opencensus.implcore.common.MillisClock;
+import io.opencensus.implcore.internal.SimpleEventQueue;
+import io.opencensus.implcore.trace.TraceComponentImplBase;
+import io.opencensus.implcore.trace.internal.RandomHandler.SecureRandomHandler;
+import io.opencensus.trace.config.TraceConfig;
+import io.opencensus.trace.export.ExportComponent;
+import io.opencensus.trace.propagation.PropagationComponent;
+
+/** Android-compatible implementation of the {@link TraceComponent}. */
+// TraceComponentImplLite was moved to io.opencensus.impllite.trace. This class exists for backwards
+// compatibility, so that it can be loaded by opencensus-api 0.5.
+@Deprecated
+public final class TraceComponentImplLite extends TraceComponent {
+ private final TraceComponentImplBase traceComponentImplBase;
+
+ /** Public constructor to be used with reflection loading. */
+ public TraceComponentImplLite() {
+ traceComponentImplBase =
+ new TraceComponentImplBase(
+ MillisClock.getInstance(), new SecureRandomHandler(), new SimpleEventQueue());
+ }
+
+ @Override
+ public Tracer getTracer() {
+ return traceComponentImplBase.getTracer();
+ }
+
+ @Override
+ public PropagationComponent getPropagationComponent() {
+ return traceComponentImplBase.getPropagationComponent();
+ }
+
+ @Override
+ public Clock getClock() {
+ return traceComponentImplBase.getClock();
+ }
+
+ @Override
+ public ExportComponent getExportComponent() {
+ return traceComponentImplBase.getExportComponent();
+ }
+
+ @Override
+ public TraceConfig getTraceConfig() {
+ return traceComponentImplBase.getTraceConfig();
+ }
+}
diff --git a/impl_lite/src/test/java/io/opencensus/impllite/metrics/MetricsTest.java b/impl_lite/src/test/java/io/opencensus/impllite/metrics/MetricsTest.java
new file mode 100644
index 00000000..7ee900a6
--- /dev/null
+++ b/impl_lite/src/test/java/io/opencensus/impllite/metrics/MetricsTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2018, OpenCensus 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.opencensus.impllite.metrics;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import io.opencensus.implcore.metrics.MetricRegistryImpl;
+import io.opencensus.implcore.metrics.export.ExportComponentImpl;
+import io.opencensus.metrics.Metrics;
+import io.opencensus.metrics.MetricsComponent;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Test for accessing the {@link MetricsComponent} through the {@link Metrics} class. */
+@RunWith(JUnit4.class)
+public class MetricsTest {
+
+ @Test
+ public void getExportComponent() {
+ assertThat(Metrics.getExportComponent()).isInstanceOf(ExportComponentImpl.class);
+ }
+
+ @Test
+ public void getMetricRegistry() {
+ assertThat(Metrics.getMetricRegistry()).isInstanceOf(MetricRegistryImpl.class);
+ }
+}
diff --git a/impl_lite/src/test/java/io/opencensus/impllite/stats/StatsTest.java b/impl_lite/src/test/java/io/opencensus/impllite/stats/StatsTest.java
new file mode 100644
index 00000000..313f8916
--- /dev/null
+++ b/impl_lite/src/test/java/io/opencensus/impllite/stats/StatsTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016-17, OpenCensus 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.opencensus.impllite.stats;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import io.opencensus.implcore.stats.StatsRecorderImpl;
+import io.opencensus.implcore.stats.ViewManagerImpl;
+import io.opencensus.stats.Stats;
+import io.opencensus.stats.StatsComponent;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Test for accessing the {@link StatsComponent} through the {@link Stats} class. */
+@RunWith(JUnit4.class)
+public final class StatsTest {
+ @Test
+ public void getStatsRecorder() {
+ assertThat(Stats.getStatsRecorder()).isInstanceOf(StatsRecorderImpl.class);
+ }
+
+ @Test
+ public void getViewManager() {
+ assertThat(Stats.getViewManager()).isInstanceOf(ViewManagerImpl.class);
+ }
+}
diff --git a/impl_lite/src/test/java/io/opencensus/impllite/tags/TagsTest.java b/impl_lite/src/test/java/io/opencensus/impllite/tags/TagsTest.java
new file mode 100644
index 00000000..890cdb15
--- /dev/null
+++ b/impl_lite/src/test/java/io/opencensus/impllite/tags/TagsTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017, OpenCensus 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.opencensus.impllite.tags;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import io.opencensus.implcore.tags.TaggerImpl;
+import io.opencensus.implcore.tags.propagation.TagPropagationComponentImpl;
+import io.opencensus.tags.Tags;
+import io.opencensus.tags.TagsComponent;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Test for accessing the {@link TagsComponent} through the {@link Tags} class. */
+@RunWith(JUnit4.class)
+public final class TagsTest {
+ @Test
+ public void getTagger() {
+ assertThat(Tags.getTagger()).isInstanceOf(TaggerImpl.class);
+ }
+
+ @Test
+ public void getTagContextSerializer() {
+ assertThat(Tags.getTagPropagationComponent()).isInstanceOf(TagPropagationComponentImpl.class);
+ }
+}
diff --git a/impl_lite/src/test/java/io/opencensus/impllite/trace/TraceComponentImplLiteTest.java b/impl_lite/src/test/java/io/opencensus/impllite/trace/TraceComponentImplLiteTest.java
new file mode 100644
index 00000000..c4a609a4
--- /dev/null
+++ b/impl_lite/src/test/java/io/opencensus/impllite/trace/TraceComponentImplLiteTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017, OpenCensus 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.opencensus.impllite.trace;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import io.opencensus.implcore.common.MillisClock;
+import io.opencensus.implcore.trace.TracerImpl;
+import io.opencensus.implcore.trace.export.ExportComponentImpl;
+import io.opencensus.implcore.trace.propagation.PropagationComponentImpl;
+import io.opencensus.trace.Tracing;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Unit tests for {@link TraceComponentImplLite}. */
+@RunWith(JUnit4.class)
+public class TraceComponentImplLiteTest {
+ @Test
+ public void implementationOfTracer() {
+ assertThat(Tracing.getTracer()).isInstanceOf(TracerImpl.class);
+ }
+
+ @Test
+ public void implementationOfBinaryPropagationHandler() {
+ assertThat(Tracing.getPropagationComponent()).isInstanceOf(PropagationComponentImpl.class);
+ }
+
+ @Test
+ public void implementationOfClock() {
+ assertThat(Tracing.getClock()).isInstanceOf(MillisClock.class);
+ }
+
+ @Test
+ public void implementationOfTraceExporter() {
+ assertThat(Tracing.getExportComponent()).isInstanceOf(ExportComponentImpl.class);
+ }
+}