Ruby Stackdriver Exporter for OpenCensus
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.
Install the gem using Bundler:
- Add the
opencensus-stackdrivergem to your application's Gemfile:
- Use Bundler to install the gem:
$ bundle install
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:
.configure do |c| c.trace.exporter = ::::::. end
If you are using Ruby on Rails, you can equivalently include this code in your Rails config:
config.opencensus.trace.exporter = ::::::.
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
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
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.
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.
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.
This library is licensed under Apache 2.0. Full license text is available in LICENSE.