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.
Install the gem using Bundler:
- Add the
opencensus-stackdriver
gem to your application's Gemfile:
gem "opencensus-stackdriver"
- 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.
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.
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.
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.