Embed opentracing 0.4.3
This commit is contained in:
parent
f7791ef5ea
commit
e027f55b03
21 changed files with 976 additions and 0 deletions
16
debian/gems-compat/opentracing-0.4.3/.codeclimate.yml
vendored
Normal file
16
debian/gems-compat/opentracing-0.4.3/.codeclimate.yml
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
engines:
|
||||
duplication:
|
||||
enabled: true
|
||||
config:
|
||||
languages:
|
||||
- ruby
|
||||
fixme:
|
||||
enabled: true
|
||||
rubocop:
|
||||
enabled: true
|
||||
ratings:
|
||||
paths:
|
||||
- "**.rb"
|
||||
exclude_paths:
|
||||
- test/
|
50
debian/gems-compat/opentracing-0.4.3/.gitignore
vendored
Normal file
50
debian/gems-compat/opentracing-0.4.3/.gitignore
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
*.gem
|
||||
*.rbc
|
||||
/.config
|
||||
/coverage/
|
||||
/InstalledFiles
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/spec/examples.txt
|
||||
/test/tmp/
|
||||
/test/version_tmp/
|
||||
/tmp/
|
||||
|
||||
# Used by dotenv library to load environment variables.
|
||||
# .env
|
||||
|
||||
## Specific to RubyMotion:
|
||||
.dat*
|
||||
.repl_history
|
||||
build/
|
||||
*.bridgesupport
|
||||
build-iPhoneOS/
|
||||
build-iPhoneSimulator/
|
||||
|
||||
## Specific to RubyMotion (use of CocoaPods):
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# vendor/Pods/
|
||||
|
||||
## Documentation cache and generated files:
|
||||
/.yardoc/
|
||||
/_yardoc/
|
||||
/doc/
|
||||
/rdoc/
|
||||
|
||||
## Environment normalization:
|
||||
/.bundle/
|
||||
/vendor/bundle
|
||||
/lib/bundler/man/
|
||||
|
||||
# for a library or gem, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
Gemfile.lock
|
||||
# .ruby-version
|
||||
# .ruby-gemset
|
||||
|
||||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||
.rvmrc
|
8
debian/gems-compat/opentracing-0.4.3/.rubocop.yml
vendored
Normal file
8
debian/gems-compat/opentracing-0.4.3/.rubocop.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
Lint/UnusedMethodArgument:
|
||||
Enabled: no
|
||||
|
||||
Metrics/LineLength:
|
||||
Max: 120
|
||||
|
||||
Metrics/ParameterLists:
|
||||
Enabled: no
|
8
debian/gems-compat/opentracing-0.4.3/.travis.yml
vendored
Normal file
8
debian/gems-compat/opentracing-0.4.3/.travis.yml
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
sudo: false
|
||||
language: ruby
|
||||
rvm:
|
||||
- 2.3.4
|
||||
- 2.4.1
|
||||
- jruby-9.1.8.0
|
||||
before_install: gem install bundler -v 1.13.6
|
||||
script: JRUBY_OPTS="--debug" bundle exec rake
|
30
debian/gems-compat/opentracing-0.4.3/CHANGELOG.md
vendored
Normal file
30
debian/gems-compat/opentracing-0.4.3/CHANGELOG.md
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
# Changelog
|
||||
|
||||
## 0.4.3
|
||||
|
||||
* Specify versions for development dependencies ([#40](https://github.com/opentracing/opentracing-ruby/pull/40))
|
||||
|
||||
## 0.4.2
|
||||
|
||||
* Update opentracing.io links and scheme on README ([#38](https://github.com/opentracing/opentracing-ruby/pull/38))
|
||||
|
||||
* Add active_span method to Tracer ([#34](https://github.com/opentracing/opentracing-ruby/pull/34))
|
||||
|
||||
## 0.4.1
|
||||
|
||||
* Add active_span convenience method to OpenTracing module ([#30](https://github.com/opentracing/opentracing-ruby/pull/30))
|
||||
* Fix global tracer delegators ([#28](https://github.com/opentracing/opentracing-ruby/pull/28))
|
||||
* Add Rubocop ([#29](https://github.com/opentracing/opentracing-ruby/pull/27))
|
||||
* Update license from MIT => Apache 2.0 ([#26](https://github.com/opentracing/opentracing-ruby/pull/26))
|
||||
|
||||
## 0.4.0
|
||||
|
||||
* The tracer now implements the OpenTracing Scope API for in-process scope propagation([#21](https://github.com/opentracing/opentracing-ruby/pull/21))
|
||||
* Adds a `log_kv` method and deprecates `log` for consistency with other language implementations. See [#22](https://github.com/opentracing/opentracing-ruby/pull/23).
|
||||
|
||||
## 0.3.2
|
||||
|
||||
* Addressing Ruby style issues ([#14](https://github.com/opentracing/opentracing-ruby/pull/14))
|
||||
* Default to the no-op tracer ([#17](https://github.com/opentracing/opentracing-ruby/pull/17))
|
||||
* Fixing serialization example in README ([#18](https://github.com/opentracing/opentracing-ruby/pull/18))
|
||||
* Removing bundler development version requirement
|
4
debian/gems-compat/opentracing-0.4.3/Gemfile
vendored
Normal file
4
debian/gems-compat/opentracing-0.4.3/Gemfile
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
# Specify your gem's dependencies in opentracing.gemspec
|
||||
gemspec
|
201
debian/gems-compat/opentracing-0.4.3/LICENSE
vendored
Normal file
201
debian/gems-compat/opentracing-0.4.3/LICENSE
vendored
Normal file
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright The OpenTracing Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
198
debian/gems-compat/opentracing-0.4.3/README.md
vendored
Normal file
198
debian/gems-compat/opentracing-0.4.3/README.md
vendored
Normal file
|
@ -0,0 +1,198 @@
|
|||
# OpenTracing API for Ruby
|
||||
|
||||
[![Build Status](https://travis-ci.org/ngauthier/opentracing-ruby.svg?branch=master)](https://travis-ci.org/ngauthier/opentracing-ruby) [![Code Climate](https://codeclimate.com/github/ngauthier/opentracing-ruby/badges/gpa.svg)](https://codeclimate.com/github/ngauthier/opentracing-ruby) [![Test Coverage](https://codeclimate.com/github/ngauthier/opentracing-ruby/badges/coverage.svg)](https://codeclimate.com/github/ngauthier/opentracing-ruby/coverage)
|
||||
|
||||
This package is a Ruby platform API for OpenTracing.
|
||||
|
||||
## Required Reading
|
||||
|
||||
In order to understand the Ruby platform API, one must first be familiar with the
|
||||
[OpenTracing project](https://opentracing.io) and
|
||||
[terminology](https://opentracing.io/docs/overview/) more specifically.
|
||||
|
||||
## Installation
|
||||
|
||||
Add this line to your application's Gemfile:
|
||||
|
||||
```ruby
|
||||
gem 'opentracing'
|
||||
```
|
||||
|
||||
And then execute:
|
||||
|
||||
$ bundle
|
||||
|
||||
Or install it yourself as:
|
||||
|
||||
$ gem install opentracing
|
||||
|
||||
`opentracing` supports Ruby 2.0+.
|
||||
|
||||
## Usage
|
||||
|
||||
Everyday consumers of this `opentracing` gem really only need to worry
|
||||
about a couple of key abstractions: the `start_active_span` and `start_span`
|
||||
methods, the `Span` and `ScopeManager` interfaces, and binding a `Tracer`
|
||||
at runtime. Here are code snippets demonstrating some important use cases.
|
||||
|
||||
### Singleton initialization
|
||||
|
||||
As early as possible, call
|
||||
|
||||
```ruby
|
||||
require 'opentracing'
|
||||
OpenTracing.global_tracer = MyTracerImplementation.new(...)
|
||||
```
|
||||
|
||||
Where `MyTracerImplementation` is your tracer. For testing, you can use
|
||||
the provided `OpenTracing::Tracer`
|
||||
|
||||
### Non-Singleton initialization
|
||||
|
||||
If you prefer direct control to singletons, manage ownership of the
|
||||
`Tracer` implementation explicitly.
|
||||
|
||||
### Scopes and within-process propagation
|
||||
|
||||
For any thread, at most one `Span` may be "active". Of course there may be many
|
||||
other `Spans` involved with the thread which are (a) started, (b) not finished,
|
||||
and yet (c) not "active": perhaps they are waiting for I/O, blocked on a child
|
||||
`Span`, or otherwise off of the critical path.
|
||||
|
||||
It's inconvenient to pass an active `Span` from function to function manually,
|
||||
so OpenTracing requires that every `Tracer` contains a `ScopeManager` that
|
||||
grants access to the active `Span` through a `Scope`. Any `Span` may be
|
||||
transferred to another callback or thread, but not `Scope`.
|
||||
|
||||
#### Accessing the active Span through Scope
|
||||
|
||||
```ruby
|
||||
# Access to the active span is straightforward.
|
||||
|
||||
span = OpenTracing.active_span
|
||||
if span
|
||||
span.set_tag('...', '...')
|
||||
end
|
||||
|
||||
# or
|
||||
|
||||
scope = OpenTracing.scope_manager.active
|
||||
if scope
|
||||
scope.span.set_tag('...', '...')
|
||||
end
|
||||
```
|
||||
|
||||
### Starting a new Span
|
||||
|
||||
The common case starts a `Scope` that's automatically registered for
|
||||
intra-process propagation via `ScopeManager`.
|
||||
|
||||
Note that `start_active_span('...')` automatically finishes the span on
|
||||
`Scope#close` (`start_active_span('...', finish_on_close: false)` does not
|
||||
finish it, in contrast).
|
||||
|
||||
```ruby
|
||||
# Automatic activation of the Span.
|
||||
# By default the active span will be finished when the returned scope is closed.
|
||||
# This can be controlled by passing finish_on_close parameter to
|
||||
# start_active_span
|
||||
scope = OpenTracing.start_active_span('operation_name')
|
||||
# Do things.
|
||||
|
||||
# Block form of start_active_span
|
||||
# start_active_span optionally accepts a block. If a block is passed to
|
||||
# start_active_span it will yield the newly created scope. The scope will
|
||||
# be closed and its associated span will be finished unless
|
||||
# finish_on_close: false is passed to start_active_span.
|
||||
OpenTracing.start_active_span('operation_name') do |scope|
|
||||
# Do things.
|
||||
end
|
||||
|
||||
# Manual activation of the Span.
|
||||
# Spans can be managed manually. This is equivalent to the more concise examples
|
||||
# above.
|
||||
span = OpenTracing.start_span('operation_name')
|
||||
OpenTracing.scope_manager.activate(span)
|
||||
scope = OpenTracing.scope_manager.active
|
||||
# Do things.
|
||||
|
||||
# If there is an active Scope, it will act as the parent to any newly started
|
||||
# Span unless ignore_active_scope: true is passed to start_span or
|
||||
# start_active_span.
|
||||
|
||||
# create a root span, ignoring the currently active scope (if it's set)
|
||||
scope = OpenTracing.start_active_span('operation_name', ignore_active_scope: true)
|
||||
|
||||
# or
|
||||
span = OpenTracing.start_span('operation_name', ignore_active_scope: true)
|
||||
|
||||
# It's possible to create a child Span given an existing parent Span by
|
||||
# using the child_of option.
|
||||
|
||||
parent_scope = OpenTracing.start_active_span('parent_operation, ignore_active_scope: true)
|
||||
child_scope = OpenTracing.start_active_span('child_operation', child_of: parent_scope.span)
|
||||
|
||||
# or
|
||||
parent_span = OpenTracing.start_span('parent_operation', ignore_active_scope: true)
|
||||
child_span = OpenTracing.start_span('child_operation', child_of: parent_span)
|
||||
|
||||
```
|
||||
|
||||
### Serializing to the wire
|
||||
|
||||
Using `Net::HTTP`:
|
||||
```ruby
|
||||
client = Net::HTTP.new("myservice.com")
|
||||
req = Net::HTTP::Post.new("/")
|
||||
|
||||
span = OpenTracing.start_span("my_span")
|
||||
OpenTracing.inject(span.context, OpenTracing::FORMAT_RACK, req)
|
||||
res = client.request(req)
|
||||
#...
|
||||
```
|
||||
|
||||
Using Faraday middleware:
|
||||
```ruby
|
||||
class TraceMiddleware < Faraday::Middleware
|
||||
def call(env)
|
||||
span = OpenTracing.start_span("my_span")
|
||||
OpenTracing.inject(span.context, OpenTracing::FORMAT_RACK, env)
|
||||
@app.call(env).on_complete do
|
||||
span.finish
|
||||
end
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
### Deserializing from the wire
|
||||
|
||||
The OpenTracing Ruby gem provides a specific Rack header extraction format,
|
||||
since most Ruby web servers get their HTTP Headers from Rack. Keep in mind that
|
||||
Rack automatically uppercases all headers and replaces dashes with underscores.
|
||||
This means that if you use dashes and underscores and case-sensitive baggage,
|
||||
it will not be possible to discern once Rack has processed it.
|
||||
|
||||
```ruby
|
||||
class MyRackApp
|
||||
def call(env)
|
||||
extracted_ctx = @tracer.extract(OpenTracing::FORMAT_RACK, env)
|
||||
span = @tracer.start_span("my_app", child_of: extracted_ctx)
|
||||
span.finish
|
||||
[200, {}, ["hello"]]
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
||||
|
||||
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
||||
|
||||
## Contributing
|
||||
|
||||
Bug reports and pull requests are welcome on GitHub at https://github.com/opentracing/opentracing-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
||||
|
||||
## Licensing
|
||||
|
||||
[Apache 2.0 License](./LICENSE).
|
17
debian/gems-compat/opentracing-0.4.3/Rakefile
vendored
Normal file
17
debian/gems-compat/opentracing-0.4.3/Rakefile
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
require 'bundler/gem_tasks'
|
||||
require 'rake/testtask'
|
||||
require 'rubocop/rake_task'
|
||||
|
||||
Rake::TestTask.new(:test) do |t|
|
||||
t.libs << 'test'
|
||||
t.libs << 'lib'
|
||||
t.test_files = FileList['test/**/*_test.rb']
|
||||
end
|
||||
|
||||
RuboCop::RakeTask.new(:rubocop)
|
||||
|
||||
if RUBY_PLATFORM == 'java'
|
||||
task default: :test
|
||||
else
|
||||
task default: %i[rubocop test]
|
||||
end
|
6
debian/gems-compat/opentracing-0.4.3/bin/console
vendored
Executable file
6
debian/gems-compat/opentracing-0.4.3/bin/console
vendored
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'bundler/setup'
|
||||
require 'opentracing'
|
||||
require 'irb'
|
||||
IRB.start
|
6
debian/gems-compat/opentracing-0.4.3/bin/setup
vendored
Executable file
6
debian/gems-compat/opentracing-0.4.3/bin/setup
vendored
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
set -vx
|
||||
|
||||
bundle install
|
45
debian/gems-compat/opentracing-0.4.3/lib/opentracing.rb
vendored
Normal file
45
debian/gems-compat/opentracing-0.4.3/lib/opentracing.rb
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
require 'forwardable'
|
||||
require 'opentracing/version'
|
||||
require 'opentracing/span_context'
|
||||
require 'opentracing/span'
|
||||
require 'opentracing/reference'
|
||||
require 'opentracing/tracer'
|
||||
require 'opentracing/scope'
|
||||
require 'opentracing/scope_manager'
|
||||
|
||||
#:nodoc:
|
||||
module OpenTracing
|
||||
# Text format for Tracer#inject and Tracer#extract.
|
||||
#
|
||||
# The carrier for FORMAT_TEXT_MAP should be a Hash with string values.
|
||||
FORMAT_TEXT_MAP = 1
|
||||
|
||||
# Binary format for #inject and #extract
|
||||
#
|
||||
# The carrier for FORMAT_BINARY should be a string, treated as a raw sequence
|
||||
# of bytes.
|
||||
FORMAT_BINARY = 2
|
||||
|
||||
# Due to Rack's popularity within the Ruby community, OpenTracing-Ruby
|
||||
# provides a Rack-specific format for injection into and extraction from HTTP
|
||||
# headers specifically, though there are some strings attached.
|
||||
#
|
||||
# The carrier for FORMAT_RACK should be `env` or equivalent. It behaves like
|
||||
# FORMAT_TEXT_MAP, but with all keys transformed per Rack's treatment of HTTP
|
||||
# headers. Keep in mind that Rack automatically uppercases all headers and
|
||||
# replaces dashes with underscores. This means that if you use dashes and
|
||||
# underscores and case-sensitive baggage keys, they may collide or become
|
||||
# unrecognizable.
|
||||
FORMAT_RACK = 3
|
||||
|
||||
class << self
|
||||
extend Forwardable
|
||||
# Global tracer to be used when OpenTracing.start_span, inject or extract is called
|
||||
attr_accessor :global_tracer
|
||||
def_delegators :global_tracer, :scope_manager, :start_active_span,
|
||||
:start_span, :inject, :extract, :active_span
|
||||
end
|
||||
end
|
||||
|
||||
# Default to the no-op tracer
|
||||
OpenTracing.global_tracer = OpenTracing::Tracer.new
|
22
debian/gems-compat/opentracing-0.4.3/lib/opentracing/carrier.rb
vendored
Normal file
22
debian/gems-compat/opentracing-0.4.3/lib/opentracing/carrier.rb
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
module OpenTracing
|
||||
# Carriers are used for inject and extract operations. A carrier should be a
|
||||
# Hash or hash-like object. At a minimum, it should implement `[]`, `[]=`, and
|
||||
# `each` shown here.
|
||||
class Carrier
|
||||
# [] retrieves a value by the given key
|
||||
# @param key [String] key to retrieve the value
|
||||
# @return [String] the desired value
|
||||
def [](key); end
|
||||
|
||||
# []= sets the value for the given key
|
||||
# @param key [String] key to set
|
||||
# @param value [String] value to set
|
||||
def []=(key, value); end
|
||||
|
||||
# each iterates over every key-value pair in the carrier
|
||||
# @yield [key, value]
|
||||
# @yieldparam key [String] the key of the tuple
|
||||
# @yieldparam value [String] the value of the tuple
|
||||
def each(&block); end
|
||||
end
|
||||
end
|
79
debian/gems-compat/opentracing-0.4.3/lib/opentracing/reference.rb
vendored
Normal file
79
debian/gems-compat/opentracing-0.4.3/lib/opentracing/reference.rb
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
module OpenTracing
|
||||
#:nodoc:
|
||||
class Reference
|
||||
CHILD_OF = 'child_of'.freeze
|
||||
FOLLOWS_FROM = 'follows_from'.freeze
|
||||
|
||||
# @param context [SpanContext, Span] child_of context refers to a
|
||||
# parent Span that caused *and* somehow depends upon the new child Span.
|
||||
# Often (but not always), the parent Span cannot finish until the child
|
||||
# Span does.
|
||||
#
|
||||
# An timing diagram for a child Span that is blocked on the new Span:
|
||||
#
|
||||
# [-Parent Span----------]
|
||||
# [-Child Span----]
|
||||
#
|
||||
# See http://opentracing.io/documentation/pages/spec
|
||||
#
|
||||
# @return [Reference] a ChildOf reference
|
||||
#
|
||||
# @example
|
||||
# root_span = OpenTracing.start_span('root operation')
|
||||
# child_span = OpenTracing.start_span('child operation', references: [
|
||||
# OpenTracing::Reference.child_of(root_span)
|
||||
# ])
|
||||
#
|
||||
def self.child_of(context)
|
||||
context = context.context if context.is_a?(Span)
|
||||
Reference.new(CHILD_OF, context)
|
||||
end
|
||||
|
||||
# @param context [SpanContext, Span] follows_from context refers to a
|
||||
# parent Span that does not depend in any way on the result of the new
|
||||
# child Span. For instance, one might use FollowsFrom Span to describe
|
||||
# pipeline stages separated by queues, or a fire-and-forget cache insert
|
||||
# at the tail end of a web request.
|
||||
#
|
||||
# A FollowsFrom Span is part of the same logical trace as the new Span:
|
||||
# i.e., the new Span is somehow caused by the work of its FollowsFrom
|
||||
# Span.
|
||||
#
|
||||
# All of the following could be valid timing diagrams for children that
|
||||
# "FollowFrom" a parent:
|
||||
#
|
||||
# [-Parent Span--] [-Child Span-]
|
||||
#
|
||||
# [-Parent Span--]
|
||||
# [-Child Span-]
|
||||
#
|
||||
# [-Parent Span-]
|
||||
# [-Child Span-]
|
||||
#
|
||||
# See http://opentracing.io/documentation/pages/spec
|
||||
#
|
||||
# @return [Reference] a FollowsFrom reference
|
||||
#
|
||||
# @example
|
||||
# context = OpenTracing.extract(OpenTracing::FORMAT_RACK, rack_env)
|
||||
# span = OpenTracing.start_span('following operation', references: [
|
||||
# OpenTracing::Reference.follows_from(context)
|
||||
# ])
|
||||
#
|
||||
def self.follows_from(context)
|
||||
context = context.context if context.is_a?(Span)
|
||||
Reference.new(FOLLOWS_FROM, context)
|
||||
end
|
||||
|
||||
def initialize(type, context)
|
||||
@type = type
|
||||
@context = context
|
||||
end
|
||||
|
||||
# @return [String] reference type
|
||||
attr_reader :type
|
||||
|
||||
# @return [SpanContext] the context of a span this reference is referencing
|
||||
attr_reader :context
|
||||
end
|
||||
end
|
22
debian/gems-compat/opentracing-0.4.3/lib/opentracing/scope.rb
vendored
Normal file
22
debian/gems-compat/opentracing-0.4.3/lib/opentracing/scope.rb
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
module OpenTracing
|
||||
# Scope represents an OpenTracing Scope
|
||||
#
|
||||
# See http://www.opentracing.io for more information.
|
||||
class Scope
|
||||
NOOP_INSTANCE = Scope.new.freeze
|
||||
|
||||
# Return the Span scoped by this Scope
|
||||
#
|
||||
# @return [Span]
|
||||
def span
|
||||
Span::NOOP_INSTANCE
|
||||
end
|
||||
|
||||
# Mark the end of the active period for the current thread and Scope,
|
||||
# updating the ScopeManager#active in the process.
|
||||
#
|
||||
# NOTE: Calling close more than once on a single Scope instance leads to
|
||||
# undefined behavior.
|
||||
def close; end
|
||||
end
|
||||
end
|
35
debian/gems-compat/opentracing-0.4.3/lib/opentracing/scope_manager.rb
vendored
Normal file
35
debian/gems-compat/opentracing-0.4.3/lib/opentracing/scope_manager.rb
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
module OpenTracing
|
||||
# ScopeManager represents an OpenTracing ScopeManager
|
||||
#
|
||||
# See http://www.opentracing.io for more information.
|
||||
#
|
||||
# The ScopeManager interface abstracts both the activation of Span instances
|
||||
# via ScopeManager#activate and access to an active Span/Scope via
|
||||
# ScopeManager#active
|
||||
#
|
||||
class ScopeManager
|
||||
NOOP_INSTANCE = ScopeManager.new.freeze
|
||||
|
||||
# Make a span instance active.
|
||||
#
|
||||
# @param span [Span] the Span that should become active
|
||||
# @param finish_on_close [Boolean] whether the Span should automatically be
|
||||
# finished when Scope#close is called
|
||||
# @return [Scope] instance to control the end of the active period for the
|
||||
# Span. It is a programming error to neglect to call Scope#close on the
|
||||
# returned instance.
|
||||
def activate(span, finish_on_close: true)
|
||||
Scope::NOOP_INSTANCE
|
||||
end
|
||||
|
||||
# @return [Scope] the currently active Scope which can be used to access the
|
||||
# currently active Span.
|
||||
#
|
||||
# If there is a non-null Scope, its wrapped Span becomes an implicit parent
|
||||
# (as Reference#CHILD_OF) of any newly-created Span at Tracer#start_active_span
|
||||
# or Tracer#start_span time.
|
||||
def active
|
||||
Scope::NOOP_INSTANCE
|
||||
end
|
||||
end
|
||||
end
|
68
debian/gems-compat/opentracing-0.4.3/lib/opentracing/span.rb
vendored
Normal file
68
debian/gems-compat/opentracing-0.4.3/lib/opentracing/span.rb
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
module OpenTracing
|
||||
# Span represents an OpenTracing Span
|
||||
#
|
||||
# See http://www.opentracing.io for more information.
|
||||
class Span
|
||||
NOOP_INSTANCE = Span.new.freeze
|
||||
|
||||
# Set the name of the operation
|
||||
#
|
||||
# @param [String] name
|
||||
def operation_name=(name); end
|
||||
|
||||
# Span Context
|
||||
#
|
||||
# @return [SpanContext]
|
||||
def context
|
||||
SpanContext::NOOP_INSTANCE
|
||||
end
|
||||
|
||||
# Set a tag value on this span
|
||||
# @param key [String] the key of the tag
|
||||
# @param value [String, Numeric, Boolean] the value of the tag. If it's not
|
||||
# a String, Numeric, or Boolean it will be encoded with to_s
|
||||
def set_tag(key, value)
|
||||
self
|
||||
end
|
||||
|
||||
# Set a baggage item on the span
|
||||
# @param key [String] the key of the baggage item
|
||||
# @param value [String] the value of the baggage item
|
||||
def set_baggage_item(key, value)
|
||||
self
|
||||
end
|
||||
|
||||
# Get a baggage item
|
||||
# @param key [String] the key of the baggage item
|
||||
# @return [String] value of the baggage item
|
||||
def get_baggage_item(key)
|
||||
nil
|
||||
end
|
||||
|
||||
# @deprecated Use {#log_kv} instead.
|
||||
# Reason: event is an optional standard log field defined in spec and not required. Also,
|
||||
# method name {#log_kv} is more consistent with other language implementations such as Python and Go.
|
||||
#
|
||||
# Add a log entry to this span
|
||||
# @param event [String] event name for the log
|
||||
# @param timestamp [Time] time of the log
|
||||
# @param fields [Hash] Additional information to log
|
||||
def log(event: nil, timestamp: Time.now, **fields)
|
||||
warn 'Span#log is deprecated. Please use Span#log_kv instead.'
|
||||
nil
|
||||
end
|
||||
|
||||
# Add a log entry to this span
|
||||
# @param timestamp [Time] time of the log
|
||||
# @param fields [Hash] Additional information to log
|
||||
def log_kv(timestamp: Time.now, **fields)
|
||||
nil
|
||||
end
|
||||
|
||||
# Finish the {Span}
|
||||
# @param end_time [Time] custom end time, if not now
|
||||
def finish(end_time: Time.now)
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
14
debian/gems-compat/opentracing-0.4.3/lib/opentracing/span_context.rb
vendored
Normal file
14
debian/gems-compat/opentracing-0.4.3/lib/opentracing/span_context.rb
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
module OpenTracing
|
||||
# SpanContext holds the data for a span that gets inherited to child spans
|
||||
class SpanContext
|
||||
NOOP_INSTANCE = SpanContext.new.freeze
|
||||
|
||||
attr_reader :baggage
|
||||
|
||||
# Create a new SpanContext
|
||||
# @param id the ID of the Context
|
||||
# @param trace_id the ID of the current trace
|
||||
# @param baggage baggage
|
||||
def initialize(baggage: {}); end
|
||||
end
|
||||
end
|
117
debian/gems-compat/opentracing-0.4.3/lib/opentracing/tracer.rb
vendored
Normal file
117
debian/gems-compat/opentracing-0.4.3/lib/opentracing/tracer.rb
vendored
Normal file
|
@ -0,0 +1,117 @@
|
|||
module OpenTracing
|
||||
# Tracer is the entry point API between instrumentation code and the tracing
|
||||
# implementation.
|
||||
#
|
||||
# This implementation both defines the public Tracer API, and provides a
|
||||
# default no-op behavior.
|
||||
#
|
||||
class Tracer
|
||||
# @return [ScopeManager] the current ScopeManager, which may be a no-op but
|
||||
# may not be nil.
|
||||
def scope_manager
|
||||
ScopeManager::NOOP_INSTANCE
|
||||
end
|
||||
|
||||
# @return [Span, nil] the active span. This is a shorthand for
|
||||
# `scope_manager.active.span`, and nil will be returned if
|
||||
# Scope#active is nil.
|
||||
def active_span
|
||||
scope = scope_manager.active
|
||||
scope.span if scope
|
||||
end
|
||||
|
||||
# Returns a newly started and activated Scope.
|
||||
#
|
||||
# If the Tracer's ScopeManager#active is not nil, no explicit references
|
||||
# are provided, and `ignore_active_scope` is false, then an inferred
|
||||
# References#CHILD_OF reference is created to the ScopeManager#active's
|
||||
# SpanContext when start_active is invoked.
|
||||
#
|
||||
# @param operation_name [String] The operation name for the Span
|
||||
# @param child_of [SpanContext, Span] SpanContext that acts as a parent to
|
||||
# the newly-started Span. If a Span instance is provided, its
|
||||
# context is automatically substituted. See [Reference] for more
|
||||
# information.
|
||||
#
|
||||
# If specified, the `references` parameter must be omitted.
|
||||
# @param references [Array<Reference>] An array of reference
|
||||
# objects that identify one or more parent SpanContexts.
|
||||
# @param start_time [Time] When the Span started, if not now
|
||||
# @param tags [Hash] Tags to assign to the Span at start time
|
||||
# @param ignore_active_scope [Boolean] whether to create an implicit
|
||||
# References#CHILD_OF reference to the ScopeManager#active.
|
||||
# @param finish_on_close [Boolean] whether span should automatically be
|
||||
# finished when Scope#close is called
|
||||
# @yield [Scope] If an optional block is passed to start_active it will
|
||||
# yield the newly-started Scope. If `finish_on_close` is true then the
|
||||
# Span will be finished automatically after the block is executed.
|
||||
# @return [Scope] The newly-started and activated Scope
|
||||
def start_active_span(operation_name,
|
||||
child_of: nil,
|
||||
references: nil,
|
||||
start_time: Time.now,
|
||||
tags: nil,
|
||||
ignore_active_scope: false,
|
||||
finish_on_close: true)
|
||||
Scope::NOOP_INSTANCE.tap do |scope|
|
||||
yield scope if block_given?
|
||||
end
|
||||
end
|
||||
|
||||
# Like #start_active_span, but the returned Span has not been registered via the
|
||||
# ScopeManager.
|
||||
#
|
||||
# @param operation_name [String] The operation name for the Span
|
||||
# @param child_of [SpanContext, Span] SpanContext that acts as a parent to
|
||||
# the newly-started Span. If a Span instance is provided, its
|
||||
# context is automatically substituted. See [Reference] for more
|
||||
# information.
|
||||
#
|
||||
# If specified, the `references` parameter must be omitted.
|
||||
# @param references [Array<Reference>] An array of reference
|
||||
# objects that identify one or more parent SpanContexts.
|
||||
# @param start_time [Time] When the Span started, if not now
|
||||
# @param tags [Hash] Tags to assign to the Span at start time
|
||||
# @param ignore_active_scope [Boolean] whether to create an implicit
|
||||
# References#CHILD_OF reference to the ScopeManager#active.
|
||||
# @return [Span] the newly-started Span instance, which has not been
|
||||
# automatically registered via the ScopeManager
|
||||
def start_span(operation_name,
|
||||
child_of: nil,
|
||||
references: nil,
|
||||
start_time: Time.now,
|
||||
tags: nil,
|
||||
ignore_active_scope: false)
|
||||
Span::NOOP_INSTANCE
|
||||
end
|
||||
|
||||
# Inject a SpanContext into the given carrier
|
||||
#
|
||||
# @param span_context [SpanContext]
|
||||
# @param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK]
|
||||
# @param carrier [Carrier] A carrier object of the type dictated by the specified `format`
|
||||
def inject(span_context, format, carrier)
|
||||
case format
|
||||
when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK
|
||||
return nil
|
||||
else
|
||||
warn 'Unknown inject format'
|
||||
end
|
||||
end
|
||||
|
||||
# Extract a SpanContext in the given format from the given carrier.
|
||||
#
|
||||
# @param format [OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK]
|
||||
# @param carrier [Carrier] A carrier object of the type dictated by the specified `format`
|
||||
# @return [SpanContext, nil] the extracted SpanContext or nil if none could be found
|
||||
def extract(format, carrier)
|
||||
case format
|
||||
when OpenTracing::FORMAT_TEXT_MAP, OpenTracing::FORMAT_BINARY, OpenTracing::FORMAT_RACK
|
||||
return SpanContext::NOOP_INSTANCE
|
||||
else
|
||||
warn 'Unknown extract format'
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
3
debian/gems-compat/opentracing-0.4.3/lib/opentracing/version.rb
vendored
Normal file
3
debian/gems-compat/opentracing-0.4.3/lib/opentracing/version.rb
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
module OpenTracing
|
||||
VERSION = '0.4.3'.freeze
|
||||
end
|
27
debian/gems-compat/opentracing-0.4.3/opentracing.gemspec
vendored
Normal file
27
debian/gems-compat/opentracing-0.4.3/opentracing.gemspec
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
lib = File.expand_path('lib', __dir__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require 'opentracing/version'
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = 'opentracing'
|
||||
spec.version = OpenTracing::VERSION
|
||||
spec.authors = %w[ngauthier bcronin bensigelman]
|
||||
spec.email = ['info@opentracing.io']
|
||||
|
||||
spec.summary = 'OpenTracing Ruby Platform API'
|
||||
spec.homepage = 'https://github.com/opentracing/opentracing-ruby'
|
||||
spec.license = 'Apache-2.0'
|
||||
|
||||
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
||||
f.match(%r{^(test|spec|features)/})
|
||||
end
|
||||
spec.bindir = 'exe'
|
||||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
||||
spec.require_paths = ['lib']
|
||||
|
||||
spec.add_development_dependency 'minitest', '~> 5.0'
|
||||
spec.add_development_dependency 'rake', '~> 10.0'
|
||||
spec.add_development_dependency 'rubocop', '~> 0.54.0'
|
||||
spec.add_development_dependency 'simplecov', '~> 0.16.0'
|
||||
spec.add_development_dependency 'simplecov-console', '~> 0.4.0'
|
||||
end
|
Loading…
Reference in a new issue