OpenCensus and OpenTracing have merged into OpenTelemetry!

Metrics

Introduction

The OpenCensus Service allows you to export metrics that are collected from client libraries and receivers to Stackdriver.

For assistance setting up Stackdriver, Click here for a guided codelab.

Configuration

In the Service’s YAML configuration file, under section “exporters” and sub-section “stackdriver” and configure fields:

Format

exporters:
  stackdriver:
    project: "<google_cloud_platform_project_id>"
    metric_prefix: "<your_metric_prefix>"
    enable_metrics: <true or false>

End to end example

In this end-to-end example, we’ll have the OpenCensus Service running and a couple of Go applications that use the Go ocagent-exporter to send over metrics to the OpenCensus Service and then to Stackdriver.

Running OpenCensus Service

On starting ocagent with the configuration below:

exporters:
  stackdriver:
    project: "opencensus-demo"
    metric_prefix: "opencensus_demo"
    enable_metrics: true

Before running the OpenCensus Service, we need to make sure that we have our Google Application Credentials resolvable either locally or after following Application Authentication

Agent

GOOGLE_APPLICATION_CREDENTIALS=gcp_creds.json ./bin/ocagent --config oca.yaml

Running Application Code

And then running the ocagent-go-exporter main.go application

The ocagent.WithAddress can be changed in main.go to point to the OpenCensus Collector directly if desired.

$ GO111MODULE=on go run example/main.go
#0: LineLength: 469By
#1: LineLength: 794By
Latency: 132.649ms
#0: LineLength: 448By
#1: LineLength: 420By
#2: LineLength: 486By
#3: LineLength: 473By
Latency: 1066.808ms

Results

On navigating to the Stackdriver Monitoring UI at https://console.cloud.google.com/monitoring

All metrics

Rates for individual line length buckets

Heatmap for line length buckets

p99th latencies

Rates for line counts

References

Resource URL
Stackdriver Monitoring home https://cloud.google.com/monitoring/
Go ocagent-exporter demo ocagent-demo