Repository is archived
No release in over 3 years
Low commit activity in last 3 years
There's a lot of open issues
Stackdriver exporter for OpenCensus
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.17
~> 0.13
~> 5.14
~> 5.1.4
~> 12.0
~> 0.59.2
~> 0.9
~> 0.1.6

Runtime

 Project Readme

Warning

OpenCensus and OpenTracing have merged to form OpenTelemetry, which serves as the next major version of OpenCensus and OpenTracing.

OpenTelemetry has now reached feature parity with OpenCensus, with tracing and metrics SDKs available in .NET, Golang, Java, NodeJS, and Python. All OpenCensus Github repositories, except census-instrumentation/opencensus-python, will be archived on July 31st, 2023. We encourage users to migrate to OpenTelemetry by this date.

To help you gradually migrate your instrumentation to OpenTelemetry, bridges are available in Java, Go, Python, and JS. Read the full blog post to learn more.

Ruby Stackdriver Exporter for OpenCensus

This repository contains the source to the opencensus-stackdriver gem. This library is a plugin for Ruby OpenCensus that exports data to Stackdriver.

OpenCensus is a platform- and provider-agnostic framework for distributed tracing and stats collection. For more information, see https://opencensus.io.

This library is in an alpha stage, and the API is subject to change. In particular, support for the Stats API is currently incomplete and experimental.

Quick Start

Installation

Install the gem using Bundler:

  1. Add the opencensus-stackdriver gem to your application's Gemfile:
gem "opencensus-stackdriver"
  1. Use Bundler to install the gem:
$ bundle install

The core opencensus gem and the google-cloud-trace client library for the Stackdriver API will be installed automatically as dependencies.

Installing the plugin

The Stackdriver plugin can be installed using OpenCensus configuration. Insert the following code in your application's initialization:

OpenCensus.configure do |c|
  c.trace.exporter = OpenCensus::Trace::Exporters::Stackdriver.new
end

If you are using Ruby on Rails, you can equivalently include this code in your Rails config:

config.opencensus.trace.exporter = OpenCensus::Trace::Exporters::Stackdriver.new

See the documentation for OpenCensus::Trace::Exporters::Stackdriver for information on the configuration options for the Stackdriver exporter.

You can find more general information on using OpenCensus from Ruby, including configuring automatic trace capture and adding custom spans, in the core opencensus README.

Connecting to Stackdriver

If you do not have a Google Cloud project, create one from the cloud console.

The Stackdriver plugin needs credentials for your project in order to export traces to the Stackdriver backend. If your application is running in Google Cloud Platform hosting (i.e. Google App Engine, Google Kubernetes Engine, or Google Compute Engine), then the plugin can generally retrieve the needed credentials automatically from the runtime environment. See this section from the google-cloud-trace README for details.

If you are running the application locally, in self-hosted VMs, or a third party hosting service, you will need to provide the project ID and credentials (keyfile) to the Google Cloud client library. See this section for details.

Either way, once you have the Stackdriver exporter configured, you can view traces on the Google Cloud Console.

About the library

Supported Ruby Versions

This library is supported on Ruby 2.2+.

However, Ruby 2.3 or later is strongly recommended, as earlier releases have reached or are nearing end-of-life. After June 1, 2018, OpenCensus will provide official support only for Ruby versions that are considered current and supported by Ruby Core (that is, Ruby versions that are either in normal maintenance or in security maintenance). See https://www.ruby-lang.org/en/downloads/branches/ for further details.

Versioning

This library follows Semantic Versioning.

It is currently in major version zero (0.y.z), which means that anything may change at any time, and the public API should not be considered stable.

Contributing

Contributions to this library are always welcome and highly encouraged.

See the Contributing Guide for more information on how to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Code of Conduct for more information.

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.