opencensus 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +9 -0
- data/CHANGELOG.md +4 -0
- data/lib/opencensus/version.rb +1 -1
- metadata +4 -20
- data/.gitignore +0 -15
- data/.rubocop.yml +0 -48
- data/.travis.yml +0 -19
- data/Gemfile +0 -4
- data/Rakefile +0 -24
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/docs/.gitignore +0 -3
- data/docs/404.html +0 -24
- data/docs/Gemfile +0 -31
- data/docs/_config.yml +0 -39
- data/docs/_layouts/default.html +0 -65
- data/docs/index.md +0 -151
- data/examples/hello-world/Gemfile +0 -5
- data/examples/hello-world/README.md +0 -33
- data/examples/hello-world/hello.rb +0 -59
- data/opencensus.gemspec +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcd6b186ce0092ad6cf63ec39de790c05ba2a8e5
|
4
|
+
data.tar.gz: d23b444fb33a05c2333d745e72a956217239a622
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59fdc1eaacc8e1f6616fc6948a78338756af8091d0be7ee5bd953270cdd2d48051048f72b56a7e9c030afea97d9f4dfe9356655586ef6dd4e672646715a495bc
|
7
|
+
data.tar.gz: a9879fbf66e97502c4c35ad4ea99365a17865138bfb4c05eb3701797b4c41990bc3bf48b7431ffb1ca01f4b3c55c824da7a2ec59c9b9bc4d8d66ec9bdc4eaf5e
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
data/lib/opencensus/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opencensus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Ching
|
8
8
|
- Daniel Azuma
|
9
9
|
autorequire:
|
10
|
-
bindir:
|
10
|
+
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-04-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -145,28 +145,13 @@ executables: []
|
|
145
145
|
extensions: []
|
146
146
|
extra_rdoc_files: []
|
147
147
|
files:
|
148
|
-
- ".
|
149
|
-
- ".rubocop.yml"
|
150
|
-
- ".travis.yml"
|
148
|
+
- ".yardopts"
|
151
149
|
- AUTHORS
|
152
150
|
- CHANGELOG.md
|
153
151
|
- CODE_OF_CONDUCT.md
|
154
152
|
- CONTRIBUTING.md
|
155
|
-
- Gemfile
|
156
153
|
- LICENSE
|
157
154
|
- README.md
|
158
|
-
- Rakefile
|
159
|
-
- bin/console
|
160
|
-
- bin/setup
|
161
|
-
- docs/.gitignore
|
162
|
-
- docs/404.html
|
163
|
-
- docs/Gemfile
|
164
|
-
- docs/_config.yml
|
165
|
-
- docs/_layouts/default.html
|
166
|
-
- docs/index.md
|
167
|
-
- examples/hello-world/Gemfile
|
168
|
-
- examples/hello-world/README.md
|
169
|
-
- examples/hello-world/hello.rb
|
170
155
|
- lib/opencensus.rb
|
171
156
|
- lib/opencensus/common.rb
|
172
157
|
- lib/opencensus/common/config.rb
|
@@ -203,7 +188,6 @@ files:
|
|
203
188
|
- lib/opencensus/trace/trace_context_data.rb
|
204
189
|
- lib/opencensus/trace/truncatable_string.rb
|
205
190
|
- lib/opencensus/version.rb
|
206
|
-
- opencensus.gemspec
|
207
191
|
homepage: https://github.com/census-instrumentation/opencensus-ruby
|
208
192
|
licenses:
|
209
193
|
- Apache-2.0
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
Exclude:
|
3
|
-
- "acceptance/**/*"
|
4
|
-
- "integration/**/*"
|
5
|
-
- "opencensus.gemspec"
|
6
|
-
- "Rakefile"
|
7
|
-
- "support/**/*"
|
8
|
-
- "test/**/*"
|
9
|
-
- "docs/**/*"
|
10
|
-
- "tmp/**/*"
|
11
|
-
|
12
|
-
Documentation:
|
13
|
-
Enabled: false
|
14
|
-
|
15
|
-
Style/StringLiterals:
|
16
|
-
EnforcedStyle: double_quotes
|
17
|
-
Style/MethodDefParentheses:
|
18
|
-
EnforcedStyle: require_no_parentheses
|
19
|
-
Style/NumericLiterals:
|
20
|
-
Enabled: false
|
21
|
-
Layout/SpaceAroundOperators:
|
22
|
-
Enabled: false
|
23
|
-
Metrics/ClassLength:
|
24
|
-
Enabled: false
|
25
|
-
Layout/EmptyLines:
|
26
|
-
Enabled: false
|
27
|
-
Style/EmptyElse:
|
28
|
-
Enabled: false
|
29
|
-
Metrics/CyclomaticComplexity:
|
30
|
-
Max: 10
|
31
|
-
Metrics/PerceivedComplexity:
|
32
|
-
Max: 10
|
33
|
-
Metrics/AbcSize:
|
34
|
-
Max: 25
|
35
|
-
Metrics/MethodLength:
|
36
|
-
Max: 20
|
37
|
-
Metrics/ParameterLists:
|
38
|
-
Enabled: false
|
39
|
-
Style/RescueModifier:
|
40
|
-
Enabled: false
|
41
|
-
Style/ClassVars:
|
42
|
-
Enabled: false
|
43
|
-
Style/TrivialAccessors:
|
44
|
-
Enabled: false
|
45
|
-
Style/CaseEquality:
|
46
|
-
Enabled: false
|
47
|
-
Style/GuardClause:
|
48
|
-
Enabled: false
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.2.9
|
5
|
-
- 2.3.6
|
6
|
-
- 2.4.3
|
7
|
-
- 2.5.0
|
8
|
-
before_install: gem install bundler -v 1.16.1
|
9
|
-
script:
|
10
|
-
- bundle exec rake
|
11
|
-
|
12
|
-
deploy:
|
13
|
-
provider: pages
|
14
|
-
local_dir: docs
|
15
|
-
skip_cleanup: true
|
16
|
-
email: chingor@google.com # To satisfy the CLA check, replace this with bot email.
|
17
|
-
github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
|
18
|
-
on:
|
19
|
-
branch: master
|
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rake/testtask"
|
3
|
-
require "yard"
|
4
|
-
|
5
|
-
require "rubocop/rake_task"
|
6
|
-
RuboCop::RakeTask.new
|
7
|
-
|
8
|
-
Rake::TestTask.new :test do |t|
|
9
|
-
t.libs << "test"
|
10
|
-
t.libs << "lib"
|
11
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
12
|
-
end
|
13
|
-
|
14
|
-
YARD::Rake::YardocTask.new do |t|
|
15
|
-
t.files = ['lib/**/*.rb'] # optional
|
16
|
-
t.options = ['--output-dir', 'docs/api'] # optional
|
17
|
-
t.stats_options = ['--list-undoc'] # optional
|
18
|
-
end
|
19
|
-
|
20
|
-
task :faster do
|
21
|
-
ENV["FASTER_TESTS"] = "true"
|
22
|
-
end
|
23
|
-
|
24
|
-
task :default => [:test, :rubocop, :yard]
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "opencensus"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/docs/.gitignore
DELETED
data/docs/404.html
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: default
|
3
|
-
---
|
4
|
-
|
5
|
-
<style type="text/css" media="screen">
|
6
|
-
.container {
|
7
|
-
margin: 10px auto;
|
8
|
-
max-width: 600px;
|
9
|
-
text-align: center;
|
10
|
-
}
|
11
|
-
h1 {
|
12
|
-
margin: 30px 0;
|
13
|
-
font-size: 4em;
|
14
|
-
line-height: 1;
|
15
|
-
letter-spacing: -1px;
|
16
|
-
}
|
17
|
-
</style>
|
18
|
-
|
19
|
-
<div class="container">
|
20
|
-
<h1>404</h1>
|
21
|
-
|
22
|
-
<p><strong>Page not found :(</strong></p>
|
23
|
-
<p>The requested page could not be found.</p>
|
24
|
-
</div>
|
data/docs/Gemfile
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
source "https://rubygems.org"
|
3
|
-
|
4
|
-
# Hello! This is where you manage which Jekyll version is used to run.
|
5
|
-
# When you want to use a different version, change it below, save the
|
6
|
-
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
|
7
|
-
#
|
8
|
-
# bundle exec jekyll serve
|
9
|
-
#
|
10
|
-
# This will help ensure the proper Jekyll version is running.
|
11
|
-
# Happy Jekylling!
|
12
|
-
gem "jekyll", "~> 3.6.2"
|
13
|
-
|
14
|
-
# This is the default theme for new Jekyll sites. You may change this to anything you like.
|
15
|
-
# gem "minima", "~> 2.0"
|
16
|
-
gem "jekyll-theme-minimal", "~> 0.1"
|
17
|
-
# gem "minimal"
|
18
|
-
|
19
|
-
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
|
20
|
-
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
21
|
-
# gem "github-pages", group: :jekyll_plugins
|
22
|
-
|
23
|
-
# If you have any plugins, put them here!
|
24
|
-
group :jekyll_plugins do
|
25
|
-
gem "jekyll-feed", "~> 0.6"
|
26
|
-
end
|
27
|
-
|
28
|
-
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
29
|
-
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
30
|
-
|
31
|
-
gem "github-pages", group: :jekyll_plugins
|
data/docs/_config.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# Welcome to Jekyll!
|
2
|
-
#
|
3
|
-
# This config file is meant for settings that affect your whole blog, values
|
4
|
-
# which you are expected to set up once and rarely edit after that. If you find
|
5
|
-
# yourself editing this file very often, consider using Jekyll's data files
|
6
|
-
# feature for the data you need to update frequently.
|
7
|
-
#
|
8
|
-
# For technical reasons, this file is *NOT* reloaded automatically when you use
|
9
|
-
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.
|
10
|
-
|
11
|
-
# Site settings
|
12
|
-
# These are used to personalize your new site. If you look in the HTML files,
|
13
|
-
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
|
14
|
-
# You can create any custom variable you would like, and they will be accessible
|
15
|
-
# in the templates via {{ site.myvariable }}.
|
16
|
-
title: OpenCensus for Ruby
|
17
|
-
email: your-email@example.com
|
18
|
-
description: A stats collection and distributed tracing framework
|
19
|
-
baseurl: "/opencensus-ruby" # the subpath of your site, e.g. /blog
|
20
|
-
url: "http://opencensus.io" # the base hostname & protocol for your site, e.g. http://example.com
|
21
|
-
github_username: census-instrumentation
|
22
|
-
|
23
|
-
# Build settings
|
24
|
-
markdown: kramdown
|
25
|
-
theme: jekyll-theme-minimal
|
26
|
-
plugins:
|
27
|
-
- jekyll-feed
|
28
|
-
|
29
|
-
# Exclude from processing.
|
30
|
-
# The following items will not be processed, by default. Create a custom list
|
31
|
-
# to override the default setting.
|
32
|
-
# exclude:
|
33
|
-
# - Gemfile
|
34
|
-
# - Gemfile.lock
|
35
|
-
# - node_modules
|
36
|
-
# - vendor/bundle/
|
37
|
-
# - vendor/cache/
|
38
|
-
# - vendor/gems/
|
39
|
-
# - vendor/ruby/
|
data/docs/_layouts/default.html
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
<!doctype html>
|
2
|
-
<html lang="{{ site.lang | default: "en-US" }}">
|
3
|
-
<head>
|
4
|
-
<meta charset="utf-8">
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
6
|
-
|
7
|
-
{% seo %}
|
8
|
-
|
9
|
-
<link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: site.github.build_revision | relative_url }}">
|
10
|
-
<meta name="viewport" content="width=device-width">
|
11
|
-
<!--[if lt IE 9]>
|
12
|
-
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
13
|
-
<![endif]-->
|
14
|
-
</head>
|
15
|
-
<body>
|
16
|
-
<div class="wrapper">
|
17
|
-
<header>
|
18
|
-
<h1>{{ site.title | default: site.github.repository_name }}</h1>
|
19
|
-
<p>{{ site.description | default: site.github.project_tagline }}</p>
|
20
|
-
|
21
|
-
{% if site.github.is_project_page %}
|
22
|
-
<p class="view"><a href="{{ site.github.repository_url }}">View the Project on GitHub <small>{{ github_name }}</small></a></p>
|
23
|
-
{% endif %}
|
24
|
-
<p class="view"><a href="{{ '/api' | relative_url }}">View the API documentation</a>
|
25
|
-
|
26
|
-
{% if site.github.is_user_page %}
|
27
|
-
<p class="view"><a href="{{ site.github.owner_url }}">View My GitHub Profile</a></p>
|
28
|
-
{% endif %}
|
29
|
-
|
30
|
-
{% if site.show_downloads %}
|
31
|
-
<ul>
|
32
|
-
<li><a href="{{ site.github.zip_url }}">Download <strong>ZIP File</strong></a></li>
|
33
|
-
<li><a href="{{ site.github.tar_url }}">Download <strong>TAR Ball</strong></a></li>
|
34
|
-
<li><a href="{{ site.github.repository_url }}">View On <strong>GitHub</strong></a></li>
|
35
|
-
</ul>
|
36
|
-
{% endif %}
|
37
|
-
</header>
|
38
|
-
<section>
|
39
|
-
|
40
|
-
{{ content }}
|
41
|
-
|
42
|
-
</section>
|
43
|
-
<footer>
|
44
|
-
{% if site.github.is_project_page %}
|
45
|
-
<p>This project is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a></p>
|
46
|
-
{% endif %}
|
47
|
-
<p><small>Hosted on GitHub Pages — Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
|
48
|
-
</footer>
|
49
|
-
</div>
|
50
|
-
<script src="{{ '/assets/js/scale.fix.js' | relative_url }}"></script>
|
51
|
-
|
52
|
-
|
53
|
-
{% if site.google_analytics %}
|
54
|
-
<script>
|
55
|
-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
56
|
-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
57
|
-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
58
|
-
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
59
|
-
|
60
|
-
ga('create', '{{ site.google_analytics }}', 'auto');
|
61
|
-
ga('send', 'pageview');
|
62
|
-
</script>
|
63
|
-
{% endif %}
|
64
|
-
</body>
|
65
|
-
</html>
|
data/docs/index.md
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
---
|
2
|
-
layout: default
|
3
|
-
---
|
4
|
-
|
5
|
-
# OpenCensus for Ruby
|
6
|
-
|
7
|
-
OpenCensus provides a framework to measure a server's resource usage and
|
8
|
-
collect performance stats. The `opencensus` Rubygem contains the core
|
9
|
-
OpenCensus APIs and basic integrations with Rails, Faraday, and GRPC.
|
10
|
-
|
11
|
-
The library is in alpha stage, and the API is subject to change.
|
12
|
-
|
13
|
-
## Quick Start
|
14
|
-
|
15
|
-
### Installation
|
16
|
-
|
17
|
-
Install the gem directly:
|
18
|
-
|
19
|
-
```sh
|
20
|
-
$ gem install opencensus
|
21
|
-
```
|
22
|
-
|
23
|
-
Or install through Bundler:
|
24
|
-
|
25
|
-
1. Add the `opencensus` gem to your Gemfile:
|
26
|
-
|
27
|
-
```ruby
|
28
|
-
gem "opencensus"
|
29
|
-
```
|
30
|
-
|
31
|
-
2. Use Bundler to install the gem:
|
32
|
-
|
33
|
-
```sh
|
34
|
-
$ bundle install
|
35
|
-
```
|
36
|
-
|
37
|
-
### Getting started with Ruby on Rails
|
38
|
-
|
39
|
-
The OpenCensus library provides a Railtie that integrates with Ruby On Rails,
|
40
|
-
automatically tracing incoming requests in the application. It also
|
41
|
-
automatically traces key processes in your application such as database queries
|
42
|
-
and view rendering.
|
43
|
-
|
44
|
-
To enable Rails integration, require this file during application startup:
|
45
|
-
|
46
|
-
```ruby
|
47
|
-
# In config/application.rb
|
48
|
-
require "opencensus/trace/integrations/rails"
|
49
|
-
```
|
50
|
-
|
51
|
-
### Getting started with other Rack-based frameworks
|
52
|
-
|
53
|
-
Other Rack-based frameworks, such as Sinatra, can use the Rack Middleware
|
54
|
-
integration, which automatically traces incoming requests. To enable the
|
55
|
-
integration for a non-Rails Rack framework, add the middleware to your
|
56
|
-
middleware stack.
|
57
|
-
|
58
|
-
```ruby
|
59
|
-
# In config.ru or similar Rack configuration file
|
60
|
-
require "opencensus/trace/integrations/rack_middleware"
|
61
|
-
use OpenCensus::Trace::Integrations::RackMiddleware
|
62
|
-
```
|
63
|
-
|
64
|
-
## Instrumentation features
|
65
|
-
|
66
|
-
### Tracing outgoing HTTP requests
|
67
|
-
|
68
|
-
If your app uses the [Faraday](https://github.com/lostisland/faraday) library
|
69
|
-
to make outgoing HTTP requests, consider installing the Faraday Middleware
|
70
|
-
integration. This integration creates a span for each outgoing Faraday request,
|
71
|
-
tracking the latency of that request, and propagates distributed trace headers
|
72
|
-
into the request so you can potentially connect your request trace with that of
|
73
|
-
the remote service. Here is an example:
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
conn = Faraday.new(url: "http://www.example.com") do |c|
|
77
|
-
c.use OpenCensus::Trace::Integrations::FaradayMiddleware
|
78
|
-
c.adapter Faraday.default_adapter
|
79
|
-
end
|
80
|
-
conn.get "/"
|
81
|
-
```
|
82
|
-
|
83
|
-
See the documentation for the
|
84
|
-
[FaradayMiddleware](http://opencensus.io/opencensus-ruby/api/OpenCensus/Trace/Integrations/FaradayMiddleware.html)
|
85
|
-
class for more info.
|
86
|
-
|
87
|
-
### Adding Custom Trace Spans
|
88
|
-
|
89
|
-
In addition to the spans added by the Rails integration (e.g. for database
|
90
|
-
queries) and by Faraday integration for outgoing HTTP requests, you can add
|
91
|
-
additional custom spans to the request trace:
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
OpenCensus::Trace.in_span "my_task" do |span|
|
95
|
-
# Do stuff...
|
96
|
-
|
97
|
-
OpenCensus::Trace.in_span "my_subtask" do |subspan|
|
98
|
-
# Do other stuff
|
99
|
-
end
|
100
|
-
end
|
101
|
-
```
|
102
|
-
|
103
|
-
See the documentation for the
|
104
|
-
[OpenCensus::Trace](http://opencensus.io/opencensus-ruby/api/OpenCensus/Trace.html)
|
105
|
-
module for more info.
|
106
|
-
|
107
|
-
### Exporting traces
|
108
|
-
|
109
|
-
By default, OpenCensus will log request trace data as JSON. To export traces to
|
110
|
-
your favorite analytics backend, install an export plugin. There are plugins
|
111
|
-
currently being developed for Stackdriver, Zipkin, and other services.
|
112
|
-
|
113
|
-
### Configuring the library
|
114
|
-
|
115
|
-
OpenCensus allows configuration of a number of aspects via the configuration
|
116
|
-
class. The following example illustrates how that looks:
|
117
|
-
|
118
|
-
```ruby
|
119
|
-
OpenCensus.configure do |c|
|
120
|
-
c.trace.default_sampler = OpenCensus::Trace::Samplers::AlwaysSample.new
|
121
|
-
c.trace.default_max_attributes = 16
|
122
|
-
end
|
123
|
-
```
|
124
|
-
|
125
|
-
If you are using Rails, you can equivalently use the Rails config:
|
126
|
-
|
127
|
-
```ruby
|
128
|
-
config.opencensus.trace.default_sampler =
|
129
|
-
OpenCensus::Trace::Samplers::AlwaysSample.new
|
130
|
-
config.opencensus.trace.default_max_attributes = 16
|
131
|
-
```
|
132
|
-
|
133
|
-
You can configure a variety of core OpenCensuys options, including:
|
134
|
-
|
135
|
-
* Sampling, which controls how often a request is traced.
|
136
|
-
* Exporting, which controls how trace information is reported.
|
137
|
-
* Formatting, which controls how distributed request trace headers are
|
138
|
-
constructed
|
139
|
-
* Size maximums, which control when trace data is truncated.
|
140
|
-
|
141
|
-
Additionally, integrations and other plugins might have their own
|
142
|
-
configurations.
|
143
|
-
|
144
|
-
For more information, consult the documentation for
|
145
|
-
[OpenCensus.configure](http://opencensus.io/opencensus-ruby/api/OpenCensus.html#configure-class_method)
|
146
|
-
and
|
147
|
-
[OpenCensus::Trace.configure](http://opencensus.io/opencensus-ruby/api/OpenCensus/Trace.html#configure-class_method).
|
148
|
-
|
149
|
-
## Supported Ruby Versions
|
150
|
-
|
151
|
-
This library is supported on Ruby 2.0+.
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Hello World example
|
2
|
-
|
3
|
-
This example application demonstrates how to use OpenCensus to record traces for a Sinatra-based web application.
|
4
|
-
|
5
|
-
## Prerequisites
|
6
|
-
|
7
|
-
Ruby 2.2 or later is required. Make sure you have Bundler installed as well.
|
8
|
-
|
9
|
-
gem install bundler
|
10
|
-
|
11
|
-
## Installation
|
12
|
-
|
13
|
-
Get the example from the OpenCensus Ruby repository on Github, and cd into the example application directory.
|
14
|
-
|
15
|
-
git clone https://github.com/census-instrumentation/opencensus-ruby.git
|
16
|
-
cd opencensus-ruby/examples/hello-world
|
17
|
-
|
18
|
-
Install the dependencies using Bundler.
|
19
|
-
|
20
|
-
bundle install
|
21
|
-
|
22
|
-
## Running the example
|
23
|
-
|
24
|
-
Run the application locally on your workstation with:
|
25
|
-
|
26
|
-
bundle exec ruby hello.rb
|
27
|
-
|
28
|
-
This will run on port 4567 by default, and display application logs on the terminal. From a separate shell, you can send requests using a tool such as curl:
|
29
|
-
|
30
|
-
curl http://localhost:4567/
|
31
|
-
curl http://localhost:4567/lengthy
|
32
|
-
|
33
|
-
The running application will log the captured traces.
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# Copyright 2018 OpenCensus Authors
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
|
16
|
-
# This is a simple Sinatra application demonstrating how to record traces
|
17
|
-
# using OpenCensus.
|
18
|
-
#
|
19
|
-
# It uses the OpenCensus Rack middleware to trace all incoming requests. It
|
20
|
-
# also demonstrates how to use the Faraday middleware to trace outgoing HTTP
|
21
|
-
# requests, as well as how to instrument your code to capture custom spans.
|
22
|
-
#
|
23
|
-
# By default, the resulting trace data is logged in JSON format. You can also
|
24
|
-
# configure OpenCensus to report traces to a backend such as Stackdriver or
|
25
|
-
# Zipkin using an exporter plugin library.
|
26
|
-
|
27
|
-
require "sinatra"
|
28
|
-
|
29
|
-
# Install the Rack middleware to trace incoming requests.
|
30
|
-
require "opencensus/trace/integrations/rack_middleware"
|
31
|
-
use OpenCensus::Trace::Integrations::RackMiddleware
|
32
|
-
|
33
|
-
# Access the Faraday middleware which will be used to trace outgoing HTTP
|
34
|
-
# requests.
|
35
|
-
require "opencensus/trace/integrations/faraday_middleware"
|
36
|
-
|
37
|
-
# Each request will be traced automatically by the middleware.
|
38
|
-
get "/" do
|
39
|
-
"Hello world!"
|
40
|
-
end
|
41
|
-
|
42
|
-
# Traces for this request will also include sub-spans as indicated below.
|
43
|
-
get "/lengthy" do
|
44
|
-
# Configure this Faraday connection with a middleware to trace outgoing
|
45
|
-
# requests.
|
46
|
-
conn = Faraday.new(url: "http://www.google.com") do |c|
|
47
|
-
c.use OpenCensus::Trace::Integrations::FaradayMiddleware
|
48
|
-
c.adapter Faraday.default_adapter
|
49
|
-
end
|
50
|
-
conn.get "/"
|
51
|
-
|
52
|
-
# You may instrument your code to create custom spans for long-running
|
53
|
-
# operations.
|
54
|
-
OpenCensus::Trace.in_span "long task" do
|
55
|
-
sleep rand
|
56
|
-
end
|
57
|
-
|
58
|
-
"Done!"
|
59
|
-
end
|
data/opencensus.gemspec
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "opencensus/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "opencensus"
|
8
|
-
spec.version = OpenCensus::VERSION
|
9
|
-
spec.authors = ["Jeff Ching", "Daniel Azuma"]
|
10
|
-
spec.email = ["chingor@google.com", "dazuma@google.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{A stats collection and distributed tracing framework}
|
13
|
-
spec.description = %q{A stats collection and distributed tracing framework}
|
14
|
-
spec.homepage = "https://github.com/census-instrumentation/opencensus-ruby"
|
15
|
-
spec.license = "Apache-2.0"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
-
f.match(%r{^(test|spec|features)/})
|
19
|
-
end
|
20
|
-
spec.bindir = "exe"
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"]
|
23
|
-
|
24
|
-
spec.required_ruby_version = ">= 2.2.0"
|
25
|
-
|
26
|
-
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
28
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
-
spec.add_development_dependency "minitest-focus", "~> 1.1"
|
30
|
-
spec.add_development_dependency "faraday", "~> 0.13"
|
31
|
-
spec.add_development_dependency "rails", "~> 5.1.4"
|
32
|
-
spec.add_development_dependency "rubocop", "~> 0.52"
|
33
|
-
spec.add_development_dependency "yard", "~> 0.9"
|
34
|
-
spec.add_development_dependency "yard-doctest", "~> 0.1.6"
|
35
|
-
end
|