├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── build-checker.yml │ ├── build-gradle-examples.yml │ ├── build-maven-examples.yml │ └── build.yml ├── .gitignore ├── .gitmodules ├── .travis.yml ├── AUTHORS ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── RELEASING.md ├── all └── build.gradle ├── api ├── README.md ├── build.gradle └── src │ ├── main │ └── java │ │ └── io │ │ └── opencensus │ │ ├── common │ │ ├── Clock.java │ │ ├── Duration.java │ │ ├── ExperimentalApi.java │ │ ├── Function.java │ │ ├── Functions.java │ │ ├── Internal.java │ │ ├── NonThrowingCloseable.java │ │ ├── OpenCensusLibraryInformation.java │ │ ├── Scope.java │ │ ├── ServerStats.java │ │ ├── ServerStatsDeserializationException.java │ │ ├── ServerStatsEncoding.java │ │ ├── ServerStatsFieldEnums.java │ │ ├── TimeUtils.java │ │ ├── Timestamp.java │ │ ├── ToDoubleFunction.java │ │ ├── ToLongFunction.java │ │ └── package-info.java │ │ ├── internal │ │ ├── DefaultVisibilityForTesting.java │ │ ├── NoopScope.java │ │ ├── Provider.java │ │ ├── StringUtils.java │ │ ├── Utils.java │ │ ├── ZeroTimeClock.java │ │ └── package-info.java │ │ ├── metrics │ │ ├── DerivedDoubleCumulative.java │ │ ├── DerivedDoubleGauge.java │ │ ├── DerivedLongCumulative.java │ │ ├── DerivedLongGauge.java │ │ ├── DoubleCumulative.java │ │ ├── DoubleGauge.java │ │ ├── LabelKey.java │ │ ├── LabelValue.java │ │ ├── LongCumulative.java │ │ ├── LongGauge.java │ │ ├── MetricOptions.java │ │ ├── MetricRegistry.java │ │ ├── Metrics.java │ │ ├── MetricsComponent.java │ │ ├── data │ │ │ ├── AttachmentValue.java │ │ │ ├── Exemplar.java │ │ │ └── package-info.java │ │ ├── export │ │ │ ├── Distribution.java │ │ │ ├── ExportComponent.java │ │ │ ├── Metric.java │ │ │ ├── MetricDescriptor.java │ │ │ ├── MetricProducer.java │ │ │ ├── MetricProducerManager.java │ │ │ ├── Point.java │ │ │ ├── Summary.java │ │ │ ├── TimeSeries.java │ │ │ └── Value.java │ │ └── package-info.java │ │ ├── resource │ │ ├── Resource.java │ │ └── package-info.java │ │ ├── stats │ │ ├── Aggregation.java │ │ ├── AggregationData.java │ │ ├── BucketBoundaries.java │ │ ├── Measure.java │ │ ├── MeasureMap.java │ │ ├── Measurement.java │ │ ├── NoopStats.java │ │ ├── Stats.java │ │ ├── StatsCollectionState.java │ │ ├── StatsComponent.java │ │ ├── StatsRecorder.java │ │ ├── View.java │ │ ├── ViewData.java │ │ ├── ViewManager.java │ │ └── package-info.java │ │ ├── tags │ │ ├── InternalUtils.java │ │ ├── NoopTags.java │ │ ├── Tag.java │ │ ├── TagContext.java │ │ ├── TagContextBuilder.java │ │ ├── TagKey.java │ │ ├── TagMetadata.java │ │ ├── TagValue.java │ │ ├── Tagger.java │ │ ├── TaggingState.java │ │ ├── Tags.java │ │ ├── TagsComponent.java │ │ ├── package-info.java │ │ ├── propagation │ │ │ ├── TagContextBinarySerializer.java │ │ │ ├── TagContextDeserializationException.java │ │ │ ├── TagContextSerializationException.java │ │ │ ├── TagContextTextFormat.java │ │ │ └── TagPropagationComponent.java │ │ └── unsafe │ │ │ └── ContextUtils.java │ │ └── trace │ │ ├── Annotation.java │ │ ├── AttributeValue.java │ │ ├── BaseMessageEvent.java │ │ ├── BigendianEncoding.java │ │ ├── BlankSpan.java │ │ ├── ContextHandle.java │ │ ├── ContextManager.java │ │ ├── CurrentSpanUtils.java │ │ ├── EndSpanOptions.java │ │ ├── Link.java │ │ ├── MessageEvent.java │ │ ├── NetworkEvent.java │ │ ├── Sampler.java │ │ ├── Span.java │ │ ├── SpanBuilder.java │ │ ├── SpanContext.java │ │ ├── SpanId.java │ │ ├── Status.java │ │ ├── TraceComponent.java │ │ ├── TraceId.java │ │ ├── TraceOptions.java │ │ ├── Tracer.java │ │ ├── Tracestate.java │ │ ├── Tracing.java │ │ ├── config │ │ ├── TraceConfig.java │ │ └── TraceParams.java │ │ ├── export │ │ ├── ExportComponent.java │ │ ├── RunningSpanStore.java │ │ ├── SampledSpanStore.java │ │ ├── SpanData.java │ │ └── SpanExporter.java │ │ ├── internal │ │ └── BaseMessageEventUtils.java │ │ ├── package-info.java │ │ ├── propagation │ │ ├── BinaryFormat.java │ │ ├── PropagationComponent.java │ │ ├── SpanContextParseException.java │ │ └── TextFormat.java │ │ ├── samplers │ │ ├── AlwaysSampleSampler.java │ │ ├── NeverSampleSampler.java │ │ ├── ProbabilitySampler.java │ │ └── Samplers.java │ │ └── unsafe │ │ ├── ContextHandleImpl.java │ │ ├── ContextHandleUtils.java │ │ ├── ContextManagerImpl.java │ │ └── ContextUtils.java │ └── test │ └── java │ └── io │ └── opencensus │ ├── common │ ├── DurationTest.java │ ├── FunctionsTest.java │ ├── ServerStatsEncodingTest.java │ ├── ServerStatsFieldEnumsTest.java │ ├── ServerStatsTest.java │ ├── TimeUtilsTest.java │ └── TimestampTest.java │ ├── internal │ ├── ProviderTest.java │ ├── StringUtilsTest.java │ └── UtilsTest.java │ ├── metrics │ ├── DerivedDoubleCumulativeTest.java │ ├── DerivedDoubleGaugeTest.java │ ├── DerivedLongCumulativeTest.java │ ├── DerivedLongGaugeTest.java │ ├── DoubleCumulativeTest.java │ ├── DoubleGaugeTest.java │ ├── LabelKeyTest.java │ ├── LabelValueTest.java │ ├── LongCumulativeTest.java │ ├── LongGaugeTest.java │ ├── MetricOptionsTest.java │ ├── MetricRegistryTest.java │ ├── MetricsComponentTest.java │ ├── MetricsTest.java │ ├── data │ │ ├── AttachmentValueTest.java │ │ └── ExemplarTest.java │ └── export │ │ ├── DistributionTest.java │ │ ├── ExportComponentTest.java │ │ ├── MetricDescriptorTest.java │ │ ├── MetricProducerManagerTest.java │ │ ├── MetricTest.java │ │ ├── PointTest.java │ │ ├── SummaryTest.java │ │ ├── TimeSeriesTest.java │ │ └── ValueTest.java │ ├── resource │ └── ResourceTest.java │ ├── stats │ ├── AggregationDataTest.java │ ├── AggregationTest.java │ ├── BucketBoundariesTest.java │ ├── MeasureTest.java │ ├── NoopStatsTest.java │ ├── NoopViewManagerTest.java │ ├── StatsTest.java │ ├── ViewDataTest.java │ └── ViewTest.java │ ├── tags │ ├── InternalUtilsTest.java │ ├── NoopTagsTest.java │ ├── TagContextTest.java │ ├── TagKeyTest.java │ ├── TagMetadataTest.java │ ├── TagTest.java │ ├── TagValueTest.java │ ├── TagsTest.java │ ├── propagation │ │ ├── TagContextDeserializationExceptionTest.java │ │ └── TagContextSerializationExceptionTest.java │ └── unsafe │ │ └── ContextUtilsTest.java │ └── trace │ ├── AnnotationTest.java │ ├── AttributeValueTest.java │ ├── BigendianEncodingTest.java │ ├── BlankSpanTest.java │ ├── CurrentSpanUtilsTest.java │ ├── EndSpanOptionsTest.java │ ├── LinkTest.java │ ├── MessageEventTest.java │ ├── NetworkEventTest.java │ ├── NoopSpan.java │ ├── SpanBuilderTest.java │ ├── SpanContextTest.java │ ├── SpanIdTest.java │ ├── SpanTest.java │ ├── StatusTest.java │ ├── TraceComponentTest.java │ ├── TraceIdTest.java │ ├── TraceOptionsTest.java │ ├── TracerTest.java │ ├── TracestateTest.java │ ├── TracingTest.java │ ├── config │ ├── TraceConfigTest.java │ └── TraceParamsTest.java │ ├── export │ ├── ExportComponentTest.java │ ├── NoopRunningSpanStoreTest.java │ ├── NoopSampledSpanStoreTest.java │ └── SpanDataTest.java │ ├── internal │ └── BaseMessageEventUtilsTest.java │ ├── propagation │ ├── BinaryFormatTest.java │ ├── PropagationComponentTest.java │ ├── SpanContextParseExceptionTest.java │ └── TextFormatTest.java │ ├── samplers │ └── SamplersTest.java │ └── unsafe │ └── ContextUtilsTest.java ├── appveyor.yml ├── benchmarks ├── README.md ├── build.gradle └── src │ └── jmh │ └── java │ └── io │ └── opencensus │ └── benchmarks │ ├── stats │ ├── RecordBatchedBenchmark.java │ ├── RecordDifferentTagValuesBenchmark.java │ ├── RecordMultipleViewsBenchmark.java │ └── StatsBenchmarksUtil.java │ ├── tags │ ├── NestedTagContextCreationBenchmark.java │ ├── TagContextBenchmark.java │ ├── TagsBenchmark.java │ └── TagsBenchmarksUtil.java │ └── trace │ ├── BasicDataBenchmark.java │ ├── BasicOperationsBenchmark.java │ ├── BenchmarksUtil.java │ ├── RecordTraceEventsBenchmark.java │ ├── SpanOperationsBenchmark.java │ └── StartEndSpanBenchmark.java ├── build.gradle ├── buildscripts ├── check-git-history.py ├── checkstyle.license ├── checkstyle.xml ├── codecov.yml ├── import-control.xml ├── kokoro │ ├── linux.cfg │ ├── linux.sh │ ├── linux_build.cfg │ ├── linux_example_gradle.cfg │ ├── linux_example_maven.cfg │ ├── linux_framework.cfg │ ├── linux_git_history.cfg │ ├── linux_presubmit.sh │ ├── macos.cfg │ ├── windows.bat │ └── windows.cfg └── travis_script ├── checker-framework └── stubs │ ├── google-cloud-java.astub │ ├── grpc.astub │ ├── guava.astub │ ├── log4j.astub │ ├── org-springframework-cloud-sleuth.astub │ └── org-springframework-cloud-sleuth.log.astub ├── contrib ├── agent │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── integration-test │ │ ├── java │ │ │ └── io │ │ │ │ └── opencensus │ │ │ │ └── contrib │ │ │ │ └── agent │ │ │ │ └── instrumentation │ │ │ │ ├── ExecutorInstrumentationIT.java │ │ │ │ ├── ThreadInstrumentationIT.java │ │ │ │ └── UrlInstrumentationIT.java │ │ └── resources │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── agent │ │ │ └── instrumentation │ │ │ └── some_resource.txt │ │ ├── jmh │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── agent │ │ │ └── instrumentation │ │ │ ├── ExecutorInstrumentationBenchmark.java │ │ │ └── ThreadInstrumentationBenchmark.java │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── opencensus │ │ │ │ └── contrib │ │ │ │ └── agent │ │ │ │ ├── AgentBuilderListener.java │ │ │ │ ├── AgentMain.java │ │ │ │ ├── Resources.java │ │ │ │ ├── Settings.java │ │ │ │ ├── bootstrap │ │ │ │ ├── ContextStrategy.java │ │ │ │ ├── ContextTrampoline.java │ │ │ │ ├── TraceStrategy.java │ │ │ │ ├── TraceTrampoline.java │ │ │ │ └── package-info.java │ │ │ │ ├── deps │ │ │ │ └── package-info.java │ │ │ │ └── instrumentation │ │ │ │ ├── ContextStrategyImpl.java │ │ │ │ ├── ContextTrampolineInitializer.java │ │ │ │ ├── ExecutorInstrumentation.java │ │ │ │ ├── Instrumenter.java │ │ │ │ ├── ThreadInstrumentation.java │ │ │ │ ├── TraceStrategyImpl.java │ │ │ │ ├── TraceTrampolineInitializer.java │ │ │ │ └── UrlInstrumentation.java │ │ └── resources │ │ │ └── reference.conf │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── agent │ │ │ ├── ResourcesTest.java │ │ │ ├── bootstrap │ │ │ ├── ContextTrampolineTest.java │ │ │ └── TraceTrampolineTest.java │ │ │ └── instrumentation │ │ │ ├── ExecutorInstrumentationTest.java │ │ │ ├── ThreadInstrumentationTest.java │ │ │ └── UrlInstrumentationTest.java │ │ └── resources │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── agent │ │ └── some_resource.txt ├── appengine_standard_util │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── opencensus │ │ │ │ └── contrib │ │ │ │ └── appengine │ │ │ │ └── standard │ │ │ │ └── util │ │ │ │ └── AppEngineCloudTraceContextUtils.java │ │ └── proto │ │ │ └── trace_id.proto │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── appengine │ │ └── standard │ │ └── util │ │ └── AppEngineCloudTraceContextUtilsTest.java ├── dropwizard │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── dropwizard │ │ │ ├── DropWizardMetrics.java │ │ │ └── DropWizardUtils.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── dropwizard │ │ ├── DropWizardMetricsTest.java │ │ └── DropWizardUtilsTest.java ├── dropwizard5 │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── dropwizard5 │ │ │ ├── DropWizardMetrics.java │ │ │ └── DropWizardUtils.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── dropwizard5 │ │ ├── DropWizardMetricsTest.java │ │ └── DropWizardUtilsTest.java ├── exemplar_util │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── exemplar │ │ │ └── util │ │ │ ├── AttachmentValueSpanContext.java │ │ │ └── ExemplarUtils.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── exemplar │ │ └── util │ │ ├── AttachmentValueSpanContextTest.java │ │ └── ExemplarUtilsTest.java ├── grpc_metrics │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── grpc │ │ │ └── metrics │ │ │ ├── RpcMeasureConstants.java │ │ │ ├── RpcViewConstants.java │ │ │ └── RpcViews.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── grpc │ │ └── metrics │ │ ├── RpcMeasureConstantsTest.java │ │ ├── RpcViewConstantsTest.java │ │ └── RpcViewsTest.java ├── grpc_util │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── grpc │ │ │ └── util │ │ │ └── StatusConverter.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── grpc │ │ └── util │ │ └── StatusConverterTest.java ├── http_jaxrs │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── http │ │ │ └── jaxrs │ │ │ ├── ExtendedContainerRequest.java │ │ │ ├── JaxrsClientExtractor.java │ │ │ ├── JaxrsClientFilter.java │ │ │ ├── JaxrsContainerExtractor.java │ │ │ ├── JaxrsContainerFilter.java │ │ │ └── Metrics.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── http │ │ └── jaxrs │ │ ├── JaxrsClientExtractorTest.java │ │ ├── JaxrsClientFilterTest.java │ │ ├── JaxrsContainerExtractorTest.java │ │ └── JaxrsContainerFilterTest.java ├── http_jetty_client │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── http │ │ │ └── jetty │ │ │ └── client │ │ │ ├── HttpRequestListener.java │ │ │ ├── OcJettyHttpClient.java │ │ │ └── OcJettyHttpClientExtractor.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── http │ │ └── jetty │ │ └── client │ │ ├── HttpRequestListenerTest.java │ │ ├── OcJettyHttpClientExtractorTest.java │ │ └── OcJettyHttpClientTest.java ├── http_servlet │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── http │ │ │ └── servlet │ │ │ ├── OcHttpServletExtractor.java │ │ │ ├── OcHttpServletFilter.java │ │ │ ├── OcHttpServletListener.java │ │ │ ├── OcHttpServletUtil.java │ │ │ └── WriteListenerWrapper.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── http │ │ └── servlet │ │ ├── OcHttpServletExtractorTest.java │ │ ├── OcHttpServletFilterTest.java │ │ ├── OcHttpServletListenerTest.java │ │ └── WriteListenerWrapperTest.java ├── http_util │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── http │ │ │ ├── AbstractHttpHandler.java │ │ │ ├── HttpClientHandler.java │ │ │ ├── HttpExtractor.java │ │ │ ├── HttpRequestContext.java │ │ │ ├── HttpServerHandler.java │ │ │ └── util │ │ │ ├── CloudTraceFormat.java │ │ │ ├── HttpMeasureConstants.java │ │ │ ├── HttpPropagationUtil.java │ │ │ ├── HttpTraceAttributeConstants.java │ │ │ ├── HttpTraceUtil.java │ │ │ ├── HttpViewConstants.java │ │ │ └── HttpViews.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── http │ │ ├── AbstractHttpHandlerTest.java │ │ ├── HttpClientHandlerTest.java │ │ ├── HttpRequestContextTest.java │ │ ├── HttpServerHandlerTest.java │ │ └── util │ │ ├── CloudTraceFormatTest.java │ │ ├── HttpMeasureConstantsTest.java │ │ ├── HttpPropagationUtilTest.java │ │ ├── HttpTraceUtilTest.java │ │ ├── HttpViewConstantsTest.java │ │ ├── HttpViewsTest.java │ │ └── testing │ │ └── FakeSpan.java ├── log_correlation │ ├── log4j2 │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── io │ │ │ │ └── opencensus │ │ │ │ └── contrib │ │ │ │ └── logcorrelation │ │ │ │ └── log4j2 │ │ │ │ ├── ContextDataUtils.java │ │ │ │ └── OpenCensusTraceContextDataInjector.java │ │ │ └── test │ │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── logcorrelation │ │ │ └── log4j2 │ │ │ ├── OpenCensusLog4jLogCorrelationTest.java │ │ │ ├── OpenCensusTraceContextDataInjectorTest.java │ │ │ └── TestSpan.java │ └── stackdriver │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── logcorrelation │ │ │ └── stackdriver │ │ │ └── OpenCensusTraceLoggingEnhancer.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── logcorrelation │ │ └── stackdriver │ │ └── OpenCensusTraceLoggingEnhancerTest.java ├── observability_ready_util │ ├── README.md │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── observability │ │ └── ready │ │ └── util │ │ └── BasicSetup.java ├── resource_util │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── resource │ │ │ └── util │ │ │ ├── AwsIdentityDocUtils.java │ │ │ ├── CloudResource.java │ │ │ ├── ContainerResource.java │ │ │ ├── GcpMetadataConfig.java │ │ │ ├── HostResource.java │ │ │ ├── K8sResource.java │ │ │ └── ResourceUtils.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── resource │ │ └── util │ │ ├── AwsIdentityDocUtilsTest.java │ │ ├── CloudResourceTest.java │ │ ├── ContainerResourceTest.java │ │ ├── HostResourceTest.java │ │ ├── K8sResourceTest.java │ │ └── ResourceUtilsTest.java ├── spring │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── opencensus │ │ │ │ └── contrib │ │ │ │ └── spring │ │ │ │ ├── aop │ │ │ │ ├── CensusSpringAspect.java │ │ │ │ ├── CensusSpringSqlAspect.java │ │ │ │ ├── Handler.java │ │ │ │ └── Traced.java │ │ │ │ ├── autoconfig │ │ │ │ ├── OpenCensusAutoConfiguration.java │ │ │ │ ├── OpenCensusProperties.java │ │ │ │ └── TraceWebAsyncClientAutoConfiguration.java │ │ │ │ └── instrument │ │ │ │ └── web │ │ │ │ ├── HttpServletFilter.java │ │ │ │ └── client │ │ │ │ └── TracingAsyncClientHttpRequestInterceptor.java │ │ └── resources │ │ │ └── META-INF │ │ │ ├── additional-spring-configuration-metadata.json │ │ │ └── spring.factories │ │ └── test │ │ ├── java │ │ └── io │ │ │ └── opencensus │ │ │ └── contrib │ │ │ └── spring │ │ │ ├── aop │ │ │ ├── CensusSpringAspectTest.java │ │ │ └── Sample.java │ │ │ └── instrument │ │ │ └── web │ │ │ ├── AbstractMvcIntegrationTest.java │ │ │ ├── HttpServletFilterIntegrationTests.java │ │ │ └── TraceWebAsyncClientAutoConfigurationTest.java │ │ └── resources │ │ ├── META-INF │ │ └── spring.factories │ │ ├── beans │ │ └── HttpServletFilterIntegrationTest-context.xml │ │ └── spring.xml ├── spring_sleuth_v1x │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ ├── java │ │ │ └── io │ │ │ │ └── opencensus │ │ │ │ └── contrib │ │ │ │ └── spring │ │ │ │ └── sleuth │ │ │ │ └── v1x │ │ │ │ ├── OpenCensusSleuthAutoConfiguration.java │ │ │ │ ├── OpenCensusSleuthProperties.java │ │ │ │ ├── OpenCensusSleuthSpan.java │ │ │ │ ├── OpenCensusSleuthSpanContextHolder.java │ │ │ │ └── OpenCensusSleuthTracer.java │ │ └── resources │ │ │ └── META-INF │ │ │ ├── additional-spring-configuration-metadata.json │ │ │ └── spring.factories │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── spring │ │ └── sleuth │ │ └── v1x │ │ ├── OpenCensusSleuthSpanContextHolderTest.java │ │ ├── OpenCensusSleuthSpanTest.java │ │ └── OpenCensusSleuthTracerTest.java ├── spring_starter │ ├── README.md │ ├── build.gradle │ └── src │ │ └── main │ │ └── resources │ │ └── META-INF │ │ └── spring.provides └── zpages │ ├── README.md │ ├── build.gradle │ ├── screenshots │ ├── rpcz-example.png │ ├── statsz-example-1.png │ ├── statsz-example-2.png │ ├── traceconfigz-example.png │ └── tracez-example.png │ └── src │ ├── main │ └── java │ │ └── io │ │ └── opencensus │ │ └── contrib │ │ └── zpages │ │ ├── RpczZPageHandler.java │ │ ├── StatszZPageHandler.java │ │ ├── Style.java │ │ ├── TraceConfigzZPageHandler.java │ │ ├── TracezZPageHandler.java │ │ ├── ZPageHandler.java │ │ ├── ZPageHandlers.java │ │ └── ZPageHttpHandler.java │ └── test │ └── java │ └── io │ └── opencensus │ └── contrib │ └── zpages │ ├── RpczZPageHandlerTest.java │ ├── StatszZPageHandlerTest.java │ ├── TracezZPageHandlerTest.java │ ├── ZPageHandlersTest.java │ └── ZPageHttpHandlerTest.java ├── examples ├── README.md ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pom.xml ├── settings.gradle ├── spring │ └── servlet │ │ ├── .gitignore │ │ ├── application.properties │ │ ├── build.gradle │ │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── pom.xml │ │ ├── settings.gradle │ │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── examples │ │ │ └── spring │ │ │ └── servlet │ │ │ ├── Application.java │ │ │ ├── ApplicationAutoConfiguration.java │ │ │ └── HelloController.java │ │ └── resources │ │ ├── META-INF │ │ └── spring.factories │ │ └── application.properties └── src │ └── main │ ├── java │ └── io │ │ └── opencensus │ │ └── examples │ │ ├── gauges │ │ ├── DerivedDoubleGaugeQuickstart.java │ │ ├── DerivedLongGaugeQuickstart.java │ │ ├── DoubleGaugeQuickstart.java │ │ └── LongGaugeQuickstart.java │ │ ├── grpc │ │ └── helloworld │ │ │ ├── HelloWorldClient.java │ │ │ ├── HelloWorldServer.java │ │ │ └── HelloWorldUtils.java │ │ ├── helloworld │ │ └── QuickStart.java │ │ ├── http │ │ └── jetty │ │ │ ├── client │ │ │ └── HelloWorldClient.java │ │ │ └── server │ │ │ └── HelloWorldServer.java │ │ ├── ocagent │ │ └── OcAgentExportersQuickStart.java │ │ ├── quickstart │ │ ├── Repl.java │ │ └── prometheus.yaml │ │ ├── stats │ │ └── StackdriverQuickstart.java │ │ ├── tags │ │ └── TagContextExample.java │ │ ├── trace │ │ ├── MultiSpansContextTracing.java │ │ ├── MultiSpansScopedTracing.java │ │ ├── MultiSpansTracing.java │ │ └── Utils.java │ │ └── zpages │ │ └── ZPagesTester.java │ └── proto │ └── helloworld.proto ├── exporters ├── metrics │ ├── ocagent │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── io │ │ │ │ └── opencensus │ │ │ │ └── exporter │ │ │ │ └── metrics │ │ │ │ └── ocagent │ │ │ │ ├── MetricsProtoUtils.java │ │ │ │ ├── OcAgentMetricsExporter.java │ │ │ │ ├── OcAgentMetricsExporterConfiguration.java │ │ │ │ ├── OcAgentMetricsExporterWorker.java │ │ │ │ ├── OcAgentMetricsServiceExportRpcHandler.java │ │ │ │ ├── OcAgentNodeUtils.java │ │ │ │ └── package-info.java │ │ │ └── test │ │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── metrics │ │ │ └── ocagent │ │ │ ├── FakeOcAgentMetricsServiceGrpcImpl.java │ │ │ ├── MetricsProtoUtilsTests.java │ │ │ ├── OcAgentMetricsExporterConfigurationTest.java │ │ │ ├── OcAgentMetricsExporterIntegrationTest.java │ │ │ └── OcAgentMetricsServiceExportRpcHandlerTest.java │ └── util │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── metrics │ │ │ └── util │ │ │ ├── IntervalMetricReader.java │ │ │ ├── MetricExporter.java │ │ │ ├── MetricReader.java │ │ │ └── QueueMetricProducer.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── metrics │ │ └── util │ │ ├── FakeMetricExporter.java │ │ ├── IntervalMetricReaderTest.java │ │ ├── MetricReaderTest.java │ │ └── QueueMetricProducerTest.java ├── stats │ ├── prometheus │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── io │ │ │ │ └── opencensus │ │ │ │ └── exporter │ │ │ │ └── stats │ │ │ │ └── prometheus │ │ │ │ ├── PrometheusExportUtils.java │ │ │ │ ├── PrometheusStatsCollector.java │ │ │ │ └── PrometheusStatsConfiguration.java │ │ │ └── test │ │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── stats │ │ │ └── prometheus │ │ │ ├── PrometheusExportUtilsTest.java │ │ │ └── PrometheusStatsCollectorTest.java │ ├── signalfx │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── io │ │ │ │ └── opencensus │ │ │ │ └── exporter │ │ │ │ └── stats │ │ │ │ └── signalfx │ │ │ │ ├── SignalFxMetricExporter.java │ │ │ │ ├── SignalFxMetricsSenderFactory.java │ │ │ │ ├── SignalFxSessionAdaptor.java │ │ │ │ ├── SignalFxStatsConfiguration.java │ │ │ │ └── SignalFxStatsExporter.java │ │ │ └── test │ │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── stats │ │ │ └── signalfx │ │ │ ├── SignalFxMetricExporterTest.java │ │ │ ├── SignalFxSessionAdaptorTest.java │ │ │ ├── SignalFxStatsConfigurationTest.java │ │ │ └── SignalFxStatsExporterTest.java │ └── stackdriver │ │ ├── README.md │ │ ├── build.gradle │ │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── stats │ │ │ └── stackdriver │ │ │ ├── CreateMetricDescriptorExporter.java │ │ │ ├── CreateTimeSeriesExporter.java │ │ │ ├── StackdriverExportUtils.java │ │ │ ├── StackdriverStatsConfiguration.java │ │ │ └── StackdriverStatsExporter.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── stats │ │ └── stackdriver │ │ ├── CreateMetricDescriptorExporterTest.java │ │ ├── CreateTimeSeriesExporterTest.java │ │ ├── FakeMetricServiceClient.java │ │ ├── StackdriverExportUtilsTest.java │ │ ├── StackdriverStatsConfigurationTest.java │ │ └── StackdriverStatsExporterTest.java └── trace │ ├── datadog │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── trace │ │ │ └── datadog │ │ │ ├── DatadogExporterHandler.java │ │ │ ├── DatadogSpan.java │ │ │ ├── DatadogTraceConfiguration.java │ │ │ └── DatadogTraceExporter.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── trace │ │ └── datadog │ │ └── DatadogExporterHandlerTest.java │ ├── elasticsearch │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── trace │ │ │ └── elasticsearch │ │ │ ├── ElasticsearchTraceConfiguration.java │ │ │ ├── ElasticsearchTraceExporter.java │ │ │ ├── ElasticsearchTraceHandler.java │ │ │ └── JsonConversionUtils.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── trace │ │ └── elasticsearch │ │ ├── ElasticsearchTraceExporterTest.java │ │ └── JsonConversionUtilsTest.java │ ├── instana │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── trace │ │ │ └── instana │ │ │ ├── InstanaExporterConfiguration.java │ │ │ ├── InstanaExporterHandler.java │ │ │ └── InstanaTraceExporter.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── trace │ │ └── instana │ │ ├── InstanaExporterHandlerTest.java │ │ └── InstanaTraceExporterTest.java │ ├── jaeger │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── trace │ │ │ └── jaeger │ │ │ ├── JaegerExporterConfiguration.java │ │ │ ├── JaegerExporterHandler.java │ │ │ └── JaegerTraceExporter.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── trace │ │ └── jaeger │ │ ├── JaegerExporterConfigurationTest.java │ │ ├── JaegerExporterHandlerIntegrationTest.java │ │ ├── JaegerExporterHandlerTest.java │ │ └── JaegerTraceExporterTest.java │ ├── logging │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── trace │ │ │ └── logging │ │ │ ├── LoggingExporter.java │ │ │ └── LoggingTraceExporter.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── trace │ │ └── logging │ │ └── LoggingTraceExporterTest.java │ ├── ocagent │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── trace │ │ │ └── ocagent │ │ │ ├── OcAgentNodeUtils.java │ │ │ ├── OcAgentTraceExporter.java │ │ │ ├── OcAgentTraceExporterConfiguration.java │ │ │ ├── OcAgentTraceExporterHandler.java │ │ │ ├── OcAgentTraceServiceConfigRpcHandler.java │ │ │ ├── OcAgentTraceServiceConnectionWorker.java │ │ │ ├── OcAgentTraceServiceExportRpcHandler.java │ │ │ ├── TraceProtoUtils.java │ │ │ └── package-info.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── trace │ │ └── ocagent │ │ ├── FakeOcAgentTraceServiceGrpcImpl.java │ │ ├── FakeOcAgentTraceServiceGrpcImplTest.java │ │ ├── OcAgentNodeUtilsTest.java │ │ ├── OcAgentTraceExporterConfigurationTest.java │ │ ├── OcAgentTraceExporterIntegrationTest.java │ │ ├── OcAgentTraceExporterTest.java │ │ ├── OcAgentTraceServiceRpcHandlersTest.java │ │ └── TraceProtoUtilsTest.java │ ├── stackdriver │ ├── README.md │ ├── build.gradle │ └── src │ │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── opencensus │ │ │ └── exporter │ │ │ └── trace │ │ │ └── stackdriver │ │ │ ├── StackdriverExporter.java │ │ │ ├── StackdriverTraceConfiguration.java │ │ │ ├── StackdriverTraceExporter.java │ │ │ └── StackdriverV2ExporterHandler.java │ │ └── test │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── trace │ │ └── stackdriver │ │ ├── StackdriverTraceConfigurationTest.java │ │ ├── StackdriverTraceExporterTest.java │ │ ├── StackdriverV2ExporterHandlerExportTest.java │ │ └── StackdriverV2ExporterHandlerProtoTest.java │ ├── util │ ├── README.md │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── trace │ │ └── util │ │ └── TimeLimitedHandler.java │ └── zipkin │ ├── README.md │ ├── build.gradle │ └── src │ ├── main │ └── java │ │ └── io │ │ └── opencensus │ │ └── exporter │ │ └── trace │ │ └── zipkin │ │ ├── ZipkinExporter.java │ │ ├── ZipkinExporterConfiguration.java │ │ ├── ZipkinExporterHandler.java │ │ └── ZipkinTraceExporter.java │ └── test │ └── java │ └── io │ └── opencensus │ └── exporter │ └── trace │ └── zipkin │ ├── ZipkinExporterConfigurationTest.java │ ├── ZipkinExporterHandlerTest.java │ └── ZipkinTraceExporterTest.java ├── findbugs-exclude.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── impl ├── README.md ├── build.gradle └── src │ ├── main │ └── java │ │ └── io │ │ └── opencensus │ │ ├── impl │ │ ├── internal │ │ │ └── DisruptorEventQueue.java │ │ ├── metrics │ │ │ └── MetricsComponentImpl.java │ │ ├── stats │ │ │ └── StatsComponentImpl.java │ │ ├── tags │ │ │ └── TagsComponentImpl.java │ │ └── trace │ │ │ ├── TraceComponentImpl.java │ │ │ └── internal │ │ │ └── ThreadLocalRandomHandler.java │ │ └── trace │ │ └── TraceComponentImpl.java │ └── test │ └── java │ └── io │ └── opencensus │ └── impl │ ├── internal │ └── DisruptorEventQueueTest.java │ ├── metrics │ └── MetricsTest.java │ ├── stats │ └── StatsTest.java │ ├── tags │ └── TagsTest.java │ └── trace │ └── TracingTest.java ├── impl_core ├── README.md ├── build.gradle └── src │ ├── jmh │ └── java │ │ └── io │ │ └── opencensus │ │ └── implcore │ │ └── trace │ │ └── propagation │ │ ├── B3FormatImplBenchmark.java │ │ ├── BinaryFormatImplBenchmark.java │ │ ├── TextFormatBenchmarkBase.java │ │ └── TraceContextImplBenchmark.java │ ├── main │ └── java │ │ └── io │ │ └── opencensus │ │ └── implcore │ │ ├── common │ │ └── MillisClock.java │ │ ├── internal │ │ ├── CheckerFrameworkUtils.java │ │ ├── CurrentState.java │ │ ├── DaemonThreadFactory.java │ │ ├── EventQueue.java │ │ ├── NoopScope.java │ │ ├── SimpleEventQueue.java │ │ ├── TimestampConverter.java │ │ ├── Utils.java │ │ └── VarInt.java │ │ ├── metrics │ │ ├── DerivedDoubleCumulativeImpl.java │ │ ├── DerivedDoubleGaugeImpl.java │ │ ├── DerivedLongCumulativeImpl.java │ │ ├── DerivedLongGaugeImpl.java │ │ ├── DoubleCumulativeImpl.java │ │ ├── DoubleGaugeImpl.java │ │ ├── LongCumulativeImpl.java │ │ ├── LongGaugeImpl.java │ │ ├── Meter.java │ │ ├── MetricRegistryImpl.java │ │ ├── MetricsComponentImplBase.java │ │ └── export │ │ │ ├── ExportComponentImpl.java │ │ │ └── MetricProducerManagerImpl.java │ │ ├── stats │ │ ├── IntervalBucket.java │ │ ├── MeasureMapImpl.java │ │ ├── MeasureMapInternal.java │ │ ├── MeasureToViewMap.java │ │ ├── MetricProducerImpl.java │ │ ├── MetricUtils.java │ │ ├── MutableAggregation.java │ │ ├── MutableViewData.java │ │ ├── RecordUtils.java │ │ ├── StatsComponentImplBase.java │ │ ├── StatsManager.java │ │ ├── StatsRecorderImpl.java │ │ └── ViewManagerImpl.java │ │ ├── tags │ │ ├── CurrentTagMapUtils.java │ │ ├── NoopTagMapBuilder.java │ │ ├── TagContextUtils.java │ │ ├── TagMapBuilderImpl.java │ │ ├── TagMapImpl.java │ │ ├── TagValueWithMetadata.java │ │ ├── TaggerImpl.java │ │ ├── TagsComponentImplBase.java │ │ └── propagation │ │ │ ├── BinarySerializationUtils.java │ │ │ ├── CorrelationContextFormat.java │ │ │ ├── TagContextBinarySerializerImpl.java │ │ │ └── TagPropagationComponentImpl.java │ │ └── trace │ │ ├── NoRecordEventsSpanImpl.java │ │ ├── RecordEventsSpanImpl.java │ │ ├── SpanBuilderImpl.java │ │ ├── StartEndHandlerImpl.java │ │ ├── TraceComponentImplBase.java │ │ ├── TracerImpl.java │ │ ├── config │ │ └── TraceConfigImpl.java │ │ ├── export │ │ ├── ExportComponentImpl.java │ │ ├── InProcessRunningSpanStore.java │ │ ├── InProcessSampledSpanStoreImpl.java │ │ ├── SampledSpanStoreImpl.java │ │ └── SpanExporterImpl.java │ │ ├── internal │ │ ├── ConcurrentIntrusiveList.java │ │ └── RandomHandler.java │ │ └── propagation │ │ ├── B3Format.java │ │ ├── BinaryFormatImpl.java │ │ ├── PropagationComponentImpl.java │ │ └── TraceContextFormat.java │ └── test │ └── java │ └── io │ └── opencensus │ └── implcore │ ├── internal │ ├── CurrentStateTest.java │ ├── TimestampConverterTest.java │ └── UtilsTest.java │ ├── metrics │ ├── DerivedDoubleCumulativeImplTest.java │ ├── DerivedDoubleGaugeImplTest.java │ ├── DerivedLongCumulativeImplTest.java │ ├── DerivedLongGaugeImplTest.java │ ├── DoubleCumulativeImplTest.java │ ├── DoubleGaugeImplTest.java │ ├── LongCumulativeImplTest.java │ ├── LongGaugeImplTest.java │ ├── MetricRegistryImplTest.java │ ├── MetricsComponentImplBaseTest.java │ └── export │ │ ├── ExportComponentImplTest.java │ │ └── MetricProducerManagerImplTest.java │ ├── stats │ ├── IntervalBucketTest.java │ ├── MeasureMapInternalTest.java │ ├── MeasureToViewMapTest.java │ ├── MetricUtilsTest.java │ ├── MutableAggregationTest.java │ ├── MutableViewDataTest.java │ ├── RecordUtilsTest.java │ ├── StatsComponentImplBaseTest.java │ ├── StatsRecorderImplTest.java │ ├── StatsTestUtil.java │ └── ViewManagerImplTest.java │ ├── tags │ ├── CurrentTagMapUtilsTest.java │ ├── ScopedTagMapTest.java │ ├── TagMapImplTest.java │ ├── TaggerImplTest.java │ ├── TagsComponentImplBaseTest.java │ ├── TagsTestUtil.java │ └── propagation │ │ ├── CorrelationContextFormatTest.java │ │ ├── TagContextBinarySerializerImplTest.java │ │ ├── TagContextDeserializationTest.java │ │ ├── TagContextRoundtripTest.java │ │ └── TagContextSerializationTest.java │ └── trace │ ├── NoRecordEventsSpanImplTest.java │ ├── RecordEventsSpanImplTest.java │ ├── SpanBuilderImplTest.java │ ├── TraceComponentImplBaseTest.java │ ├── TracerImplTest.java │ ├── config │ └── TraceConfigImplTest.java │ ├── export │ ├── ExportComponentImplTest.java │ ├── InProcessRunningSpanStoreImplTest.java │ ├── InProcessSampledSpanStoreImplTest.java │ ├── NoopInProcessRunningSpanStoreTest.java │ ├── NoopSampledSpanStoreImplTest.java │ └── SpanExporterImplTest.java │ ├── internal │ └── ConcurrentIntrusiveListTest.java │ └── propagation │ ├── B3FormatTest.java │ ├── BinaryFormatImplTest.java │ ├── PropagationComponentImplTest.java │ └── TraceContextFormatTest.java ├── impl_lite ├── README.md ├── build.gradle └── src │ ├── main │ └── java │ │ └── io │ │ └── opencensus │ │ ├── impllite │ │ ├── metrics │ │ │ └── MetricsComponentImplLite.java │ │ ├── stats │ │ │ └── StatsComponentImplLite.java │ │ ├── tags │ │ │ └── TagsComponentImplLite.java │ │ └── trace │ │ │ └── TraceComponentImplLite.java │ │ └── trace │ │ └── TraceComponentImplLite.java │ └── test │ └── java │ └── io │ └── opencensus │ └── impllite │ ├── metrics │ └── MetricsTest.java │ ├── stats │ └── StatsTest.java │ ├── tags │ └── TagsTest.java │ └── trace │ └── TraceComponentImplLiteTest.java ├── settings.gradle └── testing ├── README.md ├── build.gradle └── src ├── main └── java │ └── io │ └── opencensus │ └── testing │ ├── common │ └── TestClock.java │ └── export │ └── TestHandler.java └── test └── java └── io └── opencensus └── testing └── common └── TestClockTest.java /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners file. 2 | # This file controls who is tagged for review for any given pull request. 3 | 4 | # For anything not explicitly taken by someone else: 5 | * @census-instrumentation/global-owners @dinooliva @rghetia @songy23 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve. 4 | labels: bug 5 | --- 6 | 7 | Please answer these questions before submitting a bug report. 8 | 9 | ### What version of OpenCensus are you using? 10 | 11 | 12 | ### What JVM are you using (`java -version`)? 13 | 14 | 15 | ### What did you do? 16 | If possible, provide a recipe for reproducing the error. 17 | 18 | 19 | ### What did you expect to see? 20 | 21 | 22 | ### What did you see instead? 23 | 24 | 25 | ### Additional context 26 | Add any other context about the problem here. 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project. 4 | labels: feature-request 5 | --- 6 | 7 | **NB:** Before opening a feature request against this repo, consider whether the feature should be available across all languages in the OpenCensus libraries. If so, please [open an issue on opencensus-specs](https://github.com/census-instrumentation/opencensus-specs/issues/new) first. 8 | 9 | ### Is your feature request related to a problem? If so, please describe it. 10 | A clear and concise description of what the problem is, e.g. I need to be able to ... 11 | 12 | 13 | ### Describe the solution you'd like. 14 | A clear and concise description of what you want to happen. 15 | 16 | 17 | ### Describe alternatives you've considered. 18 | A clear and concise description of any alternative solutions or features you've considered. 19 | 20 | 21 | ### Additional context. 22 | Add any other context or screenshots about the feature request here. 23 | -------------------------------------------------------------------------------- /.github/workflows/build-checker.yml: -------------------------------------------------------------------------------- 1 | name: Build Checker 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | - v0.* 8 | 9 | jobs: 10 | build: 11 | name: Build Checker 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2.3.4 15 | with: 16 | fetch-depth: 0 17 | - id: setup-java 18 | name: Setup Java 8 19 | uses: actions/setup-java@v2 20 | with: 21 | distribution: adopt 22 | java-version: 8 23 | - uses: burrunan/gradle-cache-action@v1.10 24 | with: 25 | remote-build-cache-proxy-enabled: false 26 | arguments: clean assemble -PcheckerFramework=true -------------------------------------------------------------------------------- /.github/workflows/build-gradle-examples.yml: -------------------------------------------------------------------------------- 1 | name: Build Gradle Examples 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | - v0.* 8 | 9 | jobs: 10 | build: 11 | name: Build Gradle Examples Ubuntu 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2.3.4 15 | with: 16 | fetch-depth: 0 17 | - id: setup-java 18 | name: Setup Java 8 19 | uses: actions/setup-java@v2 20 | with: 21 | distribution: adopt 22 | java-version: 8 23 | - uses: burrunan/gradle-cache-action@v1.10 24 | with: 25 | remote-build-cache-proxy-enabled: false 26 | - name: Build Examples 27 | working-directory: ./examples 28 | run: ./gradlew clean assemble --stacktrace && ./gradlew check && ./gradlew verGJF 29 | - name: Build Spring Servlet example 30 | working-directory: ./examples/spring/servlet 31 | run: ./gradlew clean assemble --stacktrace && ./gradlew check && ./gradlew verGJF -------------------------------------------------------------------------------- /.github/workflows/build-maven-examples.yml: -------------------------------------------------------------------------------- 1 | name: Build Maven Examples 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | - v0.* 8 | 9 | jobs: 10 | build: 11 | name: Build Maven Examples Ubuntu 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2.3.4 15 | with: 16 | fetch-depth: 0 17 | - id: setup-java 18 | name: Setup Java 8 19 | uses: actions/setup-java@v2 20 | with: 21 | distribution: adopt 22 | java-version: 8 23 | - name: Build Examples 24 | working-directory: ./examples 25 | run: mvn --batch-mode --update-snapshots clean package appassembler:assemble -e 26 | - name: Build Spring Servlet example 27 | working-directory: ./examples/spring/servlet 28 | run: mvn --batch-mode --update-snapshots clean package appassembler:assemble -e -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | - v0.* 8 | 9 | jobs: 10 | build: 11 | name: Build 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: 16 | - macos-latest 17 | - ubuntu-latest 18 | java: 19 | - 8 20 | # TODO: Java 11 build doesn't work due to Java7 target. 21 | include: 22 | - os: ubuntu-latest 23 | java: 8 24 | coverage: true 25 | steps: 26 | - uses: actions/checkout@v2.3.4 27 | with: 28 | fetch-depth: 0 29 | - id: setup-java 30 | name: Setup Java ${{ matrix.java }} 31 | uses: actions/setup-java@v2 32 | with: 33 | distribution: adopt 34 | java-version: ${{ matrix.java }} 35 | - run: ./gradlew clean assemble check --stacktrace 36 | # TODO: Run jacocoTestReport 37 | # TODO: Run verGJF -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle 2 | build 3 | gradle.properties 4 | .gradle 5 | local.properties 6 | out/ 7 | 8 | # Protobuf 9 | gen_gradle 10 | 11 | # Bazel 12 | bazel-* 13 | 14 | # Maven (proto) 15 | target 16 | 17 | # IntelliJ IDEA 18 | .idea 19 | *.iml 20 | .editorconfig 21 | 22 | # Eclipse 23 | .classpath 24 | .project 25 | .settings 26 | bin 27 | 28 | # NetBeans 29 | /.nb-gradle 30 | /.nb-gradle-properties 31 | 32 | # VS Code 33 | .vscode 34 | 35 | # OS X 36 | .DS_Store 37 | 38 | # Emacs 39 | *~ 40 | \#*\# 41 | 42 | # Vim 43 | .swp 44 | 45 | # Other 46 | TAGS 47 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/.gitmodules -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Google Inc. -------------------------------------------------------------------------------- /api/README.md: -------------------------------------------------------------------------------- 1 | OpenCensus API 2 | ====================================================== 3 | 4 | * Java 6 and Android compatible. 5 | * The abstract classes in this directory can be subclassed to create alternative 6 | implementations of the OpenCensus library. 7 | -------------------------------------------------------------------------------- /api/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus API' 2 | 3 | dependencies { 4 | compile libraries.grpc_context 5 | 6 | compileOnly libraries.auto_value 7 | 8 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 9 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 10 | } 11 | 12 | javadoc { 13 | exclude 'io/opencensus/internal/**' 14 | exclude 'io/opencensus/trace/internal/**' 15 | } 16 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/Clock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.common; 18 | 19 | /** 20 | * Interface for getting the current time. 21 | * 22 | * @since 0.5 23 | */ 24 | public abstract class Clock { 25 | 26 | /** 27 | * Obtains the current instant from this clock. 28 | * 29 | * @return the current instant. 30 | * @since 0.5 31 | */ 32 | public abstract Timestamp now(); 33 | 34 | /** 35 | * Returns a time measurement with nanosecond precision that can only be used to calculate elapsed 36 | * time. 37 | * 38 | * @return a time measurement with nanosecond precision that can only be used to calculate elapsed 39 | * time. 40 | * @since 0.5 41 | */ 42 | public abstract long nowNanos(); 43 | } 44 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/Function.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-17, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.common; 18 | 19 | /** 20 | * Used to specify matching functions for use encoding tagged unions (i.e. sum types) in Java. See 21 | * {@link io.opencensus.trace.AttributeValue#match} for an example of its use. 22 | * 23 | *

Note: This class is based on the java.util.Function class added in Java 1.8. We cannot use the 24 | * Function from Java 1.8 because this library is Java 1.6 compatible. 25 | * 26 | * @since 0.5 27 | */ 28 | public interface Function { 29 | 30 | /** 31 | * Applies the function to the given argument. 32 | * 33 | * @param arg the argument to the function. 34 | * @return the result of the function. 35 | * @since 0.5 36 | */ 37 | B apply(A arg); 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/Internal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.common; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Annotates a program element (class, method, package etc) which is internal to OpenCensus, not 27 | * part of the public API, and should not be used by users of the OpenCensus library. 28 | * 29 | * @since 0.5 30 | */ 31 | @Internal 32 | @Retention(RetentionPolicy.SOURCE) 33 | @Target({ 34 | ElementType.ANNOTATION_TYPE, 35 | ElementType.CONSTRUCTOR, 36 | ElementType.FIELD, 37 | ElementType.METHOD, 38 | ElementType.PACKAGE, 39 | ElementType.TYPE 40 | }) 41 | @Documented 42 | public @interface Internal {} 43 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/NonThrowingCloseable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.common; 18 | 19 | import java.io.Closeable; 20 | 21 | /** 22 | * An {@link Closeable} which cannot throw a checked exception. 23 | * 24 | *

This is useful because such a reversion otherwise requires the caller to catch the 25 | * (impossible) Exception in the try-with-resources. 26 | * 27 | *

Example of usage: 28 | * 29 | *

30 |  *   try (NonThrowingAutoCloseable ctx = tryEnter()) {
31 |  *     ...
32 |  *   }
33 |  * 
34 | * 35 | * @deprecated {@link Scope} is a better match for operations involving the current context. 36 | * @since 0.5 37 | */ 38 | @Deprecated 39 | public interface NonThrowingCloseable extends Closeable { 40 | @Override 41 | void close(); 42 | } 43 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-17, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.common; 18 | 19 | /** 20 | * Class holder for all common constants (such as the version) for the OpenCensus Java library. 21 | * 22 | * @since 0.8 23 | */ 24 | @ExperimentalApi 25 | public final class OpenCensusLibraryInformation { 26 | 27 | /** 28 | * The current version of the OpenCensus Java library. 29 | * 30 | * @since 0.8 31 | */ 32 | public static final String VERSION = "0.32.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION 33 | 34 | private OpenCensusLibraryInformation() {} 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/Scope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.common; 18 | 19 | /** 20 | * A {@link java.io.Closeable} that represents a change to the current context over a scope of code. 21 | * {@link Scope#close} cannot throw a checked exception. 22 | * 23 | *

Example of usage: 24 | * 25 | *

26 |  *   try (Scope ctx = tryEnter()) {
27 |  *     ...
28 |  *   }
29 |  * 
30 | * 31 | * @since 0.6 32 | */ 33 | @SuppressWarnings("deprecation") 34 | public interface Scope extends NonThrowingCloseable { 35 | @Override 36 | void close(); 37 | } 38 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/ServerStatsDeserializationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.common; 18 | 19 | /** 20 | * Exception thrown when a {@link ServerStats} cannot be parsed. 21 | * 22 | * @since 0.16 23 | */ 24 | public final class ServerStatsDeserializationException extends Exception { 25 | private static final long serialVersionUID = 0L; 26 | 27 | /** 28 | * Constructs a new {@code ServerStatsDeserializationException} with the given message. 29 | * 30 | * @param message a message describing the error. 31 | * @since 0.16 32 | */ 33 | public ServerStatsDeserializationException(String message) { 34 | super(message); 35 | } 36 | 37 | /** 38 | * Constructs a new {@code ServerStatsDeserializationException} with the given message and cause. 39 | * 40 | * @param message a message describing the error. 41 | * @param cause the cause of the error. 42 | * @since 0.16 43 | */ 44 | public ServerStatsDeserializationException(String message, Throwable cause) { 45 | super(message, cause); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/ToDoubleFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.common; 18 | 19 | /*>>> 20 | import org.checkerframework.checker.nullness.qual.Nullable; 21 | */ 22 | 23 | /** 24 | * Represents a function that produces a double-valued result. See {@link 25 | * io.opencensus.metrics.MetricRegistry} for an example of its use. 26 | * 27 | *

Note: This class is based on the java.util.ToDoubleFunction class added in Java 1.8. We cannot 28 | * use the Function from Java 1.8 because this library is Java 1.6 compatible. 29 | * 30 | * @since 0.16 31 | */ 32 | public interface ToDoubleFunction { 33 | 34 | /** 35 | * Applies this function to the given argument. 36 | * 37 | * @param value the function argument. 38 | * @return the function result. 39 | */ 40 | double applyAsDouble(/*@Nullable*/ T value); 41 | } 42 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/ToLongFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.common; 18 | 19 | /*>>> 20 | import org.checkerframework.checker.nullness.qual.Nullable; 21 | */ 22 | 23 | /** 24 | * Represents a function that produces a long-valued result. See {@link 25 | * io.opencensus.metrics.MetricRegistry} for an example of its use. 26 | * 27 | *

Note: This class is based on the java.util.ToLongFunction class added in Java 1.8. We cannot 28 | * use the Function from Java 1.8 because this library is Java 1.6 compatible. 29 | * 30 | * @since 0.16 31 | */ 32 | public interface ToLongFunction { 33 | /** 34 | * Applies this function to the given argument. 35 | * 36 | * @param value the function argument. 37 | * @return the function result. 38 | */ 39 | long applyAsLong(/*@Nullable*/ T value); 40 | } 41 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/common/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** Common API between different packages in this artifact. */ 18 | package io.opencensus.common; 19 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/internal/DefaultVisibilityForTesting.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.internal; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Indicates that an element is package-private instead of private only for the purpose of testing. 26 | * This annotation is only meant to be used as documentation in the source code. 27 | */ 28 | @Retention(RetentionPolicy.SOURCE) 29 | @Target({ 30 | ElementType.ANNOTATION_TYPE, 31 | ElementType.CONSTRUCTOR, 32 | ElementType.FIELD, 33 | ElementType.METHOD, 34 | ElementType.PACKAGE, 35 | ElementType.TYPE 36 | }) 37 | public @interface DefaultVisibilityForTesting {} 38 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/internal/NoopScope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.internal; 18 | 19 | import io.opencensus.common.Scope; 20 | 21 | /** A {@link Scope} that does nothing when it is created or closed. */ 22 | public final class NoopScope implements Scope { 23 | private static final Scope INSTANCE = new NoopScope(); 24 | 25 | private NoopScope() {} 26 | 27 | /** 28 | * Returns a {@code NoopScope}. 29 | * 30 | * @return a {@code NoopScope}. 31 | */ 32 | public static Scope getInstance() { 33 | return INSTANCE; 34 | } 35 | 36 | @Override 37 | public void close() {} 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/internal/StringUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-17, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.internal; 18 | 19 | /** Internal utility methods for working with tag keys, tag values, and metric names. */ 20 | public final class StringUtils { 21 | 22 | /** 23 | * Determines whether the {@code String} contains only printable characters. 24 | * 25 | * @param str the {@code String} to be validated. 26 | * @return whether the {@code String} contains only printable characters. 27 | */ 28 | public static boolean isPrintableString(String str) { 29 | for (int i = 0; i < str.length(); i++) { 30 | if (!isPrintableChar(str.charAt(i))) { 31 | return false; 32 | } 33 | } 34 | return true; 35 | } 36 | 37 | private static boolean isPrintableChar(char ch) { 38 | return ch >= ' ' && ch <= '~'; 39 | } 40 | 41 | private StringUtils() {} 42 | } 43 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/internal/ZeroTimeClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.internal; 18 | 19 | import io.opencensus.common.Clock; 20 | import io.opencensus.common.Timestamp; 21 | import javax.annotation.concurrent.Immutable; 22 | 23 | /** A {@link Clock} that always returns 0. */ 24 | @Immutable 25 | public final class ZeroTimeClock extends Clock { 26 | private static final ZeroTimeClock INSTANCE = new ZeroTimeClock(); 27 | private static final Timestamp ZERO_TIMESTAMP = Timestamp.create(0, 0); 28 | 29 | private ZeroTimeClock() {} 30 | 31 | /** 32 | * Returns a {@code ZeroTimeClock}. 33 | * 34 | * @return a {@code ZeroTimeClock}. 35 | */ 36 | public static ZeroTimeClock getInstance() { 37 | return INSTANCE; 38 | } 39 | 40 | @Override 41 | public Timestamp now() { 42 | return ZERO_TIMESTAMP; 43 | } 44 | 45 | @Override 46 | public long nowNanos() { 47 | return 0; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/internal/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Interfaces and implementations that are internal to OpenCensus. 19 | * 20 | *

All the content under this package and its subpackages are considered annotated with {@link 21 | * io.opencensus.common.Internal}. 22 | */ 23 | @io.opencensus.common.Internal 24 | package io.opencensus.internal; 25 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/metrics/data/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * This package describes common data models in Metrics that are shared across multiple packages. 19 | * 20 | *

WARNING: Currently all the public classes under this package are marked as {@link 21 | * io.opencensus.common.ExperimentalApi}. The classes and APIs under {@link io.opencensus.metrics} 22 | * are likely to get backwards-incompatible updates in the future. DO NOT USE except for 23 | * experimental purposes. 24 | */ 25 | @io.opencensus.common.ExperimentalApi 26 | package io.opencensus.metrics.data; 27 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/metrics/export/MetricProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.metrics.export; 18 | 19 | import io.opencensus.common.ExperimentalApi; 20 | import java.util.Collection; 21 | 22 | /** 23 | * A {@link Metric} producer that can be registered for exporting using {@link 24 | * MetricProducerManager}. 25 | * 26 | *

All implementation MUST be thread-safe. 27 | * 28 | * @since 0.17 29 | */ 30 | @ExperimentalApi 31 | public abstract class MetricProducer { 32 | 33 | /** 34 | * Returns a collection of produced {@link Metric}s to be exported. 35 | * 36 | * @return a collection of produced {@link Metric}s to be exported. 37 | * @since 0.17 38 | */ 39 | public abstract Collection getMetrics(); 40 | } 41 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/metrics/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * This package describes the Metrics data model. Metrics are a data model for what stats exporters 19 | * take as input. This data model may eventually become the wire format for metrics. 20 | * 21 | *

WARNING: Currently all the public classes under this package are marked as {@link 22 | * io.opencensus.common.ExperimentalApi}. The classes and APIs under {@link io.opencensus.metrics} 23 | * are likely to get backwards-incompatible updates in the future. DO NOT USE except for 24 | * experimental purposes. 25 | * 26 | *

Please see 27 | * https://github.com/census-instrumentation/opencensus-specs/blob/master/stats/Metrics.md and 28 | * https://github.com/census-instrumentation/opencensus-proto/blob/master/opencensus/proto/stats/metrics/metrics.proto 29 | * for more details. 30 | */ 31 | @io.opencensus.common.ExperimentalApi 32 | package io.opencensus.metrics; 33 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/stats/StatsCollectionState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.stats; 18 | 19 | /** 20 | * State of the {@link StatsComponent}. 21 | * 22 | * @since 0.8 23 | */ 24 | public enum StatsCollectionState { 25 | 26 | /** 27 | * State that fully enables stats collection. 28 | * 29 | *

The {@link StatsComponent} collects stats for registered views. 30 | * 31 | * @since 0.8 32 | */ 33 | ENABLED, 34 | 35 | /** 36 | * State that disables stats collection. 37 | * 38 | *

The {@link StatsComponent} does not need to collect stats for registered views and may 39 | * return empty {@link ViewData}s from {@link ViewManager#getView(View.Name)}. 40 | * 41 | * @since 0.8 42 | */ 43 | DISABLED 44 | } 45 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/stats/StatsRecorder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.stats; 18 | 19 | /** 20 | * Provides methods to record stats against tags. 21 | * 22 | * @since 0.8 23 | */ 24 | public abstract class StatsRecorder { 25 | // TODO(sebright): Should we provide convenience methods for only recording one measure? 26 | 27 | /** 28 | * Returns an object for recording multiple measurements. 29 | * 30 | * @return an object for recording multiple measurements. 31 | * @since 0.8 32 | */ 33 | public abstract MeasureMap newMeasureMap(); 34 | } 35 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/stats/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** API for stats recording. */ 18 | // TODO: Add more details. 19 | // TODO: Add code examples. 20 | package io.opencensus.stats; 21 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/tags/InternalUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.tags; 18 | 19 | import java.util.Iterator; 20 | 21 | /** 22 | * Internal tagging utilities. 23 | * 24 | * @since 0.8 25 | */ 26 | @io.opencensus.common.Internal 27 | public final class InternalUtils { 28 | private InternalUtils() {} 29 | 30 | /** 31 | * Internal tag accessor. 32 | * 33 | * @since 0.8 34 | */ 35 | public static Iterator getTags(TagContext tags) { 36 | return tags.getIterator(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/tags/TaggingState.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.tags; 18 | 19 | /** 20 | * State of the {@link TagsComponent}. 21 | * 22 | * @since 0.8 23 | */ 24 | public enum TaggingState { 25 | // TODO(sebright): Should we add a state that propagates the tags, but doesn't allow 26 | // modifications? 27 | 28 | /** 29 | * State that fully enables tagging. 30 | * 31 | *

The {@link TagsComponent} can add tags to {@link TagContext}s, propagate {@code TagContext}s 32 | * in the current context, and serialize {@code TagContext}s. 33 | * 34 | * @since 0.8 35 | */ 36 | ENABLED, 37 | 38 | /** 39 | * State that disables tagging. 40 | * 41 | *

The {@link TagsComponent} may not add tags to {@link TagContext}s, propagate {@code 42 | * TagContext}s in the current context, or serialize {@code TagContext}s. 43 | * 44 | * @since 0.8 45 | */ 46 | // TODO(sebright): Document how this interacts with stats collection. 47 | DISABLED 48 | } 49 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/tags/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * API for associating tags with scoped operations. 19 | * 20 | *

This package manages a set of tags in the {@code io.grpc.Context}. The tags can be used to 21 | * label anything that is associated with a specific operation. For example, the {@code 22 | * io.opencensus.stats} package labels all stats with the current tags. 23 | * 24 | *

{@link io.opencensus.tags.Tag Tags} are key-value pairs. The {@link io.opencensus.tags.TagKey 25 | * keys} and {@link io.opencensus.tags.TagValue values} are wrapped {@code String}s. They are stored 26 | * as a map in a {@link io.opencensus.tags.TagContext}. 27 | * 28 | *

Note that tags are independent of the tracing data that is propagated in the {@code 29 | * io.grpc.Context}, such as trace ID. 30 | */ 31 | // TODO(sebright): Add code examples. 32 | package io.opencensus.tags; 33 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/tags/propagation/TagContextDeserializationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.tags.propagation; 18 | 19 | import io.opencensus.tags.TagContext; 20 | 21 | /** 22 | * Exception thrown when a {@link TagContext} cannot be parsed. 23 | * 24 | * @since 0.8 25 | */ 26 | public final class TagContextDeserializationException extends Exception { 27 | private static final long serialVersionUID = 0L; 28 | 29 | /** 30 | * Constructs a new {@code TagContextParseException} with the given message. 31 | * 32 | * @param message a message describing the error. 33 | * @since 0.8 34 | */ 35 | public TagContextDeserializationException(String message) { 36 | super(message); 37 | } 38 | 39 | /** 40 | * Constructs a new {@code TagContextParseException} with the given message and cause. 41 | * 42 | * @param message a message describing the error. 43 | * @param cause the cause of the error. 44 | * @since 0.8 45 | */ 46 | public TagContextDeserializationException(String message, Throwable cause) { 47 | super(message, cause); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/tags/propagation/TagContextSerializationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.tags.propagation; 18 | 19 | import io.opencensus.tags.TagContext; 20 | 21 | /** 22 | * Exception thrown when a {@link TagContext} cannot be serialized. 23 | * 24 | * @since 0.8 25 | */ 26 | public final class TagContextSerializationException extends Exception { 27 | private static final long serialVersionUID = 0L; 28 | 29 | /** 30 | * Constructs a new {@code TagContextSerializationException} with the given message. 31 | * 32 | * @param message a message describing the error. 33 | * @since 0.8 34 | */ 35 | public TagContextSerializationException(String message) { 36 | super(message); 37 | } 38 | 39 | /** 40 | * Constructs a new {@code TagContextSerializationException} with the given message and cause. 41 | * 42 | * @param message a message describing the error. 43 | * @param cause the cause of the error. 44 | * @since 0.8 45 | */ 46 | public TagContextSerializationException(String message, Throwable cause) { 47 | super(message, cause); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/tags/propagation/TagPropagationComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.tags.propagation; 18 | 19 | import io.opencensus.tags.TagContext; 20 | 21 | /** 22 | * Object containing all supported {@link TagContext} propagation formats. 23 | * 24 | * @since 0.8 25 | */ 26 | public abstract class TagPropagationComponent { 27 | 28 | /** 29 | * Returns the {@link TagContextBinarySerializer} for this implementation. 30 | * 31 | * @return the {@code TagContextBinarySerializer} for this implementation. 32 | * @since 0.8 33 | */ 34 | public abstract TagContextBinarySerializer getBinarySerializer(); 35 | 36 | /** 37 | * Returns the {@link TagContextTextFormat} for this implementation. 38 | * 39 | *

OpenCensus uses W3C Correlation Context as the HTTP text format. For more details, see correlation-context. 41 | * 42 | * @return the {@code TagContextTextFormat} for this implementation. 43 | * @since 0.21 44 | */ 45 | public abstract TagContextTextFormat getCorrelationContextFormat(); 46 | } 47 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/trace/BaseMessageEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.trace; 18 | 19 | /** 20 | * Superclass for {@link MessageEvent} and {@link NetworkEvent} to resolve API backward 21 | * compatibility issue. 22 | * 23 | *

{@code SpanData.create} can't be overloaded with parameter types that differ only in the type 24 | * of the TimedEvent, because the signatures are the same after generic type erasure. {@code 25 | * BaseMessageEvent} allows the same method to accept both {@code TimedEvents} and 26 | * {@code TimedEvents}. 27 | * 28 | *

This class should only be extended by {@code NetworkEvent} and {@code MessageEvent}. 29 | * 30 | * @deprecated This class is for internal use only. 31 | * @since 0.12 32 | */ 33 | @Deprecated 34 | public abstract class BaseMessageEvent { 35 | // package protected to avoid users to extend it. 36 | BaseMessageEvent() {} 37 | } 38 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/trace/ContextHandle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-17, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.trace; 18 | 19 | public interface ContextHandle { 20 | 21 | ContextHandle attach(); 22 | 23 | void detach(ContextHandle contextHandle); 24 | } 25 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/trace/ContextManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-17, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.trace; 18 | 19 | public interface ContextManager { 20 | 21 | ContextHandle currentContext(); 22 | 23 | ContextHandle withValue(ContextHandle contextHandle, @javax.annotation.Nullable Span span); 24 | 25 | Span getValue(ContextHandle contextHandle); 26 | } 27 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/trace/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * API for distributed tracing. 19 | * 20 | *

Distributed tracing, also called distributed request tracing, is a technique that helps 21 | * debugging distributed applications. 22 | * 23 | *

Trace represents a tree of spans. A trace has a root span that encapsulates all the spans from 24 | * start to end, and the children spans being the distinct calls invoked in between. 25 | * 26 | *

{@link io.opencensus.trace.Span} represents a single operation within a trace. 27 | * 28 | *

{@link io.opencensus.trace.Span Spans} are propagated in-process in the {@code 29 | * io.grpc.Context} and between process using one of the wire propagation formats supported in the 30 | * {@code io.opencensus.trace.propagation} package. 31 | */ 32 | // TODO: Add code examples. 33 | package io.opencensus.trace; 34 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/trace/propagation/SpanContextParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.trace.propagation; 18 | 19 | /** 20 | * Exception thrown when a {@link io.opencensus.trace.SpanContext} cannot be parsed. 21 | * 22 | * @since 0.7 23 | */ 24 | public final class SpanContextParseException extends Exception { 25 | private static final long serialVersionUID = 0L; 26 | 27 | /** 28 | * Constructs a new {@code SpanContextParseException} with the given message. 29 | * 30 | * @param message a message describing the parse error. 31 | * @since 0.7 32 | */ 33 | public SpanContextParseException(String message) { 34 | super(message); 35 | } 36 | 37 | /** 38 | * Constructs a new {@code SpanContextParseException} with the given message and cause. 39 | * 40 | * @param message a message describing the parse error. 41 | * @param cause the cause of the parse error. 42 | * @since 0.7 43 | */ 44 | public SpanContextParseException(String message, Throwable cause) { 45 | super(message, cause); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /api/src/main/java/io/opencensus/trace/unsafe/ContextHandleImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-17, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.trace.unsafe; 18 | 19 | import io.grpc.Context; 20 | import io.opencensus.trace.ContextHandle; 21 | 22 | /** {@code ContextHandle} implementation using {@see io.grpc.Context}. */ 23 | class ContextHandleImpl implements ContextHandle { 24 | 25 | private final Context context; 26 | 27 | public ContextHandleImpl(Context context) { 28 | this.context = context; 29 | } 30 | 31 | Context getContext() { 32 | return context; 33 | } 34 | 35 | @Override 36 | public ContextHandle attach() { 37 | return new ContextHandleImpl(context.attach()); 38 | } 39 | 40 | @Override 41 | public void detach(ContextHandle contextHandle) { 42 | ContextHandleImpl impl = (ContextHandleImpl) contextHandle; 43 | context.detach(impl.context); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/internal/StringUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-17, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.internal; 18 | 19 | import static org.junit.Assert.assertFalse; 20 | import static org.junit.Assert.assertTrue; 21 | 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** Tests for {@link StringUtils}. */ 27 | @RunWith(JUnit4.class) 28 | public final class StringUtilsTest { 29 | 30 | @Test 31 | public void isPrintableString() { 32 | assertTrue(StringUtils.isPrintableString("abcd")); 33 | assertFalse(StringUtils.isPrintableString("\2ab\3cd")); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/metrics/MetricsComponentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.metrics; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.opencensus.metrics.export.ExportComponent; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** Unit tests for {@link MetricsComponent}. */ 27 | @RunWith(JUnit4.class) 28 | public class MetricsComponentTest { 29 | @Test 30 | public void defaultExportComponent() { 31 | assertThat(MetricsComponent.newNoopMetricsComponent().getExportComponent()) 32 | .isInstanceOf(ExportComponent.newNoopExportComponent().getClass()); 33 | } 34 | 35 | @Test 36 | public void defaultMetricRegistry() { 37 | assertThat(MetricsComponent.newNoopMetricsComponent().getMetricRegistry()) 38 | .isInstanceOf(MetricRegistry.newNoopMetricRegistry().getClass()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/metrics/data/AttachmentValueTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.metrics.data; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.opencensus.metrics.data.AttachmentValue.AttachmentValueString; 22 | import org.junit.Rule; 23 | import org.junit.Test; 24 | import org.junit.rules.ExpectedException; 25 | import org.junit.runner.RunWith; 26 | import org.junit.runners.JUnit4; 27 | 28 | /** Unit tests for {@link io.opencensus.metrics.data.AttachmentValue}. */ 29 | @RunWith(JUnit4.class) 30 | public class AttachmentValueTest { 31 | 32 | @Rule public final ExpectedException thrown = ExpectedException.none(); 33 | 34 | @Test 35 | public void getValue() { 36 | AttachmentValueString attachmentValue = AttachmentValueString.create("value"); 37 | assertThat(attachmentValue.getValue()).isEqualTo("value"); 38 | } 39 | 40 | @Test 41 | public void preventNullString() { 42 | thrown.expect(NullPointerException.class); 43 | AttachmentValueString.create(null); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/metrics/export/ExportComponentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.metrics.export; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | /** Unit tests for {@link ExportComponent}. */ 26 | @RunWith(JUnit4.class) 27 | public class ExportComponentTest { 28 | @Test 29 | public void defaultMetricExporter() { 30 | assertThat(ExportComponent.newNoopExportComponent().getMetricProducerManager()) 31 | .isInstanceOf(MetricProducerManager.class); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/tags/InternalUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.tags; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import com.google.common.collect.Lists; 22 | import java.util.Iterator; 23 | import org.junit.Test; 24 | import org.junit.runner.RunWith; 25 | import org.junit.runners.JUnit4; 26 | 27 | /** Unit tests for {@link InternalUtils}. */ 28 | @RunWith(JUnit4.class) 29 | public final class InternalUtilsTest { 30 | 31 | @Test 32 | public void getTags() { 33 | final Iterator iterator = 34 | Lists.newArrayList(Tag.create(TagKey.create("k"), TagValue.create("v"))).iterator(); 35 | TagContext ctx = 36 | new TagContext() { 37 | @Override 38 | protected Iterator getIterator() { 39 | return iterator; 40 | } 41 | }; 42 | assertThat(InternalUtils.getTags(ctx)).isSameInstanceAs(iterator); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/tags/TagMetadataTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.tags; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import com.google.common.testing.EqualsTester; 22 | import io.opencensus.tags.TagMetadata.TagTtl; 23 | import org.junit.Test; 24 | import org.junit.runner.RunWith; 25 | import org.junit.runners.JUnit4; 26 | 27 | /** Tests for {@link TagMetadata}. */ 28 | @RunWith(JUnit4.class) 29 | public class TagMetadataTest { 30 | 31 | @Test 32 | public void testGetTagTtl() { 33 | TagMetadata tagMetadata = TagMetadata.create(TagTtl.NO_PROPAGATION); 34 | assertThat(tagMetadata.getTagTtl()).isEqualTo(TagTtl.NO_PROPAGATION); 35 | } 36 | 37 | @Test 38 | public void testEquals() { 39 | new EqualsTester() 40 | .addEqualityGroup( 41 | TagMetadata.create(TagTtl.NO_PROPAGATION), TagMetadata.create(TagTtl.NO_PROPAGATION)) 42 | .addEqualityGroup(TagMetadata.create(TagTtl.UNLIMITED_PROPAGATION)) 43 | .testEquals(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/tags/propagation/TagContextDeserializationExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.tags.propagation; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import java.io.IOException; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** Unit tests for {@link TagContextDeserializationException}. */ 27 | @RunWith(JUnit4.class) 28 | public final class TagContextDeserializationExceptionTest { 29 | 30 | @Test 31 | public void createWithMessage() { 32 | assertThat(new TagContextDeserializationException("my message").getMessage()) 33 | .isEqualTo("my message"); 34 | } 35 | 36 | @Test 37 | public void createWithMessageAndCause() { 38 | IOException cause = new IOException(); 39 | TagContextDeserializationException exception = 40 | new TagContextDeserializationException("my message", cause); 41 | assertThat(exception.getMessage()).isEqualTo("my message"); 42 | assertThat(exception.getCause()).isEqualTo(cause); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/tags/propagation/TagContextSerializationExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.tags.propagation; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import java.io.IOException; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** Unit tests for {@link TagContextSerializationException}. */ 27 | @RunWith(JUnit4.class) 28 | public final class TagContextSerializationExceptionTest { 29 | 30 | @Test 31 | public void createWithMessage() { 32 | assertThat(new TagContextSerializationException("my message").getMessage()) 33 | .isEqualTo("my message"); 34 | } 35 | 36 | @Test 37 | public void createWithMessageAndCause() { 38 | IOException cause = new IOException(); 39 | TagContextSerializationException exception = 40 | new TagContextSerializationException("my message", cause); 41 | assertThat(exception.getMessage()).isEqualTo("my message"); 42 | assertThat(exception.getCause()).isEqualTo(cause); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/trace/export/ExportComponentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.trace.export; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | /** Unit tests for {@link ExportComponent}. */ 26 | @RunWith(JUnit4.class) 27 | public class ExportComponentTest { 28 | private final ExportComponent exportComponent = ExportComponent.newNoopExportComponent(); 29 | 30 | @Test 31 | public void implementationOfSpanExporter() { 32 | assertThat(exportComponent.getSpanExporter()).isEqualTo(SpanExporter.getNoopSpanExporter()); 33 | } 34 | 35 | @Test 36 | public void implementationOfActiveSpans() { 37 | assertThat(exportComponent.getRunningSpanStore()) 38 | .isEqualTo(RunningSpanStore.getNoopRunningSpanStore()); 39 | } 40 | 41 | @Test 42 | public void implementationOfSampledSpanStore() { 43 | assertThat(exportComponent.getSampledSpanStore()) 44 | .isInstanceOf(SampledSpanStore.newNoopSampledSpanStore().getClass()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /api/src/test/java/io/opencensus/trace/propagation/SpanContextParseExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.trace.propagation; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import java.io.IOException; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** Unit tests for {@link SpanContextParseException}. */ 27 | @RunWith(JUnit4.class) 28 | public class SpanContextParseExceptionTest { 29 | 30 | @Test 31 | public void createWithMessage() { 32 | assertThat(new SpanContextParseException("my message").getMessage()).isEqualTo("my message"); 33 | } 34 | 35 | @Test 36 | public void createWithMessageAndCause() { 37 | IOException cause = new IOException(); 38 | SpanContextParseException parseException = new SpanContextParseException("my message", cause); 39 | assertThat(parseException.getMessage()).isEqualTo("my message"); 40 | assertThat(parseException.getCause()).isEqualTo(cause); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | install: 2 | - git submodule update --init --recursive 3 | 4 | build_script: 5 | # The Gradle build script runs the integration tests of contrib/agent using different Java 6 | # versions. %JAVA_HOMES% lists the home directories of the JDK installations used for 7 | # integration testing. Also see https://www.appveyor.com/docs/build-environment/#java. 8 | - set JAVA_HOMES=C:\Program Files\Java\jdk1.8.0\jre 9 | - gradlew.bat clean assemble check --stacktrace 10 | - pushd examples && gradlew.bat clean assemble check --stacktrace && popd 11 | -------------------------------------------------------------------------------- /benchmarks/README.md: -------------------------------------------------------------------------------- 1 | # OpenCensus Benchmarks 2 | 3 | See [here](../CONTRIBUTING.md#benchmarks) for how to run and debug issues with benchmarks. -------------------------------------------------------------------------------- /benchmarks/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Benchmarks' 2 | 3 | dependencies { 4 | compile project(':opencensus-api'), 5 | project(':opencensus-impl-core'), 6 | project(':opencensus-impl-lite'), 7 | project(':opencensus-impl') 8 | } 9 | 10 | jmhReport { 11 | jmhResultPath = project.file("${project.buildDir}/reports/jmh/results.json") 12 | jmhReportOutput = project.file("${project.buildDir}/reports/jmh") 13 | } 14 | 15 | tasks.jmh.finalizedBy tasks.jmhReport 16 | 17 | // Disable checkstyle if not java8. 18 | checkstyleJmh.enabled = JavaVersion.current().isJava8Compatible() 19 | -------------------------------------------------------------------------------- /buildscripts/checkstyle.license: -------------------------------------------------------------------------------- 1 | ^/\*$ 2 | ^ \* Copyright \d\d\d\d(-\d\d)?, OpenCensus Authors$ 3 | ^ \*$ 4 | ^ \* Licensed under the Apache License, Version 2.0 \(the "License"\);$ 5 | ^ \* you may not use this file except in compliance with the License\.$ 6 | ^ \* You may obtain a copy of the License at$ 7 | ^ \*$ 8 | ^ \* http://www.apache.org/licenses/LICENSE-2\.0$ 9 | ^ \*$ 10 | ^ \* Unless required by applicable law or agreed to in writing, software$ 11 | ^ \* distributed under the License is distributed on an "AS IS" BASIS,$ 12 | ^ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.$ 13 | ^ \* See the License for the specific language governing permissions and$ 14 | ^ \* limitations under the License\.$ 15 | ^ \*/$ -------------------------------------------------------------------------------- /buildscripts/codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "impl_core/src/main/java/io/opencensus/implcore/internal/VarInt.java" # ignore VarInt 3 | -------------------------------------------------------------------------------- /buildscripts/kokoro/linux.cfg: -------------------------------------------------------------------------------- 1 | # Config file for internal CI 2 | 3 | # Location of the continuous shell script in repository. 4 | build_file: "opencensus-java/buildscripts/kokoro/linux.sh" 5 | timeout_mins: 60 -------------------------------------------------------------------------------- /buildscripts/kokoro/linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This file is used for Linux builds. 4 | # To run locally: 5 | # ./buildscripts/kokoro/linux.sh 6 | 7 | # This script assumes `set -e`. Removing it may lead to undefined behavior. 8 | set -exu -o pipefail 9 | 10 | # It would be nicer to use 'readlink -f' here but osx does not support it. 11 | readonly OPENCENSUS_JAVA_DIR="$(cd "$(dirname "$0")"/../.. && pwd)" 12 | 13 | # cd to the root dir of opencensus-java 14 | cd $(dirname $0)/../.. 15 | 16 | # Run tests 17 | ./gradlew clean build 18 | 19 | OS=`uname` 20 | # Check the example only on Linux. 21 | if [ "$OS" = "Linux" ] ; then 22 | pushd examples; ./gradlew clean assemble check --stacktrace; popd 23 | fi 24 | -------------------------------------------------------------------------------- /buildscripts/kokoro/linux_build.cfg: -------------------------------------------------------------------------------- 1 | # Config file for child task BUILD 2 | 3 | env_vars { 4 | key: "TASK" 5 | value: "BUILD" 6 | } 7 | 8 | # Location of the continuous shell script in repository. 9 | build_file: "opencensus-java/buildscripts/kokoro/linux_presubmit.sh" 10 | timeout_mins: 60 11 | 12 | before_action { 13 | fetch_keystore { 14 | keystore_resource { 15 | keystore_config_id: 73495 16 | keyname: "codecov-auth-token" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /buildscripts/kokoro/linux_example_gradle.cfg: -------------------------------------------------------------------------------- 1 | # Config file for child task BUILD_EXAMPLES_GRADLE 2 | 3 | env_vars { 4 | key: "TASK" 5 | value: "BUILD_EXAMPLES_GRADLE" 6 | } 7 | 8 | # Location of the continuous shell script in repository. 9 | build_file: "opencensus-java/buildscripts/kokoro/linux_presubmit.sh" 10 | timeout_mins: 60 11 | -------------------------------------------------------------------------------- /buildscripts/kokoro/linux_example_maven.cfg: -------------------------------------------------------------------------------- 1 | # Config file for child task BUILD_EXAMPLES_MAVEN 2 | 3 | env_vars { 4 | key: "TASK" 5 | value: "BUILD_EXAMPLES_MAVEN" 6 | } 7 | 8 | # Location of the continuous shell script in repository. 9 | build_file: "opencensus-java/buildscripts/kokoro/linux_presubmit.sh" 10 | timeout_mins: 60 11 | -------------------------------------------------------------------------------- /buildscripts/kokoro/linux_framework.cfg: -------------------------------------------------------------------------------- 1 | # Config file for child task CHECKER_FRAMEWORK 2 | 3 | env_vars { 4 | key: "TASK" 5 | value: "CHECKER_FRAMEWORK" 6 | } 7 | 8 | # Location of the continuous shell script in repository. 9 | build_file: "opencensus-java/buildscripts/kokoro/linux_presubmit.sh" 10 | timeout_mins: 60 11 | -------------------------------------------------------------------------------- /buildscripts/kokoro/linux_git_history.cfg: -------------------------------------------------------------------------------- 1 | # Config file for child task CHECK_GIT_HISTORY 2 | 3 | env_vars { 4 | key: "TASK" 5 | value: "CHECK_GIT_HISTORY" 6 | } 7 | 8 | # Location of the continuous shell script in repository. 9 | build_file: "opencensus-java/buildscripts/kokoro/linux_presubmit.sh" 10 | timeout_mins: 60 11 | -------------------------------------------------------------------------------- /buildscripts/kokoro/macos.cfg: -------------------------------------------------------------------------------- 1 | # Config file for internal CI 2 | 3 | # Same script is used for macos as it is for Linux. 4 | # Location of the continuous shell script in repository. 5 | build_file: "opencensus-java/buildscripts/kokoro/linux.sh" 6 | timeout_mins: 60 7 | -------------------------------------------------------------------------------- /buildscripts/kokoro/windows.bat: -------------------------------------------------------------------------------- 1 | @rem ########################################################################## 2 | @rem 3 | @rem Script to set up Kokoro worker and run Windows tests 4 | @rem 5 | @rem ########################################################################## 6 | @rem 7 | @rem To run locally execute 'buildscript\kokoro\windows.bat'. 8 | type c:\VERSION 9 | 10 | @rem Enter repo root 11 | cd /d %~dp0\..\.. 12 | 13 | @rem Clear JAVA_HOME to prevent a different Java version from being used 14 | set JAVA_HOME= 15 | set PATH=C:\Program Files\java\jdk1.8.0_152\bin;%PATH% 16 | 17 | cmd.exe /C "%cd%\gradlew.bat" clean build || exit /b 1 18 | pushd examples 19 | cmd.exe /C "%cd%\gradlew.bat" clean assemble check --stacktrace || exit /b 1 20 | popd 21 | 22 | -------------------------------------------------------------------------------- /buildscripts/kokoro/windows.cfg: -------------------------------------------------------------------------------- 1 | # Config file for internal CI 2 | 3 | # Location of the continuous windows batch script in repository. 4 | build_file: "opencensus-java/buildscripts/kokoro/windows.bat" 5 | timeout_mins: 60 6 | -------------------------------------------------------------------------------- /checker-framework/stubs/google-cloud-java.astub: -------------------------------------------------------------------------------- 1 | import org.checkerframework.checker.nullness.qual.Nullable; 2 | 3 | package com.google.cloud; 4 | 5 | class ServiceOptions, OptionsT extends ServiceOptions> { 6 | @Nullable 7 | static String getDefaultProjectId(); 8 | } 9 | -------------------------------------------------------------------------------- /checker-framework/stubs/grpc.astub: -------------------------------------------------------------------------------- 1 | package io.grpc; 2 | 3 | import org.checkerframework.checker.nullness.qual.Nullable; 4 | 5 | class Context { 6 | static Key<@Nullable T> key(String name); 7 | static Key keyWithDefault(String name, T defaultValue); 8 | class Key { 9 | T get(Context context); 10 | T get(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /checker-framework/stubs/guava.astub: -------------------------------------------------------------------------------- 1 | import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; 2 | import org.checkerframework.checker.nullness.qual.NonNull; 3 | import org.checkerframework.checker.nullness.qual.Nullable; 4 | 5 | package com.google.common.base; 6 | 7 | class Strings { 8 | @EnsuresNonNullIf(result = false, expression = "#1") 9 | static boolean isNullOrEmpty(@Nullable String str); 10 | } 11 | 12 | class Preconditions { 13 | static T checkNotNull(T reference, @Nullable Object errorMessage); 14 | } 15 | -------------------------------------------------------------------------------- /checker-framework/stubs/log4j.astub: -------------------------------------------------------------------------------- 1 | import org.checkerframework.checker.nullness.qual.Nullable; 2 | 3 | package org.apache.logging.log4j; 4 | 5 | class ThreadContext { 6 | @Nullable 7 | static ReadOnlyThreadContextMap getThreadContextMap(); 8 | } 9 | -------------------------------------------------------------------------------- /checker-framework/stubs/org-springframework-cloud-sleuth.astub: -------------------------------------------------------------------------------- 1 | package org.springframework.cloud.sleuth; 2 | 3 | import org.checkerframework.checker.nullness.qual.Nullable; 4 | import org.springframework.cloud.sleuth.Sampler; 5 | import org.springframework.cloud.sleuth.Span; 6 | 7 | interface Tracer { 8 | @Nullable Span close(@Nullable Span span); 9 | @Nullable Span continueSpan(@Nullable Span span); 10 | @Nullable Span createSpan(String name); 11 | @Nullable Span createSpan(String name, @Nullable Sampler sampler); 12 | @Nullable Span createSpan(String name, @Nullable Span parent); 13 | @Nullable Span detach(@Nullable Span span); 14 | @Nullable Span getCurrentSpan(); 15 | } 16 | 17 | class Span { 18 | Span (Span span, @Nullable Span parent); 19 | } 20 | -------------------------------------------------------------------------------- /checker-framework/stubs/org-springframework-cloud-sleuth.log.astub: -------------------------------------------------------------------------------- 1 | package org.springframework.cloud.sleuth.log; 2 | 3 | import org.checkerframework.checker.nullness.qual.Nullable; 4 | import org.springframework.cloud.sleuth.Span; 5 | 6 | interface SpanLogger { 7 | void logStartedSpan(@Nullable Span parent, Span span); 8 | void logStoppedSpan(@Nullable Span parent, Span span); 9 | } 10 | -------------------------------------------------------------------------------- /contrib/agent/src/integration-test/resources/io/opencensus/contrib/agent/instrumentation/some_resource.txt: -------------------------------------------------------------------------------- 1 | Some resource. -------------------------------------------------------------------------------- /contrib/agent/src/main/java/io/opencensus/contrib/agent/bootstrap/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.agent.bootstrap; 18 | 19 | /** 20 | * Contains classes that need to be loaded by the bootstrap classloader because they are used from 21 | * classes loaded by the bootstrap classloader. 22 | * 23 | *

NB: Do not add direct dependencies on classes that are not loaded by the bootstrap 24 | * classloader. Keep this package small. 25 | */ 26 | -------------------------------------------------------------------------------- /contrib/agent/src/main/java/io/opencensus/contrib/agent/deps/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.agent.deps; 18 | 19 | /** 20 | * Contains third party packages, such as Byte Buddy, Guava, etc., relocated here by the build 21 | * process to avoid any conflicts of the agent's classes with the app's classes, which are loaded by 22 | * the same classloader (the system classloader). 23 | */ 24 | -------------------------------------------------------------------------------- /contrib/agent/src/main/java/io/opencensus/contrib/agent/instrumentation/ContextTrampolineInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.agent.instrumentation; 18 | 19 | import com.google.auto.service.AutoService; 20 | import io.opencensus.contrib.agent.Settings; 21 | import io.opencensus.contrib.agent.bootstrap.ContextStrategy; 22 | import io.opencensus.contrib.agent.bootstrap.ContextTrampoline; 23 | import net.bytebuddy.agent.builder.AgentBuilder; 24 | 25 | /** 26 | * Initializes the {@link ContextTrampoline} with a concrete {@link ContextStrategy}. 27 | * 28 | * @since 0.9 29 | */ 30 | @AutoService(Instrumenter.class) 31 | public final class ContextTrampolineInitializer implements Instrumenter { 32 | 33 | @Override 34 | public AgentBuilder instrument(AgentBuilder agentBuilder, Settings settings) { 35 | // TODO(stschmidt): Gracefully handle the case of missing io.grpc.Context at runtime, 36 | // maybe load the missing classes from a JAR that comes with the agent JAR. 37 | ContextTrampoline.setContextStrategy(new ContextStrategyImpl()); 38 | 39 | return agentBuilder; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /contrib/agent/src/main/java/io/opencensus/contrib/agent/instrumentation/Instrumenter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.agent.instrumentation; 18 | 19 | import io.opencensus.contrib.agent.Settings; 20 | import net.bytebuddy.agent.builder.AgentBuilder; 21 | 22 | /** 23 | * Interface for plug-ins that add bytecode instrumentation. 24 | * 25 | * @since 0.6 26 | */ 27 | public interface Instrumenter { 28 | 29 | /** 30 | * Adds bytecode instrumentation to the given {@link AgentBuilder}. 31 | * 32 | * @param agentBuilder an {@link AgentBuilder} object to which the additional instrumentation is 33 | * added 34 | * @param settings the configuration settings 35 | * @return an {@link AgentBuilder} object having the additional instrumentation 36 | * @since 0.10 37 | */ 38 | AgentBuilder instrument(AgentBuilder agentBuilder, Settings settings); 39 | } 40 | -------------------------------------------------------------------------------- /contrib/agent/src/main/java/io/opencensus/contrib/agent/instrumentation/TraceTrampolineInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.agent.instrumentation; 18 | 19 | import com.google.auto.service.AutoService; 20 | import io.opencensus.contrib.agent.Settings; 21 | import io.opencensus.contrib.agent.bootstrap.TraceStrategy; 22 | import io.opencensus.contrib.agent.bootstrap.TraceTrampoline; 23 | import net.bytebuddy.agent.builder.AgentBuilder; 24 | 25 | /** 26 | * Initializes the {@link TraceTrampoline} with a concrete {@link TraceStrategy}. 27 | * 28 | * @since 0.9 29 | */ 30 | @AutoService(Instrumenter.class) 31 | public final class TraceTrampolineInitializer implements Instrumenter { 32 | 33 | @Override 34 | public AgentBuilder instrument(AgentBuilder agentBuilder, Settings settings) { 35 | // TODO(stschmidt): Gracefully handle the case of missing trace API at runtime, 36 | // maybe load the missing classes from a JAR that comes with the agent JAR. 37 | TraceTrampoline.setTraceStrategy(new TraceStrategyImpl()); 38 | 39 | return agentBuilder; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /contrib/agent/src/main/resources/reference.conf: -------------------------------------------------------------------------------- 1 | # Reference configuration for the OpenCensus Agent for Java. 2 | 3 | opencensus.contrib.agent { 4 | 5 | # Configuration settings related to automatic context propagation. 6 | context-propagation { 7 | 8 | # Enable/disable automatic context propagation for Executors. 9 | executor.enabled = true 10 | 11 | # Enable/disable automatic context propagation for Threads. 12 | thread.enabled = true 13 | } 14 | 15 | # The "trace" section configures which Java methods the agent instruments for 16 | # tracing. 17 | trace { 18 | 19 | java.net.URL.getContent { 20 | enabled = true 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /contrib/agent/src/test/resources/io/opencensus/contrib/agent/some_resource.txt: -------------------------------------------------------------------------------- 1 | A resource! -------------------------------------------------------------------------------- /contrib/appengine_standard_util/README.md: -------------------------------------------------------------------------------- 1 | # OpenCensus AppEngine Standard Util 2 | [![Build Status][travis-image]][travis-url] 3 | [![Windows Build Status][appveyor-image]][appveyor-url] 4 | [![Maven Central][maven-image]][maven-url] 5 | 6 | The *OpenCensus AppEngine Standard Util for Java* is a collection of utilities for trace 7 | instrumentation when working with [AppEngine][appengine-url]. 8 | 9 | ## Quickstart 10 | 11 | ### Add the dependencies to your project 12 | 13 | For Maven add to your `pom.xml`: 14 | ```xml 15 | 16 | 17 | io.opencensus 18 | opencensus-appengine-standard-util 19 | 0.28.3 20 | 21 | 22 | ``` 23 | 24 | For Gradle add to your dependencies: 25 | ```groovy 26 | compile 'io.opencensus:opencensus-contrib-appengine-standard-util:0.28.3' 27 | ``` 28 | 29 | [travis-image]: https://travis-ci.org/census-instrumentation/opencensus-java.svg?branch=master 30 | [travis-url]: https://travis-ci.org/census-instrumentation/opencensus-java 31 | [appveyor-image]: https://ci.appveyor.com/api/projects/status/hxthmpkxar4jq4be/branch/master?svg=true 32 | [appveyor-url]: https://ci.appveyor.com/project/opencensusjavateam/opencensus-java/branch/master 33 | [maven-image]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-appengine-standard-util/badge.svg 34 | [maven-url]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-appengine-standard-util 35 | [appengine-url]: https://appengine.google.com/ 36 | -------------------------------------------------------------------------------- /contrib/appengine_standard_util/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus AppEngine Standard Util' 2 | 3 | apply plugin: 'java' 4 | apply plugin: 'com.google.protobuf' 5 | 6 | def protocVersion = '3.11.4' 7 | 8 | buildscript { 9 | repositories { 10 | maven { url "https://plugins.gradle.org/m2/" } 11 | } 12 | dependencies { 13 | classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.8" 14 | } 15 | } 16 | 17 | [compileJava, compileTestJava].each() { 18 | it.sourceCompatibility = 1.7 19 | it.targetCompatibility = 1.7 20 | } 21 | 22 | dependencies { 23 | compile project(':opencensus-api'), 24 | libraries.appengine_api, 25 | libraries.guava, 26 | libraries.protobuf 27 | 28 | signature "org.codehaus.mojo.signature:java18:+@signature" 29 | } 30 | 31 | protobuf { 32 | protoc { 33 | // The artifact spec for the Protobuf Compiler 34 | artifact = "com.google.protobuf:protoc:${protocVersion}" 35 | } 36 | 37 | generatedFilesBaseDir = "$projectDir/gen_gradle/src" 38 | 39 | generateProtoTasks { 40 | all().each { task -> 41 | task.builtins { 42 | java { 43 | option 'annotate_code' 44 | } 45 | } 46 | } 47 | } 48 | } 49 | 50 | clean { 51 | delete protobuf.generatedFilesBaseDir 52 | } 53 | -------------------------------------------------------------------------------- /contrib/appengine_standard_util/src/main/proto/trace_id.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option java_multiple_files = true; 4 | option java_package = "io.opencensus.contrib.appengine.standard.util"; 5 | option java_outer_classname = "TraceProto"; 6 | 7 | message TraceIdProto { 8 | fixed64 hi = 1; 9 | fixed64 lo = 2; 10 | } 11 | -------------------------------------------------------------------------------- /contrib/dropwizard/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus dropwizard util' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.7 7 | it.targetCompatibility = 1.7 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | project(':opencensus-impl-core') 13 | 14 | compile libraries.dropwizard 15 | 16 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 17 | } 18 | -------------------------------------------------------------------------------- /contrib/dropwizard/src/test/java/io/opencensus/contrib/dropwizard/DropWizardUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.dropwizard; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import com.codahale.metrics.Counter; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** Tests for {@link DropWizardUtils}. */ 27 | @RunWith(JUnit4.class) 28 | public class DropWizardUtilsTest { 29 | 30 | @Test 31 | public void generateFullMetricName() { 32 | assertThat(DropWizardUtils.generateFullMetricName("requests", "gauge")) 33 | .isEqualTo("codahale_requests_gauge"); 34 | } 35 | 36 | @Test 37 | public void generateFullMetricDescription() { 38 | assertThat(DropWizardUtils.generateFullMetricDescription("Counter", new Counter())) 39 | .isEqualTo("Collected from codahale (metric=Counter, type=com.codahale.metrics.Counter)"); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /contrib/dropwizard5/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus dropwizard5 util' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.8 7 | it.targetCompatibility = 1.8 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | project(':opencensus-impl-core') 13 | 14 | compile libraries.dropwizard5 15 | 16 | signature "org.codehaus.mojo.signature:java18:+@signature" 17 | } 18 | -------------------------------------------------------------------------------- /contrib/dropwizard5/src/test/java/io/opencensus/contrib/dropwizard5/DropWizardUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.dropwizard5; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.dropwizard.metrics5.Counter; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** Tests for {@link DropWizardUtils}. */ 27 | @RunWith(JUnit4.class) 28 | public class DropWizardUtilsTest { 29 | 30 | @Test 31 | public void generateFullMetricName() { 32 | assertThat(DropWizardUtils.generateFullMetricName("requests", "gauge")) 33 | .isEqualTo("dropwizard5_requests_gauge"); 34 | } 35 | 36 | @Test 37 | public void generateFullMetricDescription() { 38 | assertThat(DropWizardUtils.generateFullMetricDescription("Counter", new Counter())) 39 | .isEqualTo( 40 | "Collected from dropwizard5 (metric=Counter, type=io.dropwizard.metrics5.Counter)"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /contrib/exemplar_util/README.md: -------------------------------------------------------------------------------- 1 | # OpenCensus Exemplar Util 2 | 3 | [![Build Status][travis-image]][travis-url] 4 | [![Windows Build Status][appveyor-image]][appveyor-url] 5 | [![Maven Central][maven-image]][maven-url] 6 | 7 | The *OpenCensus Exemplar Util for Java* is a collection of utilities for recording Exemplars for 8 | OpenCensus stats. 9 | 10 | ## Quickstart 11 | 12 | ### Add the dependencies to your project 13 | 14 | For Maven add to your `pom.xml`: 15 | ```xml 16 | 17 | 18 | io.opencensus 19 | opencensus-contrib-exemplar-util 20 | 0.28.3 21 | 22 | 23 | ``` 24 | 25 | For Gradle add to your dependencies: 26 | ```groovy 27 | compile 'io.opencensus:opencensus-contrib-exemplar-util:0.28.3' 28 | ``` 29 | 30 | [travis-image]: https://travis-ci.org/census-instrumentation/opencensus-java.svg?branch=master 31 | [travis-url]: https://travis-ci.org/census-instrumentation/opencensus-java 32 | [appveyor-image]: https://ci.appveyor.com/api/projects/status/hxthmpkxar4jq4be/branch/master?svg=true 33 | [appveyor-url]: https://ci.appveyor.com/project/opencensusjavateam/opencensus-java/branch/master 34 | [maven-image]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-exemplar-util/badge.svg 35 | [maven-url]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-exemplar-util 36 | 37 | -------------------------------------------------------------------------------- /contrib/exemplar_util/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Exemplar Util' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.6 7 | it.targetCompatibility = 1.6 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api') 12 | 13 | compileOnly libraries.auto_value 14 | 15 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 16 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 17 | } 18 | -------------------------------------------------------------------------------- /contrib/grpc_metrics/README.md: -------------------------------------------------------------------------------- 1 | # OpenCensus gRPC Metrics 2 | 3 | RPC measure and view constants used by gRPC. 4 | 5 | This library may be moved into gRPC in the future. 6 | -------------------------------------------------------------------------------- /contrib/grpc_metrics/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus gRPC Metrics' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.6 7 | it.targetCompatibility = 1.6 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | libraries.guava 13 | 14 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 15 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 16 | } 17 | -------------------------------------------------------------------------------- /contrib/grpc_util/README.md: -------------------------------------------------------------------------------- 1 | # OpenCensus gRPC Util 2 | [![Build Status][travis-image]][travis-url] 3 | [![Windows Build Status][appveyor-image]][appveyor-url] 4 | [![Maven Central][maven-image]][maven-url] 5 | 6 | The *OpenCensus gRPC Util for Java* is a collection of utilities for trace instrumentation when 7 | working with [gRPC][grpc-url]. 8 | 9 | ## Quickstart 10 | 11 | ### Add the dependencies to your project 12 | 13 | For Maven add to your `pom.xml`: 14 | ```xml 15 | 16 | 17 | io.opencensus 18 | opencensus-contrib-grpc-util 19 | 0.28.3 20 | 21 | 22 | ``` 23 | 24 | For Gradle add to your dependencies: 25 | ```groovy 26 | compile 'io.opencensus:opencensus-contrib-grpc-util:0.28.3' 27 | ``` 28 | 29 | [travis-image]: https://travis-ci.org/census-instrumentation/opencensus-java.svg?branch=master 30 | [travis-url]: https://travis-ci.org/census-instrumentation/opencensus-java 31 | [appveyor-image]: https://ci.appveyor.com/api/projects/status/hxthmpkxar4jq4be/branch/master?svg=true 32 | [appveyor-url]: https://ci.appveyor.com/project/opencensusjavateam/opencensus-java/branch/master 33 | [maven-image]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-grpc-util/badge.svg 34 | [maven-url]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-grpc-util 35 | [grpc-url]: https://github.com/grpc/grpc-java 36 | -------------------------------------------------------------------------------- /contrib/grpc_util/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus gRPC Util' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.6 7 | it.targetCompatibility = 1.6 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api') 12 | 13 | compile (libraries.grpc_core) { 14 | // Prefer library version. 15 | exclude group: 'com.google.errorprone', module: 'error_prone_annotations' 16 | 17 | // Prefer library version. 18 | exclude group: 'com.google.code.findbugs', module: 'jsr305' 19 | 20 | // We will always be more up to date. 21 | exclude group: 'io.opencensus', module: 'opencensus-api' 22 | } 23 | 24 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 25 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 26 | } 27 | -------------------------------------------------------------------------------- /contrib/http_jaxrs/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | description = 'OpenCensus Http Servlet Plugin' 6 | 7 | [compileJava, compileTestJava].each() { 8 | it.sourceCompatibility = 1.8 9 | it.targetCompatibility = 1.8 10 | } 11 | 12 | dependencies { 13 | compile project(':opencensus-api') 14 | compile project(':opencensus-contrib-http-util') 15 | 16 | // Will be provided from elsewhere at runtime 17 | compileOnly('javax.ws.rs:javax.ws.rs-api:2.1.1') 18 | compileOnly('javax.annotation:javax.annotation-api:1.3.2') 19 | 20 | testCompile('javax.ws.rs:javax.ws.rs-api:2.1.1') 21 | testCompile('javax.annotation:javax.annotation-api:1.3.2') 22 | 23 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 24 | } 25 | -------------------------------------------------------------------------------- /contrib/http_jaxrs/src/main/java/io/opencensus/contrib/http/jaxrs/ExtendedContainerRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.http.jaxrs; 18 | 19 | import javax.ws.rs.container.ContainerRequestContext; 20 | import javax.ws.rs.container.ResourceInfo; 21 | 22 | /** Contains both {@link ContainerRequestContext} and {@link ResourceInfo}. */ 23 | class ExtendedContainerRequest { 24 | private final ContainerRequestContext requestContext; 25 | private final ResourceInfo resourceInfo; 26 | 27 | public ExtendedContainerRequest( 28 | ContainerRequestContext requestContext, ResourceInfo resourceInfo) { 29 | this.requestContext = requestContext; 30 | this.resourceInfo = resourceInfo; 31 | } 32 | 33 | public ContainerRequestContext getRequestContext() { 34 | return requestContext; 35 | } 36 | 37 | public ResourceInfo getResourceInfo() { 38 | return resourceInfo; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /contrib/http_jaxrs/src/main/java/io/opencensus/contrib/http/jaxrs/Metrics.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.http.jaxrs; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | import javax.ws.rs.NameBinding; 24 | 25 | /** 26 | * Annotation to mark JAX-RS endpoint or method for metrics collection. 27 | * 28 | * @since 0.19 29 | */ 30 | @NameBinding 31 | @Target({ElementType.TYPE, ElementType.METHOD}) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface Metrics {} 34 | -------------------------------------------------------------------------------- /contrib/http_jetty_client/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | description = 'OpenCensus Http Jetty Client Plugin' 6 | 7 | [compileJava, compileTestJava].each() { 8 | it.sourceCompatibility = 1.6 9 | it.targetCompatibility = 1.6 10 | } 11 | 12 | // TODO[rghetia]: jetty 9.3+ requires jdk 8. Http2.0 is supported in jetty 9.3 13 | // May require creating separate artifact for jetty 9.3 and above. 14 | //def jettyVersion = "9.4.12.v20180830" 15 | def jettyVersion = "9.2.25.v20180606" 16 | 17 | dependencies { 18 | compile project(':opencensus-api') 19 | compile project(':opencensus-contrib-http-util') 20 | 21 | compile "org.eclipse.jetty:jetty-client:${jettyVersion}" 22 | 23 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 24 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 25 | } 26 | -------------------------------------------------------------------------------- /contrib/http_servlet/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | description = 'OpenCensus Http Servlet Plugin' 6 | 7 | [compileJava, compileTestJava].each() { 8 | it.sourceCompatibility = 1.6 9 | it.targetCompatibility = 1.6 10 | } 11 | 12 | dependencies { 13 | compile libraries.grpc_context 14 | compile project(':opencensus-api') 15 | compile project(':opencensus-contrib-http-util') 16 | 17 | compile "javax.servlet:javax.servlet-api:3.1.0" 18 | 19 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 20 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 21 | } 22 | -------------------------------------------------------------------------------- /contrib/http_util/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus HTTP Util' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.6 7 | it.targetCompatibility = 1.6 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | libraries.guava 13 | 14 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 15 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 16 | } 17 | -------------------------------------------------------------------------------- /contrib/http_util/src/main/java/io/opencensus/contrib/http/util/HttpPropagationUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.http.util; 18 | 19 | import io.opencensus.trace.propagation.TextFormat; 20 | 21 | /** 22 | * Utility class to get all supported {@link TextFormat}. 23 | * 24 | * @since 0.11.0 25 | */ 26 | public class HttpPropagationUtil { 27 | 28 | private HttpPropagationUtil() {} 29 | 30 | /** 31 | * Returns the Stack Driver format implementation. The header specification for this format is 32 | * "X-Cloud-Trace-Context: <TRACE_ID>/<SPAN_ID>[;o=<TRACE_TRUE>]". See this page for more information. 34 | * 35 | * @since 0.11.0 36 | * @return the Stack Driver format. 37 | */ 38 | public static TextFormat getCloudTraceFormat() { 39 | return new CloudTraceFormat(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /contrib/http_util/src/main/java/io/opencensus/contrib/http/util/HttpTraceAttributeConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.http.util; 18 | 19 | /** Constant Trace attribute keys for HTTP Request and Response @Since 0.18 */ 20 | public final class HttpTraceAttributeConstants { 21 | public static final String HTTP_HOST = "http.host"; 22 | public static final String HTTP_ROUTE = "http.route"; 23 | public static final String HTTP_PATH = "http.path"; 24 | public static final String HTTP_METHOD = "http.method"; 25 | public static final String HTTP_USER_AGENT = "http.user_agent"; 26 | public static final String HTTP_URL = "http.url"; 27 | public static final String HTTP_STATUS_CODE = "http.status_code"; 28 | 29 | private HttpTraceAttributeConstants() {} 30 | } 31 | -------------------------------------------------------------------------------- /contrib/http_util/src/test/java/io/opencensus/contrib/http/util/HttpPropagationUtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.http.util; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.opencensus.trace.propagation.TextFormat; 22 | import org.junit.Test; 23 | import org.junit.runner.RunWith; 24 | import org.junit.runners.JUnit4; 25 | 26 | /** Unit tests for {@link HttpPropagationUtil}. */ 27 | @RunWith(JUnit4.class) 28 | public class HttpPropagationUtilTest { 29 | 30 | @Test 31 | public void cloudTraceFormatNotNull() { 32 | TextFormat cloudTraceFormat = HttpPropagationUtil.getCloudTraceFormat(); 33 | assertThat(cloudTraceFormat).isNotNull(); 34 | assertThat(cloudTraceFormat).isInstanceOf(CloudTraceFormat.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /contrib/log_correlation/log4j2/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Log4j 2 Log Correlation' 2 | 3 | apply plugin: 'java' 4 | 5 | dependencies { 6 | compile project(':opencensus-api') 7 | compileOnly libraries.log4j2 8 | 9 | testCompile libraries.guava, 10 | libraries.log4j2 11 | 12 | signature "org.codehaus.mojo.signature:java16:+@signature" 13 | } 14 | 15 | compileTestJava { 16 | sourceCompatibility = "1.7" 17 | targetCompatibility = "1.7" 18 | } 19 | 20 | test { 21 | systemProperties['log4j2.contextDataInjector'] = 22 | 'io.opencensus.contrib.logcorrelation.log4j2.OpenCensusTraceContextDataInjector' 23 | } 24 | -------------------------------------------------------------------------------- /contrib/log_correlation/log4j2/src/test/java/io/opencensus/contrib/logcorrelation/log4j2/TestSpan.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.logcorrelation.log4j2; 18 | 19 | import io.opencensus.trace.Annotation; 20 | import io.opencensus.trace.AttributeValue; 21 | import io.opencensus.trace.EndSpanOptions; 22 | import io.opencensus.trace.Link; 23 | import io.opencensus.trace.Span; 24 | import io.opencensus.trace.SpanContext; 25 | import java.util.EnumSet; 26 | import java.util.Map; 27 | 28 | // Simple test Span that holds a SpanContext. The tests cannot use Span directly, since it is 29 | // abstract. 30 | final class TestSpan extends Span { 31 | TestSpan(SpanContext context) { 32 | super(context, EnumSet.of(Options.RECORD_EVENTS)); 33 | } 34 | 35 | @Override 36 | public void end(EndSpanOptions options) {} 37 | 38 | @Override 39 | public void addLink(Link link) {} 40 | 41 | @Override 42 | public void addAnnotation(Annotation annotation) {} 43 | 44 | @Override 45 | public void addAnnotation(String description, Map attributes) {} 46 | } 47 | -------------------------------------------------------------------------------- /contrib/log_correlation/stackdriver/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Stackdriver Log Correlation' 2 | 3 | apply plugin: 'java' 4 | 5 | dependencies { 6 | compile project(':opencensus-api'), 7 | libraries.grpc_auth, 8 | libraries.grpc_core, 9 | libraries.grpc_netty_shaded, 10 | libraries.grpc_stub 11 | 12 | compile (libraries.google_cloud_logging) { 13 | // Prefer library version. 14 | exclude group: 'io.grpc', module: 'grpc-auth' 15 | exclude group: 'io.grpc', module: 'grpc-core' 16 | exclude group: 'io.grpc', module: 'grpc-netty-shaded' 17 | exclude group: 'io.grpc', module: 'grpc-stub' 18 | 19 | // We will always be more up to date. 20 | exclude group: 'io.opencensus', module: 'opencensus-api' 21 | } 22 | 23 | testCompile libraries.guava 24 | 25 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 26 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 27 | } 28 | -------------------------------------------------------------------------------- /contrib/observability_ready_util/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Observability Ready Util' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.8 7 | it.targetCompatibility = 1.8 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | project(':opencensus-impl-core'), 13 | project(':opencensus-contrib-grpc-metrics'), 14 | project(':opencensus-exporter-metrics-ocagent'), 15 | project(':opencensus-exporter-trace-ocagent') 16 | 17 | signature "org.codehaus.mojo.signature:java18:+@signature" 18 | } 19 | -------------------------------------------------------------------------------- /contrib/resource_util/README.md: -------------------------------------------------------------------------------- 1 | # OpenCensus Resources Util 2 | [![Build Status][travis-image]][travis-url] 3 | [![Windows Build Status][appveyor-image]][appveyor-url] 4 | [![Maven Central][maven-image]][maven-url] 5 | 6 | The *OpenCensus Resource Util for Java* is a collection of utilities that defines a set of 7 | common resources (aws_ec2_instance, gcp_gce_instance, k8s_container, etc.) and offers auto detection 8 | for some of the resources, based on the environment where the application is running. 9 | 10 | ## Quickstart 11 | 12 | ### Add the dependencies to your project 13 | 14 | For Maven add to your `pom.xml`: 15 | ```xml 16 | 17 | 18 | io.opencensus 19 | opencensus-contrib-resource-util 20 | 0.20.0 21 | 22 | 23 | ``` 24 | 25 | For Gradle add to your dependencies: 26 | ```groovy 27 | compile 'io.opencensus:opencensus-contrib-resource-util:0.20.0' 28 | ``` 29 | 30 | [travis-image]: https://travis-ci.org/census-instrumentation/opencensus-java.svg?branch=master 31 | [travis-url]: https://travis-ci.org/census-instrumentation/opencensus-java 32 | [appveyor-image]: https://ci.appveyor.com/api/projects/status/hxthmpkxar4jq4be/branch/master?svg=true 33 | [appveyor-url]: https://ci.appveyor.com/project/opencensusjavateam/opencensus-java/branch/master 34 | [maven-image]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-resource-util/badge.svg 35 | [maven-url]: https://maven-badges.herokuapp.com/maven-central/io.opencensus/opencensus-contrib-resource-util 36 | -------------------------------------------------------------------------------- /contrib/resource_util/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Resource Util' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.6 7 | it.targetCompatibility = 1.6 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | libraries.guava, 13 | libraries.jsr305 14 | 15 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 16 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 17 | } 18 | -------------------------------------------------------------------------------- /contrib/spring/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Spring' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.8 7 | it.targetCompatibility = 1.8 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | project(':opencensus-contrib-http-util'), 13 | project(':opencensus-contrib-http-servlet'), 14 | libraries.spring_aspects, 15 | libraries.spring_context, 16 | libraries.findbugs_annotations, 17 | libraries.spring_boot_starter_web2, 18 | libraries.httpcomponents 19 | 20 | testCompile project(':opencensus-impl'), 21 | project(':opencensus-testing'), 22 | libraries.aspectj, 23 | libraries.spring_test, 24 | libraries.sprint_boot_starter_tomcat, 25 | libraries.spring_boot_test2, 26 | libraries.javax_servlet 27 | 28 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 29 | } 30 | -------------------------------------------------------------------------------- /contrib/spring/src/main/java/io/opencensus/contrib/spring/aop/Traced.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.spring.aop; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Traced specifies the annotated method should be included in the Trace. 26 | * 27 | *

By default, the name of the method will be used for the span name. However, the span name can 28 | * be explicitly set via the name interface. 29 | * 30 | * @since 0.16.0 31 | */ 32 | @Target(ElementType.METHOD) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface Traced { 35 | 36 | /** 37 | * The optional custom span name. 38 | * 39 | * @return the optional custom span name; if not specified the method name will be used as the 40 | * span name 41 | */ 42 | String name() default ""; 43 | } 44 | -------------------------------------------------------------------------------- /contrib/spring/src/main/resources/META-INF/additional-spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | {"properties": [ 2 | { 3 | "name": "opencensus.spring.enabled", 4 | "type": "java.lang.Boolean", 5 | "description": "Enable Spring Integration Opencensus Instrumentation.", 6 | "defaultValue": true 7 | } 8 | ]} -------------------------------------------------------------------------------- /contrib/spring/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # Auto Configuration 2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 3 | io.opencensus.contrib.spring.autoconfig.OpenCensusAutoConfiguration,\ 4 | io.opencensus.contrib.spring.autoconfig.TraceWebAsyncClientAutoConfiguration 5 | -------------------------------------------------------------------------------- /contrib/spring/src/test/java/io/opencensus/contrib/spring/aop/Sample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.spring.aop; 18 | 19 | import java.sql.SQLException; 20 | 21 | public class Sample { 22 | @Traced() 23 | void example1() { 24 | // do work 25 | } 26 | 27 | @Traced(name = "custom-span-name") 28 | void example2() { 29 | // do moar work 30 | } 31 | 32 | @Traced() 33 | void call(long delay) throws Exception { 34 | Thread.sleep(delay); 35 | } 36 | 37 | @Traced(name = "blah") 38 | void custom(long delay) throws Exception { 39 | Thread.sleep(delay); 40 | } 41 | 42 | @Traced() 43 | void boom() throws Exception { 44 | throw new Exception("boom"); 45 | } 46 | 47 | public void execute(String sql) throws SQLException {} 48 | 49 | public void executeQuery(String sql) throws SQLException {} 50 | 51 | public void executeUpdate(String sql) throws SQLException {} 52 | 53 | public void executeLargeUpdate(String sql) throws SQLException {} 54 | } 55 | -------------------------------------------------------------------------------- /contrib/spring/src/test/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # Auto Configuration 2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 3 | io.opencensus.contrib.spring.autoconfig.OpenCensusAutoConfiguration,\ 4 | io.opencensus.contrib.spring.autoconfig.TraceWebAsyncClientAutoConfiguration -------------------------------------------------------------------------------- /contrib/spring/src/test/resources/beans/HttpServletFilterIntegrationTest-context.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /contrib/spring/src/test/resources/spring.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /contrib/spring_sleuth_v1x/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Spring Sleuth' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.6 7 | it.targetCompatibility = 1.6 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | libraries.spring_boot_starter_web, 13 | libraries.spring_cloud_build, 14 | libraries.spring_cloud_starter_sleuth 15 | 16 | testCompile project(':opencensus-impl'), 17 | project(':opencensus-testing'), 18 | libraries.spring_test 19 | 20 | signature "org.codehaus.mojo.signature:java16:+@signature" 21 | } 22 | -------------------------------------------------------------------------------- /contrib/spring_sleuth_v1x/src/main/java/io/opencensus/contrib/spring/sleuth/v1x/OpenCensusSleuthProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.spring.sleuth.v1x; 18 | 19 | import io.opencensus.common.ExperimentalApi; 20 | import org.springframework.boot.context.properties.ConfigurationProperties; 21 | 22 | /** 23 | * Sleuth annotation settings. 24 | * 25 | * @since 0.16 26 | */ 27 | @ExperimentalApi 28 | @ConfigurationProperties("spring.opencensus.sleuth") 29 | public class OpenCensusSleuthProperties { 30 | 31 | private boolean enabled = true; 32 | 33 | /** Returns whether OpenCensus trace propagation is enabled. */ 34 | public boolean isEnabled() { 35 | return this.enabled; 36 | } 37 | 38 | /** Enables OpenCensus trace propagation. */ 39 | public void setEnabled(boolean enabled) { 40 | this.enabled = enabled; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /contrib/spring_sleuth_v1x/src/main/resources/META-INF/additional-spring-configuration-metadata.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/contrib/spring_sleuth_v1x/src/main/resources/META-INF/additional-spring-configuration-metadata.json -------------------------------------------------------------------------------- /contrib/spring_sleuth_v1x/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # Auto Configuration 2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 3 | io.opencensus.contrib.spring.sleuth.v1x.OpenCensusSleuthAutoConfiguration\ 4 | 5 | # Environment Post Processor 6 | org.springframework.boot.env.EnvironmentPostProcessor=\ 7 | org.springframework.cloud.sleuth.autoconfig.TraceEnvironmentPostProcessor 8 | -------------------------------------------------------------------------------- /contrib/spring_starter/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | description = 'OpenCensus Spring Cloud Starter' 6 | 7 | [compileJava, compileTestJava].each() { 8 | it.sourceCompatibility = 1.6 9 | it.targetCompatibility = 1.6 10 | } 11 | 12 | dependencies { 13 | compile project(':opencensus-api'), 14 | project(':opencensus-contrib-spring'), 15 | project(':opencensus-impl') 16 | 17 | signature "org.codehaus.mojo.signature:java16:+@signature" 18 | } 19 | -------------------------------------------------------------------------------- /contrib/spring_starter/src/main/resources/META-INF/spring.provides: -------------------------------------------------------------------------------- 1 | provides: opencensus-contrib-spring -------------------------------------------------------------------------------- /contrib/zpages/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Z-Pages' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.8 7 | it.targetCompatibility = 1.8 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | project(':opencensus-contrib-grpc-metrics',), 13 | libraries.guava 14 | 15 | signature "org.codehaus.mojo.signature:java18:+@signature" 16 | } 17 | -------------------------------------------------------------------------------- /contrib/zpages/screenshots/rpcz-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/contrib/zpages/screenshots/rpcz-example.png -------------------------------------------------------------------------------- /contrib/zpages/screenshots/statsz-example-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/contrib/zpages/screenshots/statsz-example-1.png -------------------------------------------------------------------------------- /contrib/zpages/screenshots/statsz-example-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/contrib/zpages/screenshots/statsz-example-2.png -------------------------------------------------------------------------------- /contrib/zpages/screenshots/traceconfigz-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/contrib/zpages/screenshots/traceconfigz-example.png -------------------------------------------------------------------------------- /contrib/zpages/screenshots/tracez-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/contrib/zpages/screenshots/tracez-example.png -------------------------------------------------------------------------------- /contrib/zpages/src/main/java/io/opencensus/contrib/zpages/ZPageHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.zpages; 18 | 19 | import java.io.OutputStream; 20 | import java.util.Map; 21 | 22 | /** 23 | * Main interface for all the Z-Pages. All Z-Pages must implement this interface to allow other HTTP 24 | * server implementation to support these pages. 25 | * 26 | * @since 0.6 27 | */ 28 | public abstract class ZPageHandler { 29 | 30 | /** 31 | * Returns the URL path that should be used to register this page. 32 | * 33 | * @return the URL path that should be used to register this page. 34 | * @since 0.6 35 | */ 36 | public abstract String getUrlPath(); 37 | 38 | /** 39 | * Emits the HTML generated page to the {@code outputStream}. 40 | * 41 | * @param queryMap the query components map. 42 | * @param outputStream the output {@code OutputStream}. 43 | * @since 0.6 44 | */ 45 | public abstract void emitHtml(Map queryMap, OutputStream outputStream); 46 | 47 | /** Package protected constructor to disallow users to extend this class. */ 48 | ZPageHandler() {} 49 | } 50 | -------------------------------------------------------------------------------- /contrib/zpages/src/test/java/io/opencensus/contrib/zpages/ZPageHandlersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.zpages; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | /** Unit tests for {@link ZPageHandlers}. */ 26 | @RunWith(JUnit4.class) 27 | public class ZPageHandlersTest { 28 | 29 | @Test 30 | public void implementationOfTracez() { 31 | assertThat(ZPageHandlers.getTracezZPageHandler()).isInstanceOf(TracezZPageHandler.class); 32 | } 33 | 34 | @Test 35 | public void implementationOfTraceConfigz() { 36 | assertThat(ZPageHandlers.getTraceConfigzZPageHandler()) 37 | .isInstanceOf(TraceConfigzZPageHandler.class); 38 | } 39 | 40 | @Test 41 | public void implementationOfRpcz() { 42 | assertThat(ZPageHandlers.getRpczZpageHandler()).isInstanceOf(RpczZPageHandler.class); 43 | } 44 | 45 | @Test 46 | public void implementationOfStatsz() { 47 | assertThat(ZPageHandlers.getStatszZPageHandler()).isInstanceOf(StatszZPageHandler.class); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /contrib/zpages/src/test/java/io/opencensus/contrib/zpages/ZPageHttpHandlerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.contrib.zpages; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import java.net.URI; 22 | import java.net.URISyntaxException; 23 | import org.junit.Test; 24 | import org.junit.runner.RunWith; 25 | import org.junit.runners.JUnit4; 26 | 27 | /** Unit tests for {@link ZPageHttpHandler}. */ 28 | @RunWith(JUnit4.class) 29 | public class ZPageHttpHandlerTest { 30 | @Test 31 | public void parseUndefinedQuery() throws URISyntaxException { 32 | URI uri = new URI("http://localhost:8000/tracez"); 33 | assertThat(ZPageHttpHandler.uriQueryToMap(uri)).isEmpty(); 34 | } 35 | 36 | @Test 37 | public void parseQuery() throws URISyntaxException { 38 | URI uri = new URI("http://localhost:8000/tracez?ztype=1&zsubtype&zname=Test"); 39 | assertThat(ZPageHttpHandler.uriQueryToMap(uri)) 40 | .containsExactly("ztype", "1", "zsubtype", "", "zname", "Test"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/examples/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /examples/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'opencensus-examples' 2 | -------------------------------------------------------------------------------- /examples/spring/servlet/.gitignore: -------------------------------------------------------------------------------- 1 | .mvn/** 2 | mvn** 3 | 4 | -------------------------------------------------------------------------------- /examples/spring/servlet/application.properties: -------------------------------------------------------------------------------- 1 | opencensus.spring.enabled = true 2 | opencensus.spring.trace.publicEndpoint = false 3 | -------------------------------------------------------------------------------- /examples/spring/servlet/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/examples/spring/servlet/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /examples/spring/servlet/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /examples/spring/servlet/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'opencensus-examples-spring-servlet' 2 | -------------------------------------------------------------------------------- /examples/spring/servlet/src/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | # Auto Configuration 2 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 3 | io.opencensus.examples.spring.servlet.ApplicationAutoConfiguration 4 | -------------------------------------------------------------------------------- /examples/spring/servlet/src/resources/application.properties: -------------------------------------------------------------------------------- 1 | opencensus.spring.trace.propagation=B3 -------------------------------------------------------------------------------- /examples/src/main/java/io/opencensus/examples/quickstart/prometheus.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2018, OpenCensus Authors 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | global: 17 | scrape_interval: 10s 18 | 19 | external_labels: 20 | monitor: 'demo' 21 | 22 | scrape_configs: 23 | - job_name: 'demo' 24 | 25 | scrape_interval: 10s 26 | 27 | static_configs: 28 | - targets: ['localhost:8889'] -------------------------------------------------------------------------------- /examples/src/main/java/io/opencensus/examples/trace/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.examples.trace; 18 | 19 | import java.util.logging.Logger; 20 | 21 | /** Util methods. */ 22 | final class Utils { 23 | 24 | private static final Logger logger = Logger.getLogger(Utils.class.getName()); 25 | 26 | static void sleep(int ms) { 27 | // A helper to avoid try-catch when invoking Thread.sleep so that 28 | // sleeps can be succinct and not permeated by exception handling. 29 | try { 30 | Thread.sleep(ms); 31 | } catch (Exception e) { 32 | logger.warning((String.format("Failed to sleep for %dms. Exception: %s", ms, e))); 33 | } 34 | } 35 | 36 | private Utils() {} 37 | } 38 | -------------------------------------------------------------------------------- /examples/src/main/proto/helloworld.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | syntax = "proto3"; 18 | 19 | option java_multiple_files = true; 20 | option java_package = "io.opencensus.examples.grpc.helloworld"; 21 | option java_outer_classname = "HelloWorldProto"; 22 | 23 | package helloworld; 24 | 25 | // The greeting service definition. 26 | service Greeter { 27 | // Sends a greeting 28 | rpc SayHello (HelloRequest) returns (HelloReply) {} 29 | } 30 | 31 | // The request message containing the user's name. 32 | message HelloRequest { 33 | string name = 1; 34 | } 35 | 36 | // The response message containing the greetings 37 | message HelloReply { 38 | string message = 1; 39 | } 40 | -------------------------------------------------------------------------------- /exporters/metrics/ocagent/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Java OC-Agent Metrics Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.7 5 | it.targetCompatibility = 1.7 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-contrib-resource-util') 13 | 14 | compile (libraries.grpc_core) { 15 | // We will always be more up to date. 16 | exclude group: 'io.opencensus', module: 'opencensus-api' 17 | } 18 | 19 | compile (libraries.grpc_stub) { 20 | // We will always be more up to date. 21 | exclude group: 'io.opencensus', module: 'opencensus-api' 22 | } 23 | 24 | compile (libraries.grpc_netty) { 25 | // We will always be more up to date. 26 | exclude group: 'io.opencensus', module: 'opencensus-api' 27 | } 28 | 29 | compile (libraries.opencensus_proto) { 30 | // We will always be more up to date. 31 | exclude group: 'io.opencensus', module: 'opencensus-api' 32 | } 33 | 34 | testRuntimeOnly project(':opencensus-impl'), 35 | project(':opencensus-impl-core') 36 | 37 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 38 | } 39 | -------------------------------------------------------------------------------- /exporters/metrics/ocagent/src/main/java/io/opencensus/exporter/metrics/ocagent/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * This package contains the Java implementation of the OpenCensus Agent (OC-Agent) Metrics 19 | * Exporter. 20 | * 21 | *

WARNING: Currently all the public classes under this package are marked as {@link 22 | * io.opencensus.common.ExperimentalApi}. The classes and APIs under {@link 23 | * io.opencensus.exporter.metrics.ocagent} are likely to get backwards-incompatible updates in the 24 | * future. DO NOT USE except for experimental purposes. 25 | * 26 | *

See more details on 27 | * https://github.com/census-instrumentation/opencensus-proto/tree/master/src/opencensus/proto/agent. 28 | */ 29 | @io.opencensus.common.ExperimentalApi 30 | package io.opencensus.exporter.metrics.ocagent; 31 | -------------------------------------------------------------------------------- /exporters/metrics/util/README.md: -------------------------------------------------------------------------------- 1 | # OpenCensus Java Metrics Exporter Util 2 | 3 | The *OpenCensus Metrics Exporter Util* is the Java helper package for all metrics exporters. 4 | 5 | ## Quickstart 6 | 7 | ### Add the dependencies to your project 8 | 9 | For Maven add to your `pom.xml`: 10 | ```xml 11 | 12 | 13 | io.opencensus 14 | opencensus-api 15 | 0.19.0 16 | 17 | 18 | io.opencensus 19 | opencensus-exporter-metrics-util 20 | 0.19.0 21 | 22 | 23 | ``` 24 | 25 | For Gradle add to your dependencies: 26 | ```groovy 27 | compile 'io.opencensus:opencensus-api:0.19.0' 28 | compile 'io.opencensus:opencensus-exporter-metrics-util:0.19.0' 29 | ``` 30 | -------------------------------------------------------------------------------- /exporters/metrics/util/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Java Metrics Exporter Utils' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.7 5 | it.targetCompatibility = 1.7 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | libraries.guava 13 | 14 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 15 | } 16 | -------------------------------------------------------------------------------- /exporters/metrics/util/src/main/java/io/opencensus/exporter/metrics/util/MetricExporter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.exporter.metrics.util; 18 | 19 | import io.opencensus.metrics.export.Metric; 20 | import java.util.Collection; 21 | 22 | /** 23 | * Abstract class that represents a metric exporter. 24 | * 25 | * @since 0.19 26 | */ 27 | public abstract class MetricExporter { 28 | 29 | /** 30 | * Exports the list of given {@link Metric}. 31 | * 32 | * @param metrics the list of {@link Metric} to be exported. 33 | * @since 0.19 34 | */ 35 | public abstract void export(Collection metrics); 36 | } 37 | -------------------------------------------------------------------------------- /exporters/stats/prometheus/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Stats Prometheus Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.7 5 | it.targetCompatibility = 1.7 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-exporter-metrics-util'), 13 | libraries.guava, 14 | libraries.prometheus_simpleclient 15 | 16 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 17 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 18 | } -------------------------------------------------------------------------------- /exporters/stats/signalfx/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus SignalFx Stats Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.7 5 | it.targetCompatibility = 1.7 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-exporter-metrics-util'), 13 | libraries.guava 14 | 15 | compile (libraries.signalfx_java) { 16 | // Prefer library version. 17 | exclude group: 'com.google.guava', module: 'guava' 18 | } 19 | 20 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 21 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 22 | } 23 | -------------------------------------------------------------------------------- /exporters/stats/stackdriver/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Stats Stackdriver Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.7 5 | it.targetCompatibility = 1.7 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-contrib-exemplar-util'), 13 | project(':opencensus-contrib-resource-util'), 14 | project(':opencensus-exporter-metrics-util'), 15 | libraries.google_auth, 16 | libraries.grpc_auth, 17 | libraries.grpc_core, 18 | libraries.grpc_netty_shaded, 19 | libraries.grpc_stub, 20 | libraries.guava 21 | 22 | compile (libraries.google_cloud_monitoring) { 23 | // Prefer library version. 24 | exclude group: 'com.google.guava', module: 'guava' 25 | 26 | // Prefer library version. 27 | exclude group: 'com.google.code.findbugs', module: 'jsr305' 28 | 29 | // Prefer library version. 30 | exclude group: 'io.grpc', module: 'grpc-auth' 31 | exclude group: 'io.grpc', module: 'grpc-core' 32 | exclude group: 'io.grpc', module: 'grpc-netty-shaded' 33 | exclude group: 'io.grpc', module: 'grpc-stub' 34 | 35 | // We will always be more up to date. 36 | exclude group: 'io.opencensus', module: 'opencensus-api' 37 | } 38 | 39 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 40 | } -------------------------------------------------------------------------------- /exporters/stats/stackdriver/src/test/java/io/opencensus/exporter/stats/stackdriver/FakeMetricServiceClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.exporter.stats.stackdriver; 18 | 19 | import com.google.cloud.monitoring.v3.MetricServiceClient; 20 | import com.google.cloud.monitoring.v3.stub.MetricServiceStub; 21 | 22 | /** 23 | * MetricServiceClient.createMetricDescriptor() and MetricServiceClient.createTimeSeries() are final 24 | * methods and cannot be mocked. We have to use a mock MetricServiceStub in order to verify the 25 | * output. 26 | */ 27 | final class FakeMetricServiceClient extends MetricServiceClient { 28 | 29 | FakeMetricServiceClient(MetricServiceStub stub) { 30 | super(stub); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /exporters/trace/datadog/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Datadog Trace Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.8 5 | it.targetCompatibility = 1.8 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.findbugs_annotations 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-exporter-trace-util'), 13 | libraries.guava, 14 | libraries.gson, 15 | libraries.auto_value 16 | 17 | signature "org.codehaus.mojo.signature:java18:1.0@signature" 18 | } 19 | -------------------------------------------------------------------------------- /exporters/trace/elasticsearch/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Trace Elasticsearch Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.6 5 | it.targetCompatibility = 1.6 6 | } 7 | 8 | 9 | dependencies { 10 | 11 | compileOnly libraries.auto_value 12 | 13 | compile project(':opencensus-api'), 14 | project(':opencensus-exporter-trace-util'), 15 | libraries.guava 16 | 17 | testCompile project(':opencensus-api') 18 | 19 | signature "org.codehaus.mojo.signature:java17:+@signature" 20 | } -------------------------------------------------------------------------------- /exporters/trace/instana/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Trace Instana Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.6 5 | it.targetCompatibility = 1.6 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-exporter-trace-util'), 13 | libraries.guava 14 | 15 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 16 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 17 | } 18 | -------------------------------------------------------------------------------- /exporters/trace/jaeger/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Trace Jaeger Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.6 5 | it.targetCompatibility = 1.6 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-exporter-trace-util'), 13 | libraries.guava 14 | 15 | compile(libraries.jaeger_reporter) { 16 | // Prefer library version. 17 | exclude group: 'com.google.guava', module: 'guava' 18 | } 19 | 20 | testCompile 'org.testcontainers:testcontainers:1.7.0', 21 | 'com.google.http-client:google-http-client-gson:1.23.0' 22 | 23 | // Unless linked to impl, spans will be blank and not exported during integration tests. 24 | testRuntime project(':opencensus-impl') 25 | 26 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 27 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 28 | } 29 | -------------------------------------------------------------------------------- /exporters/trace/logging/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Trace Logging Exporter' 2 | 3 | dependencies { 4 | compile project(':opencensus-api'), 5 | libraries.guava 6 | 7 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 8 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 9 | } -------------------------------------------------------------------------------- /exporters/trace/ocagent/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Java OC-Agent Trace Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.7 5 | it.targetCompatibility = 1.7 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-contrib-resource-util'), 13 | project(':opencensus-exporter-trace-util') 14 | 15 | compile (libraries.grpc_core) { 16 | // We will always be more up to date. 17 | exclude group: 'io.opencensus', module: 'opencensus-api' 18 | } 19 | 20 | compile (libraries.grpc_stub) { 21 | // We will always be more up to date. 22 | exclude group: 'io.opencensus', module: 'opencensus-api' 23 | } 24 | 25 | compile (libraries.grpc_netty) { 26 | // We will always be more up to date. 27 | exclude group: 'io.opencensus', module: 'opencensus-api' 28 | } 29 | 30 | compile (libraries.opencensus_proto) { 31 | // We will always be more up to date. 32 | exclude group: 'io.opencensus', module: 'opencensus-api' 33 | } 34 | 35 | testRuntimeOnly project(':opencensus-impl'), 36 | project(':opencensus-impl-core') 37 | 38 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 39 | } 40 | -------------------------------------------------------------------------------- /exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * This package contains the Java implementation of the OpenCensus Agent (OC-Agent) Trace Exporter. 19 | * 20 | *

WARNING: Currently all the public classes under this package are marked as {@link 21 | * io.opencensus.common.ExperimentalApi}. The classes and APIs under {@link 22 | * io.opencensus.exporter.trace.ocagent} are likely to get backwards-incompatible updates in the 23 | * future. DO NOT USE except for experimental purposes. 24 | * 25 | *

See more details on 26 | * https://github.com/census-instrumentation/opencensus-proto/tree/master/src/opencensus/proto/agent. 27 | */ 28 | @io.opencensus.common.ExperimentalApi 29 | package io.opencensus.exporter.trace.ocagent; 30 | -------------------------------------------------------------------------------- /exporters/trace/stackdriver/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Trace Stackdriver Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.7 5 | it.targetCompatibility = 1.7 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-contrib-resource-util'), 13 | libraries.google_auth, 14 | libraries.grpc_auth, 15 | libraries.grpc_core, 16 | libraries.grpc_netty_shaded, 17 | libraries.grpc_stub, 18 | libraries.guava 19 | 20 | compile (libraries.google_cloud_trace) { 21 | // Prefer library version. 22 | exclude group: 'com.google.guava', module: 'guava' 23 | 24 | // Prefer library version. 25 | exclude group: 'com.google.code.findbugs', module: 'jsr305' 26 | 27 | // Prefer library version. 28 | exclude group: 'io.grpc', module: 'grpc-auth' 29 | exclude group: 'io.grpc', module: 'grpc-core' 30 | exclude group: 'io.grpc', module: 'grpc-netty-shaded' 31 | exclude group: 'io.grpc', module: 'grpc-stub' 32 | 33 | // We will always be more up to date. 34 | exclude group: 'io.opencensus', module: 'opencensus-api' 35 | } 36 | 37 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 38 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 39 | } 40 | -------------------------------------------------------------------------------- /exporters/trace/util/README.md: -------------------------------------------------------------------------------- 1 | # OpenCensus Java Trace Exporter Util 2 | 3 | The *OpenCensus Trace Exporter Util* is the Java helper package for all trace exporters. 4 | 5 | ## Quickstart 6 | 7 | ### Add the dependencies to your project 8 | 9 | For Maven add to your `pom.xml`: 10 | ```xml 11 | 12 | 13 | io.opencensus 14 | opencensus-api 15 | 0.22.0 16 | 17 | 18 | io.opencensus 19 | opencensus-exporter-trace-util 20 | 0.22.0 21 | 22 | 23 | ``` 24 | 25 | For Gradle add to your dependencies: 26 | ```groovy 27 | compile 'io.opencensus:opencensus-api:0.22.0' 28 | compile 'io.opencensus:opencensus-exporter-trace-util:0.22.0' 29 | ``` 30 | -------------------------------------------------------------------------------- /exporters/trace/util/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Java Trace Exporter Utils' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.6 5 | it.targetCompatibility = 1.6 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | libraries.guava 13 | 14 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 15 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 16 | } 17 | -------------------------------------------------------------------------------- /exporters/trace/zipkin/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Trace Zipkin Exporter' 2 | 3 | [compileJava, compileTestJava].each() { 4 | it.sourceCompatibility = 1.6 5 | it.targetCompatibility = 1.6 6 | } 7 | 8 | dependencies { 9 | compileOnly libraries.auto_value 10 | 11 | compile project(':opencensus-api'), 12 | project(':opencensus-exporter-trace-util'), 13 | libraries.guava, 14 | libraries.zipkin_reporter, 15 | libraries.zipkin_urlconnection 16 | 17 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 18 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 19 | } 20 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/census-instrumentation/opencensus-java/baa68680b19040ff7739e314a2422a25cf41e27a/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /impl/README.md: -------------------------------------------------------------------------------- 1 | OpenCensus Java implementation 2 | ====================================================== 3 | 4 | * Java 7 compatible. 5 | * Contains any classes not compatible with Android. 6 | -------------------------------------------------------------------------------- /impl/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Implementation' 2 | 3 | apply plugin: 'java' 4 | 5 | [compileJava, compileTestJava].each() { 6 | it.sourceCompatibility = 1.7 7 | it.targetCompatibility = 1.7 8 | } 9 | 10 | dependencies { 11 | compile project(':opencensus-api'), 12 | project(':opencensus-impl-core'), 13 | libraries.disruptor 14 | 15 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 16 | } 17 | 18 | javadoc.exclude 'io/opencensus/internal/**' -------------------------------------------------------------------------------- /impl/src/main/java/io/opencensus/impl/metrics/MetricsComponentImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impl.metrics; 18 | 19 | import io.opencensus.implcore.common.MillisClock; 20 | import io.opencensus.implcore.metrics.MetricsComponentImplBase; 21 | import io.opencensus.metrics.MetricsComponent; 22 | 23 | /** Implementation of {@link MetricsComponent}. */ 24 | public final class MetricsComponentImpl extends MetricsComponentImplBase { 25 | 26 | public MetricsComponentImpl() { 27 | super(MillisClock.getInstance()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /impl/src/main/java/io/opencensus/impl/stats/StatsComponentImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impl.stats; 18 | 19 | import io.opencensus.impl.internal.DisruptorEventQueue; 20 | import io.opencensus.implcore.common.MillisClock; 21 | import io.opencensus.implcore.stats.StatsComponentImplBase; 22 | import io.opencensus.stats.StatsComponent; 23 | 24 | /** Java 7 and 8 implementation of {@link StatsComponent}. */ 25 | public final class StatsComponentImpl extends StatsComponentImplBase { 26 | 27 | /** Public constructor to be used with reflection loading. */ 28 | public StatsComponentImpl() { 29 | super(DisruptorEventQueue.getInstance(), MillisClock.getInstance()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /impl/src/main/java/io/opencensus/impl/tags/TagsComponentImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impl.tags; 18 | 19 | import io.opencensus.implcore.tags.TagsComponentImplBase; 20 | import io.opencensus.tags.TagsComponent; 21 | 22 | /** Java 7 and 8 implementation of {@link TagsComponent}. */ 23 | public final class TagsComponentImpl extends TagsComponentImplBase {} 24 | -------------------------------------------------------------------------------- /impl/src/main/java/io/opencensus/impl/trace/internal/ThreadLocalRandomHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impl.trace.internal; 18 | 19 | import io.opencensus.implcore.trace.internal.RandomHandler; 20 | import java.util.Random; 21 | import java.util.concurrent.ThreadLocalRandom; 22 | import javax.annotation.concurrent.ThreadSafe; 23 | 24 | /** Implementation of the {@link RandomHandler} using {@link ThreadLocalRandom}. */ 25 | @ThreadSafe 26 | public final class ThreadLocalRandomHandler extends RandomHandler { 27 | 28 | /** Constructs a new {@code ThreadLocalRandomHandler}. */ 29 | public ThreadLocalRandomHandler() {} 30 | 31 | @Override 32 | public Random current() { 33 | return ThreadLocalRandom.current(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /impl/src/test/java/io/opencensus/impl/metrics/MetricsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impl.metrics; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.opencensus.implcore.metrics.MetricRegistryImpl; 22 | import io.opencensus.implcore.metrics.export.ExportComponentImpl; 23 | import io.opencensus.metrics.Metrics; 24 | import io.opencensus.metrics.MetricsComponent; 25 | import org.junit.Test; 26 | import org.junit.runner.RunWith; 27 | import org.junit.runners.JUnit4; 28 | 29 | /** Test for accessing the {@link MetricsComponent} through the {@link Metrics} class. */ 30 | @RunWith(JUnit4.class) 31 | public class MetricsTest { 32 | 33 | @Test 34 | public void getExportComponent() { 35 | assertThat(Metrics.getExportComponent()).isInstanceOf(ExportComponentImpl.class); 36 | } 37 | 38 | @Test 39 | public void getMetricRegistry() { 40 | assertThat(Metrics.getMetricRegistry()).isInstanceOf(MetricRegistryImpl.class); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /impl/src/test/java/io/opencensus/impl/stats/StatsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-17, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impl.stats; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.opencensus.implcore.stats.StatsRecorderImpl; 22 | import io.opencensus.implcore.stats.ViewManagerImpl; 23 | import io.opencensus.stats.Stats; 24 | import io.opencensus.stats.StatsComponent; 25 | import org.junit.Test; 26 | import org.junit.runner.RunWith; 27 | import org.junit.runners.JUnit4; 28 | 29 | /** Test for accessing the {@link StatsComponent} through the {@link Stats} class. */ 30 | @RunWith(JUnit4.class) 31 | public final class StatsTest { 32 | @Test 33 | public void getStatsRecorder() { 34 | assertThat(Stats.getStatsRecorder()).isInstanceOf(StatsRecorderImpl.class); 35 | } 36 | 37 | @Test 38 | public void getViewManager() { 39 | assertThat(Stats.getViewManager()).isInstanceOf(ViewManagerImpl.class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /impl/src/test/java/io/opencensus/impl/tags/TagsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impl.tags; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.opencensus.implcore.tags.TaggerImpl; 22 | import io.opencensus.implcore.tags.propagation.TagPropagationComponentImpl; 23 | import io.opencensus.tags.Tags; 24 | import io.opencensus.tags.TagsComponent; 25 | import org.junit.Test; 26 | import org.junit.runner.RunWith; 27 | import org.junit.runners.JUnit4; 28 | 29 | /** Test for accessing the {@link TagsComponent} through the {@link Tags} class. */ 30 | @RunWith(JUnit4.class) 31 | public final class TagsTest { 32 | @Test 33 | public void getTagger() { 34 | assertThat(Tags.getTagger()).isInstanceOf(TaggerImpl.class); 35 | } 36 | 37 | @Test 38 | public void getTagContextSerializer() { 39 | assertThat(Tags.getTagPropagationComponent()).isInstanceOf(TagPropagationComponentImpl.class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /impl_core/README.md: -------------------------------------------------------------------------------- 1 | OpenCensus implementation 2 | ====================================================== 3 | 4 | * The main implementation shared between Java and Android. 5 | * Java 7 and Android compatible. 6 | -------------------------------------------------------------------------------- /impl_core/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Core Implementation' 2 | 3 | dependencies { 4 | compile project(':opencensus-api'), 5 | libraries.guava 6 | 7 | compileOnly libraries.auto_value 8 | 9 | testCompile project(':opencensus-testing') 10 | 11 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 12 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 13 | } 14 | 15 | javadoc.exclude 'io/opencensus/internal/**' 16 | javadoc.exclude 'io/opencensus/trace/internal/**' -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/common/MillisClock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.common; 18 | 19 | import io.opencensus.common.Clock; 20 | import io.opencensus.common.Timestamp; 21 | import javax.annotation.concurrent.ThreadSafe; 22 | 23 | /** A {@link Clock} that uses {@link System#currentTimeMillis()} and {@link System#nanoTime()}. */ 24 | @ThreadSafe 25 | public final class MillisClock extends Clock { 26 | private static final MillisClock INSTANCE = new MillisClock(); 27 | 28 | private MillisClock() {} 29 | 30 | /** 31 | * Returns a {@code MillisClock}. 32 | * 33 | * @return a {@code MillisClock}. 34 | */ 35 | public static MillisClock getInstance() { 36 | return INSTANCE; 37 | } 38 | 39 | @Override 40 | public Timestamp now() { 41 | return Timestamp.fromMillis(System.currentTimeMillis()); 42 | } 43 | 44 | @Override 45 | public long nowNanos() { 46 | return System.nanoTime(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/internal/CheckerFrameworkUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.internal; 18 | 19 | import javax.annotation.Nullable; 20 | 21 | /** 22 | * Utility methods for suppressing nullness warnings and working around Checker Framework issues. 23 | */ 24 | public final class CheckerFrameworkUtils { 25 | private CheckerFrameworkUtils() {} 26 | 27 | /** Suppresses warnings about a nullable value. */ 28 | // TODO(sebright): Try to remove all uses of this method. 29 | @SuppressWarnings("nullness") 30 | public static T castNonNull(@Nullable T arg) { 31 | return arg; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/internal/EventQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.internal; 18 | 19 | /** A queue that processes events. See {@code DisruptorEventQueue} for an example. */ 20 | public interface EventQueue { 21 | void enqueue(Entry entry); 22 | 23 | void shutdown(); 24 | 25 | /** 26 | * Base interface to be used for all entries in {@link EventQueue}. For example usage, see {@code 27 | * DisruptorEventQueue}. 28 | */ 29 | interface Entry { 30 | /** 31 | * Process the event associated with this entry. This will be called for every event in the 32 | * associated {@link EventQueue}. 33 | */ 34 | void process(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/internal/NoopScope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.internal; 18 | 19 | import io.opencensus.common.Scope; 20 | 21 | /** A {@link Scope} that does nothing when it is created or closed. */ 22 | public final class NoopScope implements Scope { 23 | private static final Scope INSTANCE = new NoopScope(); 24 | 25 | private NoopScope() {} 26 | 27 | /** 28 | * Returns a {@code NoopScope}. 29 | * 30 | * @return a {@code NoopScope}. 31 | */ 32 | public static Scope getInstance() { 33 | return INSTANCE; 34 | } 35 | 36 | @Override 37 | public void close() {} 38 | } 39 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/internal/SimpleEventQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.internal; 18 | 19 | /** 20 | * An {@link EventQueue} that processes events in the current thread. This class can be used for 21 | * testing. 22 | */ 23 | public class SimpleEventQueue implements EventQueue { 24 | 25 | @Override 26 | public void enqueue(Entry entry) { 27 | entry.process(); 28 | } 29 | 30 | @Override 31 | public void shutdown() {} 32 | } 33 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/internal/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.internal; 18 | 19 | import java.util.List; 20 | 21 | /** General internal utility methods. */ 22 | public final class Utils { 23 | 24 | private Utils() {} 25 | 26 | /** 27 | * Throws a {@link NullPointerException} if any of the list elements is null. 28 | * 29 | * @param list the argument list to check for null. 30 | * @param errorMessage the message to use for the exception. Will be converted to a string using 31 | * {@link String#valueOf(Object)}. 32 | */ 33 | public static void checkListElementNotNull( 34 | List list, @javax.annotation.Nullable Object errorMessage) { 35 | for (T element : list) { 36 | if (element == null) { 37 | throw new NullPointerException(String.valueOf(errorMessage)); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/metrics/Meter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.metrics; 18 | 19 | import io.opencensus.common.Clock; 20 | import io.opencensus.metrics.export.Metric; 21 | import io.opencensus.metrics.export.MetricDescriptor; 22 | import javax.annotation.Nullable; 23 | 24 | interface Meter { 25 | /** 26 | * Provides a {@link io.opencensus.metrics.export.Metric} with one or more {@link 27 | * io.opencensus.metrics.export.TimeSeries}. 28 | * 29 | * @param clock the clock used to get the time. 30 | * @throws NullPointerException if {@code TimeSeries} is not present in {@code Metric}. 31 | * @return a {@code Metric}. 32 | */ 33 | @Nullable 34 | Metric getMetric(Clock clock); 35 | 36 | /** 37 | * Provides a {@link io.opencensus.metrics.export.MetricDescriptor}. 38 | * 39 | * @return a {@code MetricDescriptor}. 40 | */ 41 | MetricDescriptor getMetricDescriptor(); 42 | } 43 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/metrics/MetricsComponentImplBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.metrics; 18 | 19 | import io.opencensus.common.Clock; 20 | import io.opencensus.implcore.metrics.export.ExportComponentImpl; 21 | import io.opencensus.metrics.MetricsComponent; 22 | 23 | /** Implementation of {@link MetricsComponent}. */ 24 | public class MetricsComponentImplBase extends MetricsComponent { 25 | 26 | private final ExportComponentImpl exportComponent; 27 | private final MetricRegistryImpl metricRegistry; 28 | 29 | @Override 30 | public ExportComponentImpl getExportComponent() { 31 | return exportComponent; 32 | } 33 | 34 | @Override 35 | public MetricRegistryImpl getMetricRegistry() { 36 | return metricRegistry; 37 | } 38 | 39 | protected MetricsComponentImplBase(Clock clock) { 40 | exportComponent = new ExportComponentImpl(); 41 | metricRegistry = new MetricRegistryImpl(clock); 42 | // Register the MetricRegistry's MetricProducer to the global MetricProducerManager. 43 | exportComponent.getMetricProducerManager().add(metricRegistry.getMetricProducer()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/metrics/export/ExportComponentImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.metrics.export; 18 | 19 | import io.opencensus.metrics.export.ExportComponent; 20 | import io.opencensus.metrics.export.MetricProducerManager; 21 | 22 | /** Implementation of {@link ExportComponent}. */ 23 | public final class ExportComponentImpl extends ExportComponent { 24 | 25 | private final MetricProducerManager metricProducerManager = new MetricProducerManagerImpl(); 26 | 27 | @Override 28 | public MetricProducerManager getMetricProducerManager() { 29 | return metricProducerManager; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/stats/MetricProducerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.stats; 18 | 19 | import io.opencensus.metrics.export.Metric; 20 | import io.opencensus.metrics.export.MetricProducer; 21 | import java.util.Collection; 22 | import javax.annotation.concurrent.ThreadSafe; 23 | 24 | /** Implementation of {@link MetricProducer}. */ 25 | @ThreadSafe 26 | final class MetricProducerImpl extends MetricProducer { 27 | 28 | private final StatsManager statsManager; 29 | 30 | MetricProducerImpl(StatsManager statsManager) { 31 | this.statsManager = statsManager; 32 | } 33 | 34 | @Override 35 | public Collection getMetrics() { 36 | return statsManager.getMetrics(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/stats/StatsRecorderImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.stats; 18 | 19 | import static com.google.common.base.Preconditions.checkNotNull; 20 | 21 | import io.opencensus.stats.StatsRecorder; 22 | 23 | /** Implementation of {@link StatsRecorder}. */ 24 | public final class StatsRecorderImpl extends StatsRecorder { 25 | private final StatsManager statsManager; 26 | 27 | StatsRecorderImpl(StatsManager statsManager) { 28 | checkNotNull(statsManager, "StatsManager"); 29 | this.statsManager = statsManager; 30 | } 31 | 32 | @Override 33 | public MeasureMapImpl newMeasureMap() { 34 | return MeasureMapImpl.create(statsManager); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/stats/ViewManagerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.stats; 18 | 19 | import io.opencensus.stats.View; 20 | import io.opencensus.stats.ViewData; 21 | import io.opencensus.stats.ViewManager; 22 | import java.util.Set; 23 | import javax.annotation.Nullable; 24 | 25 | /** Implementation of {@link ViewManager}. */ 26 | public final class ViewManagerImpl extends ViewManager { 27 | private final StatsManager statsManager; 28 | 29 | ViewManagerImpl(StatsManager statsManager) { 30 | this.statsManager = statsManager; 31 | } 32 | 33 | @Override 34 | public void registerView(View view) { 35 | statsManager.registerView(view); 36 | } 37 | 38 | @Override 39 | @Nullable 40 | public ViewData getView(View.Name viewName) { 41 | return statsManager.getView(viewName); 42 | } 43 | 44 | @Override 45 | public Set getAllExportedViews() { 46 | return statsManager.getExportedViews(); 47 | } 48 | 49 | void clearStats() { 50 | statsManager.clearStats(); 51 | } 52 | 53 | void resumeStatsCollection() { 54 | statsManager.resumeStatsCollection(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/tags/TagContextUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.tags; 18 | 19 | import io.opencensus.tags.Tag; 20 | 21 | final class TagContextUtils { 22 | private TagContextUtils() {} 23 | 24 | /** 25 | * Add a {@code Tag} of any type to a builder. 26 | * 27 | * @param tag tag containing the key and value to set. 28 | * @param builder the builder to update. 29 | */ 30 | static void addTagToBuilder(Tag tag, TagMapBuilderImpl builder) { 31 | builder.put(tag.getKey(), tag.getValue(), tag.getTagMetadata()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/trace/config/TraceConfigImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.trace.config; 18 | 19 | import io.opencensus.trace.config.TraceConfig; 20 | import io.opencensus.trace.config.TraceParams; 21 | 22 | /** 23 | * Global configuration of the trace service. This allows users to change configs for the default 24 | * sampler, maximum events to be kept, etc. 25 | */ 26 | public final class TraceConfigImpl extends TraceConfig { 27 | // Reads and writes are atomic for reference variables. Use volatile to ensure that these 28 | // operations are visible on other CPUs as well. 29 | private volatile TraceParams activeTraceParams = TraceParams.DEFAULT; 30 | 31 | /** Constructs a new {@code TraceConfigImpl}. */ 32 | public TraceConfigImpl() {} 33 | 34 | @Override 35 | public TraceParams getActiveTraceParams() { 36 | return activeTraceParams; 37 | } 38 | 39 | @Override 40 | public void updateActiveTraceParams(TraceParams traceParams) { 41 | activeTraceParams = traceParams; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/trace/internal/RandomHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.trace.internal; 18 | 19 | import java.security.SecureRandom; 20 | import java.util.Random; 21 | import javax.annotation.concurrent.ThreadSafe; 22 | 23 | /** 24 | * Abstract class to access the current {@link Random}. 25 | * 26 | *

Implementation can have a per thread instance or a single global instance. 27 | */ 28 | @ThreadSafe 29 | public abstract class RandomHandler { 30 | /** 31 | * Returns the current {@link Random}. 32 | * 33 | * @return the current {@code Random}. 34 | */ 35 | public abstract Random current(); 36 | 37 | /** Implementation of the {@link RandomHandler} using {@link SecureRandom}. */ 38 | @ThreadSafe 39 | public static final class SecureRandomHandler extends RandomHandler { 40 | private final Random random = new SecureRandom(); 41 | 42 | /** Constructs a new {@link SecureRandomHandler}. */ 43 | public SecureRandomHandler() {} 44 | 45 | @Override 46 | public Random current() { 47 | return random; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /impl_core/src/main/java/io/opencensus/implcore/trace/propagation/PropagationComponentImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.trace.propagation; 18 | 19 | import io.opencensus.trace.propagation.BinaryFormat; 20 | import io.opencensus.trace.propagation.PropagationComponent; 21 | import io.opencensus.trace.propagation.TextFormat; 22 | 23 | /** Implementation of the {@link PropagationComponent}. */ 24 | public class PropagationComponentImpl extends PropagationComponent { 25 | private final BinaryFormat binaryFormat = new BinaryFormatImpl(); 26 | private final TextFormat b3Format = new B3Format(); 27 | private final TextFormat traceContextFormat = new TraceContextFormat(); 28 | 29 | @Override 30 | public BinaryFormat getBinaryFormat() { 31 | return binaryFormat; 32 | } 33 | 34 | @Override 35 | public TextFormat getB3Format() { 36 | return b3Format; 37 | } 38 | 39 | @Override 40 | public TextFormat getTraceContextFormat() { 41 | return traceContextFormat; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /impl_core/src/test/java/io/opencensus/implcore/internal/UtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.internal; 18 | 19 | import java.util.Arrays; 20 | import java.util.List; 21 | import org.junit.Rule; 22 | import org.junit.Test; 23 | import org.junit.rules.ExpectedException; 24 | import org.junit.runner.RunWith; 25 | import org.junit.runners.JUnit4; 26 | 27 | /** Unit tests for {@link Utils}. */ 28 | @RunWith(JUnit4.class) 29 | public class UtilsTest { 30 | @Rule public ExpectedException thrown = ExpectedException.none(); 31 | 32 | @Test 33 | public void checkListElementNull() { 34 | List list = Arrays.asList(0.0, 1.0, 2.0, null); 35 | thrown.expect(NullPointerException.class); 36 | thrown.expectMessage("null"); 37 | Utils.checkListElementNotNull(list, null); 38 | } 39 | 40 | @Test 41 | public void checkListElementNull_WithMessage() { 42 | List list = Arrays.asList(0.0, 1.0, 2.0, null); 43 | thrown.expect(NullPointerException.class); 44 | thrown.expectMessage("list should not be null."); 45 | Utils.checkListElementNotNull(list, "list should not be null."); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /impl_core/src/test/java/io/opencensus/implcore/metrics/export/ExportComponentImplTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.metrics.export; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import org.junit.Test; 22 | import org.junit.runner.RunWith; 23 | import org.junit.runners.JUnit4; 24 | 25 | /** Unit tests for {@link ExportComponentImpl}. */ 26 | @RunWith(JUnit4.class) 27 | public class ExportComponentImplTest { 28 | 29 | @Test 30 | public void getMetricProducerManager() { 31 | ExportComponentImpl exportComponent = new ExportComponentImpl(); 32 | assertThat(exportComponent.getMetricProducerManager()) 33 | .isInstanceOf(MetricProducerManagerImpl.class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /impl_core/src/test/java/io/opencensus/implcore/tags/TagsTestUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.implcore.tags; 18 | 19 | import com.google.common.collect.Lists; 20 | import io.opencensus.tags.InternalUtils; 21 | import io.opencensus.tags.Tag; 22 | import io.opencensus.tags.TagContext; 23 | import java.util.Collection; 24 | 25 | /** Test utilities for tagging. */ 26 | public class TagsTestUtil { 27 | private TagsTestUtil() {} 28 | 29 | /** Returns a collection of all tags in a {@link TagContext}. */ 30 | public static Collection tagContextToList(TagContext tags) { 31 | return Lists.newArrayList(InternalUtils.getTags(tags)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /impl_lite/README.md: -------------------------------------------------------------------------------- 1 | OpenCensus Android implementation 2 | ====================================================== 3 | 4 | * Android compatible. 5 | * StatsManager specifies the stats implementation classes that should be used 6 | with Android. 7 | -------------------------------------------------------------------------------- /impl_lite/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Lite Implementation' 2 | 3 | dependencies { 4 | compile project(':opencensus-api'), 5 | project(':opencensus-impl-core') 6 | 7 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 8 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 9 | } 10 | -------------------------------------------------------------------------------- /impl_lite/src/main/java/io/opencensus/impllite/metrics/MetricsComponentImplLite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impllite.metrics; 18 | 19 | import io.opencensus.implcore.common.MillisClock; 20 | import io.opencensus.implcore.metrics.MetricsComponentImplBase; 21 | import io.opencensus.metrics.MetricsComponent; 22 | 23 | /** Android-compatible implementation of {@link MetricsComponent}. */ 24 | public final class MetricsComponentImplLite extends MetricsComponentImplBase { 25 | 26 | public MetricsComponentImplLite() { 27 | super(MillisClock.getInstance()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /impl_lite/src/main/java/io/opencensus/impllite/stats/StatsComponentImplLite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impllite.stats; 18 | 19 | import io.opencensus.implcore.common.MillisClock; 20 | import io.opencensus.implcore.internal.SimpleEventQueue; 21 | import io.opencensus.implcore.stats.StatsComponentImplBase; 22 | import io.opencensus.stats.StatsComponent; 23 | 24 | /** Android-compatible implementation of {@link StatsComponent}. */ 25 | public final class StatsComponentImplLite extends StatsComponentImplBase { 26 | 27 | public StatsComponentImplLite() { 28 | // TODO(sebright): Use a more efficient queue implementation. 29 | super(new SimpleEventQueue(), MillisClock.getInstance()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /impl_lite/src/main/java/io/opencensus/impllite/tags/TagsComponentImplLite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impllite.tags; 18 | 19 | import io.opencensus.implcore.tags.TagsComponentImplBase; 20 | import io.opencensus.tags.TagsComponent; 21 | 22 | /** Android-compatible implementation of {@link TagsComponent}. */ 23 | public final class TagsComponentImplLite extends TagsComponentImplBase {} 24 | -------------------------------------------------------------------------------- /impl_lite/src/test/java/io/opencensus/impllite/metrics/MetricsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impllite.metrics; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.opencensus.implcore.metrics.MetricRegistryImpl; 22 | import io.opencensus.implcore.metrics.export.ExportComponentImpl; 23 | import io.opencensus.metrics.Metrics; 24 | import io.opencensus.metrics.MetricsComponent; 25 | import org.junit.Test; 26 | import org.junit.runner.RunWith; 27 | import org.junit.runners.JUnit4; 28 | 29 | /** Test for accessing the {@link MetricsComponent} through the {@link Metrics} class. */ 30 | @RunWith(JUnit4.class) 31 | public class MetricsTest { 32 | 33 | @Test 34 | public void getExportComponent() { 35 | assertThat(Metrics.getExportComponent()).isInstanceOf(ExportComponentImpl.class); 36 | } 37 | 38 | @Test 39 | public void getMetricRegistry() { 40 | assertThat(Metrics.getMetricRegistry()).isInstanceOf(MetricRegistryImpl.class); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /impl_lite/src/test/java/io/opencensus/impllite/stats/StatsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-17, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impllite.stats; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.opencensus.implcore.stats.StatsRecorderImpl; 22 | import io.opencensus.implcore.stats.ViewManagerImpl; 23 | import io.opencensus.stats.Stats; 24 | import io.opencensus.stats.StatsComponent; 25 | import org.junit.Test; 26 | import org.junit.runner.RunWith; 27 | import org.junit.runners.JUnit4; 28 | 29 | /** Test for accessing the {@link StatsComponent} through the {@link Stats} class. */ 30 | @RunWith(JUnit4.class) 31 | public final class StatsTest { 32 | @Test 33 | public void getStatsRecorder() { 34 | assertThat(Stats.getStatsRecorder()).isInstanceOf(StatsRecorderImpl.class); 35 | } 36 | 37 | @Test 38 | public void getViewManager() { 39 | assertThat(Stats.getViewManager()).isInstanceOf(ViewManagerImpl.class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /impl_lite/src/test/java/io/opencensus/impllite/tags/TagsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017, OpenCensus Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.opencensus.impllite.tags; 18 | 19 | import static com.google.common.truth.Truth.assertThat; 20 | 21 | import io.opencensus.implcore.tags.TaggerImpl; 22 | import io.opencensus.implcore.tags.propagation.TagPropagationComponentImpl; 23 | import io.opencensus.tags.Tags; 24 | import io.opencensus.tags.TagsComponent; 25 | import org.junit.Test; 26 | import org.junit.runner.RunWith; 27 | import org.junit.runners.JUnit4; 28 | 29 | /** Test for accessing the {@link TagsComponent} through the {@link Tags} class. */ 30 | @RunWith(JUnit4.class) 31 | public final class TagsTest { 32 | @Test 33 | public void getTagger() { 34 | assertThat(Tags.getTagger()).isInstanceOf(TaggerImpl.class); 35 | } 36 | 37 | @Test 38 | public void getTagContextSerializer() { 39 | assertThat(Tags.getTagPropagationComponent()).isInstanceOf(TagPropagationComponentImpl.class); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /testing/README.md: -------------------------------------------------------------------------------- 1 | OpenCensus Testing Package 2 | ====================================================== 3 | 4 | * Java 6 and Android compatible. 5 | * The classes in this directory can be used to test the API integration. 6 | -------------------------------------------------------------------------------- /testing/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'OpenCensus Testing' 2 | 3 | dependencies { 4 | compile project(':opencensus-api'), 5 | libraries.guava 6 | 7 | signature "org.codehaus.mojo.signature:java17:1.0@signature" 8 | signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature" 9 | } 10 | --------------------------------------------------------------------------------