Name Date Size #Lines LOC

..--

src/main/java/io/opencensus/contrib/observability/ready/util/H25-Apr-2025-10943

README.mdH A D25-Apr-20252.2 KiB5943

build.gradleH A D25-Apr-2025527 1914

README.md

1# OpenCensus Observability Ready Util for Java
2
3[![Build Status][travis-image]][travis-url]
4[![Windows Build Status][appveyor-image]][appveyor-url]
5
6The *OpenCensus Observability Ready Util for Java* allows users to use OpenCensus easily.
7
8It provides a wrapper that
9* Enables [Basic RPC views](https://github.com/census-instrumentation/opencensus-java/blob/2a17c8482ffb04540ea4ac0a5f746ad8d536c996/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcViews.java#L219)
10* Sets Probabilistic sampling rate to `0.0001`
11* Creates and Registers OCAgent Exporter to collect traces and metrics
12
13## Quickstart
14
15### Add the dependencies to your project
16
17For Maven add to your `pom.xml`:
18```xml
19<dependencies>
20  <dependency>
21    <groupId>io.opencensus</groupId>
22    <artifactId>opencensus-contrib-observability-ready-util</artifactId>
23    <version>0.25.0</version>
24  </dependency>
25</dependencies>
26```
27
28For Gradle add to your dependencies:
29```groovy
30compile 'io.opencensus:opencensus-contrib-observability-ready-util:0.25.0'
31```
32
33### Enable OpenCensus:
34
35```java
36import io.opencensus.contrib.observability.ready.util.BasicSetup;
37
38public class YourClass {
39  public static void main(String[] args) {
40    // It is recommended to call this method before doing any RPC call to avoid missing stats.
41    BasicSetup.enableOpenCensus("with-service-name");
42  }
43}
44```
45
46> If Agent is not yet up and running, Exporter will just retry connection.
47
48### And deploy OpenCensus Agent:
49
50It will require you to deploy the [OpenCensus-Agent](https://github.com/census-instrumentation/opencensus-service#opencensus-agent) in order to export and examine the stats and traces.
51The OpenCensus Agent exporter aka “ocagent-exporter” enables your applications to send the
52observability that they’ve collected using OpenCensus to the OpenCensus Agent.
53
54
55[travis-image]: https://travis-ci.org/census-instrumentation/opencensus-java.svg?branch=master
56[travis-url]: https://travis-ci.org/census-instrumentation/opencensus-java
57[appveyor-image]: https://ci.appveyor.com/api/projects/status/hxthmpkxar4jq4be/branch/master?svg=true
58[appveyor-url]: https://ci.appveyor.com/project/opencensusjavateam/opencensus-java/branch/master
59