zipkin-tracer 0.36.1 → 0.36.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9731d7b33a04a21d40dbb5e887bc9f54d3052822b9a940b4c67abd9d263802ee
4
- data.tar.gz: 914938b89e93da3977a7df4eea19d5ec5e4c626410776c2fb69c25ec853a9c0c
3
+ metadata.gz: 795d59f52ecde287fa4afd8e391285c4bfcd5e60bc8eef827b31c53b14525b4f
4
+ data.tar.gz: f21cb46bf09dda5b55e660d7c47a2a70e281a3b21089e033b1ad9828e8802ec8
5
5
  SHA512:
6
- metadata.gz: de1f610c691567ed0f31bfe1d71625082c0b8a73b2fd78294770b566d24d39b49af45fab24b440947a3ae9f869ae6d25f97165c790f3a7170b414d4c94f5d820
7
- data.tar.gz: 74f20c4a09682e3049194e3d1d897f2977d6a00b08f2ffc98707c8d9e1dff76918892ea9726a0fe938670aa642ea01b7f03073ac9fe2efa0b78148ddbcc4c1ba
6
+ metadata.gz: b63fc26c0ac9cd3c64cd1fcbe3079657ae9fea506213aeed3885cb4a334908aaa18b61086699282c629afb712923e56a4b3ee45e06d3dd4051011b62d528d37b
7
+ data.tar.gz: 7b6c764aeee41e2b124c5494a180f31decd6f4f302195f9a3a8f273aff5775cd3fd76a474e97484bc081e54fd522953fbbe7333eb04db3df33f2f5c0fa558592
data/.gitignore ADDED
@@ -0,0 +1,31 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Documentation cache and generated files:
13
+ /.yardoc/
14
+ /_yardoc/
15
+ /doc/
16
+ /rdoc/
17
+
18
+ ## Environment normalisation:
19
+ /.bundle/
20
+ /lib/bundler/man/
21
+
22
+ # for a library or gem, you might want to ignore these files since the code is
23
+ # intended to run in multiple environments; otherwise, check them in:
24
+ # Gemfile.lock
25
+ .ruby-version
26
+ .ruby-gemset
27
+
28
+ # do not include Gemfile.lock in gem source
29
+ Gemfile.lock
30
+
31
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,27 @@
1
+ language: ruby
2
+ jdk:
3
+ - oraclejdk8
4
+ rvm:
5
+ - 2.6.2
6
+ - 2.5.5
7
+ - 2.4.5
8
+ - 2.3.8
9
+ - jruby-9.1.17.0
10
+ - jruby-9.2.6.0
11
+ deploy:
12
+ provider: rubygems
13
+ api_key:
14
+ secure: HJquPWOoh9YKHTJrGTBriao4wVDu/tn+JwZphPrS38PNu5FkzyRuhjq2XyBrm8BkuJWdqkVx9rpJTlFkcjIfhpZOJUn5gtTUgp12/voUMWBCWw9AUfbYdYkGhy6Lmq6miJcUFkhdeiMmnliz0Wav1ZYEWkodC25ACKQiGtk9rwr+4wKkluljOnmbyPFRiF61ZjSaz4qy9ZpwWOSPGuEjCQuvhW1hx0VNBjsio59sKUK0v2lFHxSfMjW+QrB5GAV0isv4CtG5V9MKMlRBX8+4RbklO0LHdCmykTDTioyYrfBI0x7RiO/l453/EH4dQEzivZ9AQNtIIshPu1Zht63LHWff4JyytSGxe5WmXaQjxfrZi2LMIXbeg5g2pPDmiMqFVSCgxFKJQW1eyU9pF3w5C4v9P0uLeizGnLReOwwjBDqiWIQ2bR4YWn+fsg/wbhjXHmefEjcJYL59niK8pw1JOcg7fy/P32wbbqILUcIg3of1ih1lyPV4YBY62KJny6e0c83zX2KukVMP9M6crW2NEspMqcQWFzbp3SR9oM0ziMDGUs0s1/PKVtuFTZ2S+ykbawX5P9YqSSx8iXp+Ez5MAMbrjiPXlzpzMvudDaN3kqRT2EomJ4iQjJOxXgUyTspLpZFojh4+RVjgi+sGEA8SeNiqrytThsCwQV1ro8ymL+8=
15
+ gem: zipkin-tracer
16
+ on:
17
+ tags: true
18
+ repo: openzipkin/zipkin-ruby
19
+ condition: "$TRAVIS_RUBY_VERSION == 2.6.2"
20
+ notifications:
21
+ webhooks:
22
+ urls:
23
+ - https://webhooks.gitter.im/e/637e968b45032d16ee26
24
+ on_success: change
25
+ on_failure: always
26
+ on_start: false
27
+ script: "bundle exec rspec"
data/CHANGELOG.md ADDED
@@ -0,0 +1,241 @@
1
+ # 0.36.2
2
+ * Cleanup the gemspec. No code changes.
3
+
4
+ # 0.36.1
5
+ * Bugfix: Prevent uninitialized constant AsyncHttpApiClient::ZipkinHttpSender error
6
+
7
+ # 0.36.0
8
+ * Add ZipkinSqsSender to send spans via Amazon SQS
9
+ * Rename ZipkinJsonTracer to ZipkinHttpSender and rename others to replace the term "tracer" with "sender"
10
+
11
+ # 0.35.1
12
+ * Fix bug with Rails 5.1 when calling recognize_path with a nil path
13
+
14
+ # 0.35.0
15
+ * removes record_on_server_receive option
16
+ * records status_code and method on all server receive events.
17
+
18
+ # 0.34.0
19
+ * Whitelist plugin ensure a request is traced even if it is not routable
20
+ * Gem requires Ruby > 2.3.0. In practice this was true already.
21
+
22
+ # 0.33.0
23
+ * Switch to Zipkin v2 span format
24
+
25
+ # 0.32.4
26
+ * Remove the ':service_port' configuration.
27
+ * Fix 'sa' annotation encoding.
28
+
29
+ # 0.32.3
30
+ * Fix bug using trace generator.
31
+
32
+ # 0.32.2
33
+ * Recover the old Trace.id logic but based not the new API. Again, for compatibility.
34
+
35
+ # 0.32.1
36
+ * Delete added parameter to trace.next_id
37
+
38
+ # 0.32.0
39
+ * Restore Trace.id for now as software needs to migrate out of it.
40
+
41
+ # 0.31.0
42
+ * Remove dependency from finagle-thrift
43
+ * Use http.url instead of http.uri
44
+
45
+ # 0.30.0
46
+ * Add 'http.method' to client annotations
47
+
48
+ # 0.29.1
49
+ * Patch abstract route to work with Grape
50
+
51
+ # 0.29.0
52
+ * Add abstract route to span name
53
+ * Fix not to raise "NoMethodError" for Rails:Module
54
+
55
+ # 0.28.0
56
+ * Add the `:trace_id_128bit` configuration option.
57
+
58
+ # 0.27.2.1
59
+ * Update version.rb to fix checksum mismatch on RubyGems.org
60
+ * Add `condition` on Travis CI deployment
61
+
62
+ # 0.27.2
63
+ * Convert trace values to string
64
+
65
+ # 0.27.1
66
+ * Rescue connection errors when sending information to Zipkin fails
67
+
68
+ # 0.27.0
69
+ * Add tagging of errors for Faraday and Excon.
70
+
71
+ # 0.26.0
72
+ * Add sidekiq worker tracing.
73
+
74
+ # 0.25.0
75
+ * Fix pass kafka producer to rack middleware
76
+
77
+ # 0.24.0
78
+ * Fix Pass and use the span in annotate_plugin
79
+
80
+ # 0.23.0
81
+ * Fix Excon middleware span duration
82
+ * Add `start_span` and `end_span` to the Null tracer
83
+
84
+ # 0.22.0
85
+ * Add the `:record_on_server_receive` configuration option.
86
+
87
+ # 0.21.2
88
+ * Bugfix: Guard against tracer not set in Faraday and Excon middlewares
89
+
90
+ # 0.21.1
91
+ * Bugfix: better guard against nil response in the Excon middleware
92
+
93
+ # 0.21.0
94
+ * Added an Excon middleware
95
+
96
+ # 0.20.1
97
+ * Bugfix: Properly handle the `sampled_as_boolean` configuration option
98
+
99
+ # 0.20.0
100
+ * Bugfix: The Faraday middleware does not leave in the container any generated Id
101
+ * Added TraceContainer and TraceGenerator to provide easier abstractions to interact with this library
102
+
103
+ # 0.19.1
104
+ * Limits the required headers to x_b3_trace_id and x_b3_span_id as per spec.
105
+
106
+ # 0.19.0
107
+ * Propagates the X-B3-Sampled in the same form it receives it (boolean or 1/0)
108
+ * Adds a configuration option to allow a service to emit boolean or numbers for the X-B3-Sampled header
109
+
110
+ # 0.18.6
111
+ * Passes HTTP Method to recognize_path
112
+
113
+ # 0.18.5
114
+ * `NullTracer` has a noop `flush!` method.
115
+ * Spans from `local_component_span` will be named according to `local_component_value` over `lc`.
116
+
117
+ # 0.18.4
118
+ * Uses http.path to annotate paths instead of http.uri.
119
+
120
+ # 0.18.3
121
+ * Ensures ip addresses for all hostnames are resolved, solves issue with docker hostnames
122
+
123
+ # 0.18.2
124
+ * Remove nil parentId from zipkin span payload.
125
+
126
+ # 0.18.1
127
+ * Turn the ZipkinTracer::FaradayHandler::B3_HEADERS constant into a private method
128
+
129
+ # 0.18.0
130
+ * Adds the :log_tracing option to explicitly use the logger tracer.
131
+ * Logger classes can not be passed via the configuration file (never worked correctly).
132
+ * Logger tracer logs in JSON format for easy analysis by other tools.
133
+
134
+ # 0.17.0
135
+ Adds a :producer configuration key as an alternative to Hermann as Kafka client.
136
+
137
+ # 0.16.0
138
+ * Remove the scribe tracer.
139
+ * Use sucker_punch 2.x. The main feature is the dependency on concurrent-ruby instead of celluloid.
140
+
141
+ # 0.15.1
142
+ * Less strict dependency on Rack. Allows to use Rails 5.
143
+
144
+ # 0.15.0
145
+ * Hostname resolution done asyncronously for the JSON tracer
146
+
147
+ # 0.14.1
148
+ * Access to the tracer when we need it and not before.
149
+
150
+ # 0.14.0
151
+ * Adds a logger kind of tracer.
152
+
153
+ # 0.13.2
154
+ * Move record methods in TraceClient to Span
155
+ * Relocate definition of constant variables
156
+
157
+ # 0.13.1
158
+ * Check the config entry is not blank when infering adapters
159
+
160
+ # 0.13.0
161
+ * Remove support for buffering. It was broken anyways.
162
+
163
+ # 0.12.2
164
+ * Make local tracing method (ZipkinTracer::TraceClient.local_component_span) returns the result of block
165
+
166
+ # 0.12.1
167
+ * Allow nesting of local tracing spans
168
+
169
+ # 0.12.0
170
+ * Add local tracing, fix flushing, add timestamp and duration to span
171
+
172
+ # 0.11.0
173
+ * Use local spans instead of thread-safe variables to improve performance
174
+ * Add new `with_new_span` method to the tracer api to allow creating custom spans
175
+
176
+ # 0.10.3
177
+ * Avoid requiring finagle-thrift when possible to avoid a hard dependency on Thrift
178
+
179
+ # 0.10.2
180
+ * Add faraday as a dependency
181
+
182
+ # 0.10.1
183
+ * Performance optimization: Do not create tracing related objects in the Faraday middleware if we
184
+ are not sampling.
185
+ * Fix benchmark Rake task so it uses the proper Faraday middlewares
186
+
187
+ # 0.10.0
188
+ * Always create trace IDs even when the trace will not be sent to zipkin (other parts of the app may use them).
189
+ * Bugfix: Tracer is now Threadsafe
190
+ * Development improvement: Benchmark Rake task to help finding performance issues
191
+
192
+ # 0.9.1
193
+ * Make Scribe actually optional by inspecting the conf first and requiring after.
194
+
195
+ # 0.9.0
196
+ * Add a JSON tracer (ZipkinJsonTracer).
197
+
198
+ # 0.8.1
199
+ * Set caller service name using domain environment variable. If the value
200
+ is not set, it will fall back to the configuration file default.
201
+
202
+ # 0.8.0
203
+ * To proper follow the correct spec, now the annotations cr/cs set the local service as servicename
204
+ * Added a 'sa' annotation to indicate the remote service servicename
205
+
206
+ # 0.7.3
207
+ * Send method name (get, post, etc) as lowercase (zipkin > 1.22 expect them lowercase)
208
+
209
+ # 0.7.2
210
+ * Rescue possible errors when lookup of the hostname fails
211
+
212
+ # 0.7.1
213
+ * Remove Scribe from direct dependencies list
214
+
215
+ # 0.7
216
+ * The ruby client does not wait to receive ACK from the collector. Just send traces
217
+ * Connecting to the collector now happens in a different thread
218
+ * The server annotations will not add information about the URL hit if hit by a zipkin enabled client
219
+
220
+ # 0.6.3
221
+ * Properly pop the Id from the traces stacks when finishing the Faraday tracer
222
+
223
+ # 0.6.2
224
+ * Do not trace requests if the current application will not serve them.
225
+
226
+ # 0.6.1
227
+ * Relax constraint on Rack from ~> 1.6 to ~> 1.3
228
+
229
+ # 0.6
230
+ * New configuration option :logger to setup a logger for error messages
231
+ * The Zipkin Rack middleware will not raise an error if sending information to Zipkin raises an error
232
+
233
+ # 0.5.1
234
+ * The Zipkin Rack middleware will not raise an error if sending information to Zipkin raises an error
235
+ * Integration specs to make sure information is properly passed when using Rack middleware together with Faraday's
236
+
237
+ # 0.5.0
238
+ * Added Faraday middleware to the repo
239
+
240
+ # 0.4.0
241
+ * Use Thread safe Finagle version to store the traces
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zipkin-tracer.gemspec
4
+ gemspec
5
+
6
+ platform :ruby do
7
+ gem 'benchmark-ips'
8
+ gem 'rbtrace'
9
+ gem 'byebug'
10
+ gem 'simplecov', require: false
11
+ end
12
+
13
+ platform :jruby do
14
+ gem 'hermann', '~> 0.27.0'
15
+ end
16
+
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2011 Twitter Inc.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/NOTICE.md ADDED
@@ -0,0 +1,3 @@
1
+ This repository was originally developed by Twitter and released under Apache license.
2
+
3
+ Further code has been developed by Openzipkin contributors.
data/README.md ADDED
@@ -0,0 +1,237 @@
1
+ # ZipkinTracer: Zipkin client for Ruby
2
+
3
+ [![Build Status](https://api.travis-ci.org/openzipkin/zipkin-ruby.svg?branch=master)](https://travis-ci.org/openzipkin/zipkin-ruby)
4
+
5
+ Rack and Faraday integration middlewares for Zipkin tracing.
6
+
7
+ ## Usage
8
+
9
+ ### Sending traces on incoming requests
10
+
11
+ Options can be provided via Rails.config for a Rails 3+ app, or can be passed as a hash argument to the Rack plugin.
12
+
13
+ ```ruby
14
+ require 'zipkin-tracer'
15
+ use ZipkinTracer::RackHandler, config # config is optional
16
+ ```
17
+
18
+ where `Rails.config.zipkin_tracer` or `config` is a hash that can contain the following keys:
19
+
20
+ * `:service_name` **REQUIRED** - the name of the service being traced. There are two ways to configure this value. Either write the service name in the config file or set the "DOMAIN" environment variable (e.g. 'test-service.example.com' or 'test-service'). The environment variable takes precedence over the config file value.
21
+ * `:sample_rate` (default: 0.1) - the ratio of requests to sample, from 0 to 1
22
+ * `:json_api_host` - hostname with protocol of a zipkin api instance (e.g. `https://zipkin.example.com`) to use the HTTP sender
23
+ * `:zookeeper` - the address of the zookeeper server to use by the Kafka sender
24
+ * `:sqs_queue_name` - the name of the Amazon SQS queue to use the SQS sender
25
+ * `:sqs_region` - the AWS region for the Amazon SQS queue
26
+ * `:log_tracing` - Set to true to log all traces. Only used if traces are not sent to the API or Kafka.
27
+ * `:annotate_plugin` - plugin function which receives the Rack env, the response status, headers, and body to record annotations
28
+ * `:filter_plugin` - plugin function which receives the Rack env and will skip tracing if it returns false
29
+ * `:whitelist_plugin` - plugin function which receives the Rack env and will force sampling if it returns true
30
+ * `:sampled_as_boolean` - When set to true (default but deprecrated), it uses true/false for the `X-B3-Sampled` header. When set to false uses 1/0 which is preferred.
31
+ * `:trace_id_128bit` - When set to true, high 8-bytes will be prepended to trace_id. The upper 4-bytes are epoch seconds and the lower 4-bytes are random. This makes it convertible to Amazon X-Ray trace ID format v1. (See http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-request-tracing.html)
32
+
33
+ ### Sending traces on outgoing requests with Faraday
34
+
35
+ First, Faraday has to be part of your Gemfile:
36
+ ```
37
+ gem 'faraday', '~> 0.8'
38
+ ```
39
+
40
+ For the Faraday middleware to have the correct trace ID, the rack middleware should be used in your application as explained above.
41
+
42
+ Then include `ZipkinTracer::FaradayHandler` as a Faraday middleware:
43
+
44
+ ```ruby
45
+ require 'faraday'
46
+ require 'zipkin-tracer'
47
+
48
+ conn = Faraday.new(:url => 'http://localhost:9292/') do |faraday|
49
+ faraday.use ZipkinTracer::FaradayHandler, 'service_name' # 'service_name' is optional (but recommended)
50
+ # default Faraday stack
51
+ faraday.request :url_encoded
52
+ faraday.adapter Faraday.default_adapter
53
+ end
54
+ ```
55
+
56
+ Note that supplying the service name for the destination service is optional;
57
+ the tracing will default to a service name derived from the first section of the destination URL (e.g. 'service.example.com' => 'service').
58
+
59
+ ### Tracing Sidekiq workers
60
+
61
+ Sidekiq tracing can be turned on by adding ZipkinTracer::Sidekiq::Middleware to your sidekiq middleware chain:
62
+
63
+ ```ruby
64
+ zipkin_tracer_config = {
65
+ service_name: 'service',
66
+ json_api_host: 'http://zipkin.io',
67
+ traceable_workers: [:MyWorker, :MyWorker2],
68
+ sample_rate: 0.5
69
+ }
70
+
71
+ Sidekiq.configure_server do |config|
72
+ config.server_middleware do |chain|
73
+ chain.add ZipkinTracer::Sidekiq::Middleware, zipkin_tracer_config
74
+ end
75
+ end
76
+ ```
77
+
78
+ By default workers aren't traced. You can specify the workers that you want to trace with traceable_workers config option. If you want all your workers to be traced pass [:all] to traceable_workers option (traceable_workers: [:all]).
79
+
80
+ ### Local tracing
81
+
82
+ `ZipkinTracer::TraceClient` provides an API to record local traces in your application.
83
+ It can be used to measure the performance of process, record value of variables, and so on.
84
+
85
+ When `local_component_span` method is called, it creates a new span and a local component, and provides the following methods to create annotations.
86
+ * record(key) - annotation
87
+ * record_tag(key, value) - tag
88
+
89
+ Example:
90
+ ```ruby
91
+ ZipkinTracer::TraceClient.local_component_span('DB process') do |ztc|
92
+ ztc.record 'Create users'
93
+ ztc.record_tag 'number', '1000'
94
+
95
+ # create 1000 users
96
+ end
97
+ ```
98
+
99
+
100
+ ## Senders
101
+
102
+ Only one of the following senders can be used at a given time.
103
+
104
+ ### HTTP
105
+
106
+ Sends traces as JSON over HTTP. This is the preferred sender to use as the openzipkin project moves away from Thrift.
107
+
108
+ You need to specify the `:json_api_host` parameter to wherever your zipkin collector is running. It will POST traces to the `/api/v2/spans` path.
109
+
110
+ ### Kafka
111
+
112
+ Uses Kafka as the transport.
113
+
114
+ If in the config `:zookeeper` is set, then the gem will use Kafka via
115
+ [Hermann](https://github.com/reiseburo/hermann); you will need the `hermann`
116
+ gem (~> 0.27.0) installed, as it is not part of zipkin-tracer's gemspec.
117
+
118
+ Alternatively, you may provide a :producer option in the config; this producer
119
+ should accept #push() with a message and optional :topic. If the value returned
120
+ responds to #value!, it will be called (to block until completed).
121
+
122
+ Caveat: Hermann is only usable from within Jruby, due to its implementation of zookeeper based broker discovery being JVM based.
123
+
124
+ The Kafka transport send data using Thrift. Since version 0.31.0, Thrift is not a dependency, thus the gem 'finagle-thrift' needs to be added to the Gemfile also.
125
+
126
+ ### Amazon SQS
127
+
128
+ Uses Amazon SQS as the transport.
129
+
130
+ If `:sqs_queue_name` is set in the config, then the gem will use Amazon SQS; you will need the `aws-sdk-sqs` gem installed, as it is not part of zipkin-tracer's gemspec.
131
+
132
+ The following [Amazon SQS permissions](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-api-permissions-reference.html) are required:
133
+ - `sqs:SendMessage`
134
+ - `sqs:GetQueueUrl`
135
+
136
+ Optionally, you can set `:sqs_region` to specify the AWS region to connect to.
137
+
138
+ ### Logger
139
+
140
+ The simplest sender that does something. It will log all your spans.
141
+ This sender can be used for debugging purpose (to see what is going to be sent) or to deliver zipkin information into the logs for later retrieval and analysis.
142
+
143
+ You need to set `:log_tracing` to true in the configuration.
144
+
145
+ ### Null
146
+
147
+ If the configuration does not provide either an API host, Zookeeper server or Amazon SQS queue then the middlewares will not attempt to send traces although they will still generate proper IDs and pass them to other services.
148
+
149
+ Thus, if you only want to generate IDs for instance for logging and do not intent to integrate with Zipkin you can still use this gem. Just do not specify any server :)
150
+
151
+
152
+ ## Plugins
153
+
154
+ ### annotate_plugin
155
+ The annotate plugin expects a function of the form:
156
+
157
+ ```ruby
158
+ lambda { |span, env, status, response_headers, response_body| ... }
159
+ ```
160
+
161
+ The annotate plugin is expected to perform annotation based on content of the Rack environment and the response components.
162
+
163
+ **Warning:** Access to the response body may cause problems if the response is being streamed, in general this should be avoided.
164
+ See the Rack specification for more detail and instructions for properly hijacking responses.
165
+
166
+ The return value is ignored.
167
+
168
+ For example:
169
+
170
+ ```ruby
171
+ lambda do |span, env, status, response_headers, response_body|
172
+ ep = ::Trace.default_endpoint
173
+ # string annotation
174
+ span.record_tag('http.referrer', env['HTTP_REFERRER'])
175
+ # integer annotation
176
+ span.record_tag('http.content_size', env['CONTENT_SIZE'].to_s)
177
+ span.record_tag('http.status_code', status)
178
+ end
179
+ ```
180
+
181
+ ### filter_plugin
182
+ The filter plugin expects a function of the form:
183
+
184
+ ```ruby
185
+ lambda { |env| ... }
186
+ ```
187
+
188
+ The filter plugin allows skipping tracing if the return value is false.
189
+
190
+ For example:
191
+
192
+ ```ruby
193
+ # don't trace /static/ URIs
194
+ lambda { |env| env['PATH_INFO'] !~ /^\/static\// }
195
+ ```
196
+
197
+ ### whitelist_plugin
198
+ The whitelist plugin expects a function of the form:
199
+
200
+ ```ruby
201
+ lambda { |env| ... }
202
+ ```
203
+
204
+ The whitelist plugin allows forcing sampling if the return value is true.
205
+
206
+ For example:
207
+
208
+ ```ruby
209
+ # sample if request header specifies known device identifier
210
+ lambda { |env| KNOWN_DEVICES.include?(env['HTTP_X_DEVICE_ID']) }
211
+ ```
212
+
213
+ ## Development
214
+
215
+ This project uses Rspec. Make sure your PRs contain proper tests.
216
+ We have two rake tasks to help finding performance issues:
217
+ ```
218
+ rake benchmark
219
+ ```
220
+ Will run a benchmark testing all the different tracers and giving you
221
+ their relative speed.
222
+
223
+ ```
224
+ rake run_once
225
+ ```
226
+ Will run the rack middleware, optionally the faraday middleware. Please
227
+ modify the code to run the middleware you want to test.
228
+ The best way to use this rake test is together with rbtrace.
229
+ First run the task in background:
230
+ ```
231
+ rake run_once &
232
+ ```
233
+ Take note of the PID that displays in your terminal and run:
234
+ ```
235
+ rbtrace -p PID -f
236
+ ```
237
+ It will print out the methods used and the time each took.
data/RELEASE.md ADDED
@@ -0,0 +1,6 @@
1
+ ## Release Process
2
+
3
+ * tag the commit `git tag -v0.0.0`
4
+ * push tags to origin `git push origin --tags`
5
+ * Travis will automatically build and push to rubygems
6
+ * TODO: have travis push the tag using info from version.rb
data/Rakefile ADDED
@@ -0,0 +1,134 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'zipkin-tracer'
4
+ require 'benchmark'
5
+ require 'benchmark/ips'
6
+ require 'faraday'
7
+ require 'rack/mock'
8
+ require 'rbtrace'
9
+ require 'tempfile'
10
+
11
+ def add_rspec_options(options=[])
12
+ if RUBY_PLATFORM == 'java'
13
+ options << '--tag ~platform:mri'
14
+ else
15
+ options << '--tag ~platform:java'
16
+ end
17
+ return options
18
+ end
19
+
20
+ RSpec::Core::RakeTask.new(:spec) do |r|
21
+ r.rspec_opts = add_rspec_options
22
+ end
23
+
24
+ task :default => :spec
25
+
26
+
27
+ # Used to test a completely minimum middleware, no zipkin.
28
+ class EmptyMiddleware
29
+ def initialize(app)
30
+ @app = app
31
+ end
32
+
33
+ def call(env)
34
+ if @app.respond_to?(:call)
35
+ status, headers, body = @app.call(env)
36
+ else
37
+ [200, {}, 'Hello world']
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+ # Used to mock a middleware which uses Faraday.
44
+ # Note that we are creating fake objects pretending to be Faraday for speed.
45
+ class FaradayMiddleware
46
+ def initialize
47
+ response_env = { status: 200 }
48
+ @env = {
49
+ method: :post,
50
+ url: 'http://www.this_is_not_really_called.com',
51
+ body: 'majere',
52
+ request_headers: Faraday::Utils::Headers.new({}),
53
+ }
54
+ @app = lambda { |env| ResponseObject.new(@env, response_env) }
55
+ @middleware = ZipkinTracer::FaradayHandler.new(@app)
56
+ end
57
+
58
+ def call(_env)
59
+ @middleware.call(@env)
60
+ end
61
+
62
+ private
63
+
64
+ class ResponseObject
65
+ attr_reader :env
66
+
67
+ def initialize(env, response_env)
68
+ @env = env
69
+ @response_env = response_env
70
+ end
71
+
72
+ def on_complete
73
+ yield @response_env
74
+ self
75
+ end
76
+ end
77
+ end
78
+
79
+ desc "Runs a zipkin middleware once."
80
+ task :run_once do
81
+ empty_app = EmptyMiddleware.new(nil)
82
+ app = FaradayMiddleware.new
83
+
84
+ logger = Logger.new(Tempfile.new('fakelog'))
85
+ null_configuration = { logger: logger, sample_rate: 1}
86
+ null_tracer_rack = ZipkinTracer::RackHandler.new(app, null_configuration)
87
+ env = Rack::MockRequest.env_for('/path', {})
88
+
89
+ sleep(10)
90
+ null_tracer_rack.call(env)
91
+ end
92
+
93
+ # This task is used to help development of ZipkinTracer.
94
+ # It benchmark the relative performance of the different tracers.
95
+ desc "Runs benchmarks for ZipkinTracer."
96
+ task :benchmark do
97
+ logger = Logger.new(Tempfile.new('fakelog'))
98
+ fake_url = 'http://www.google.com' #resolve but unable to send I hope!
99
+
100
+ empty_app = EmptyMiddleware.new(nil)
101
+
102
+ null_configuration = { sample_rate: 1 }
103
+ json_configuration = null_configuration.merge(json_api_host: fake_url)
104
+ logger_configuration = null_configuration.merge(logger: logger)
105
+
106
+ # We create a different faraday middleware per rack middleware below because
107
+ # both middlewares share the same tracer. So they need to be created in pairs.
108
+ empty_rack = EmptyMiddleware.new(empty_app)
109
+ null_tracer_rack = ZipkinTracer::RackHandler.new(empty_app, null_configuration)
110
+ null_faraday_app = FaradayMiddleware.new
111
+ null_tracer_faraday_rack = ZipkinTracer::RackHandler.new(null_faraday_app, null_configuration)
112
+ json_tracer_rack = ZipkinTracer::RackHandler.new(empty_app, json_configuration)
113
+ json_faraday_app = FaradayMiddleware.new
114
+ json_tracer_faraday_rack = ZipkinTracer::RackHandler.new(json_faraday_app, json_configuration)
115
+ logger_tracer_rack = ZipkinTracer::RackHandler.new(empty_app, logger_configuration)
116
+ log_faraday_app = FaradayMiddleware.new
117
+ logger_tracer_faraday_rack = ZipkinTracer::RackHandler.new(log_faraday_app, logger_configuration)
118
+
119
+ env = Rack::MockRequest.env_for('/path', {})
120
+
121
+ Benchmark.ips do |bm|
122
+ # bm.report("No rack middleware") { empty_rack.call(env) } # Uncomment if curious
123
+ bm.report("NullTracer") { null_tracer_rack.call(env) }
124
+ bm.report("NullTracer + Faraday") { null_tracer_faraday_rack.call(env) }
125
+ bm.report("JSONTracer") { json_tracer_rack.call(env) }
126
+ bm.report("JSONTracer + Faraday") { json_tracer_faraday_rack.call(env) }
127
+ bm.report("Logging Tracer") { logger_tracer_rack.call(env) }
128
+ bm.report("Logging Tracer + Faraday") { logger_tracer_faraday_rack.call(env) }
129
+ bm.compare!
130
+ end
131
+
132
+ puts "i/s means the number of times the middleware can be called per second"
133
+
134
+ end
@@ -1,3 +1,3 @@
1
1
  module ZipkinTracer
2
- VERSION = '0.36.1'.freeze
2
+ VERSION = '0.36.2'.freeze
3
3
  end
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'zipkin-tracer/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'zipkin-tracer'
7
+ s.version = ZipkinTracer::VERSION
8
+ s.authors = ['Franklin Hu', 'R Tyler Croy', 'James Way', 'Jordi Polo', 'Julien Feltesse', 'Scott Steeg', 'Yohei Kitamura']
9
+ s.email = ['franklin@twitter.com', 'tyler@monkeypox.org', 'jamescway@gmail.com', 'jcarres@medidata.com', 'jfeltesse@medidata.com', 'ssteeg@medidata.com', 'ykitamura@medidata.com']
10
+ s.summary = 'Ruby tracing via Zipkin'
11
+ s.description = 'Adds tracing instrumentation for ruby applications'
12
+ s.license = 'Apache-2.0'
13
+ s.metadata = {
14
+ 'homepage_uri' => 'https://github.com/openzipkin/zipkin-ruby',
15
+ 'changelog_uri' => 'https://github.com/openzipkin/zipkin-ruby/blob/master/CHANGELOG.md'
16
+ }
17
+
18
+ s.required_ruby_version = '>= 2.3.0'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ s.require_paths = ['lib']
26
+
27
+ s.add_dependency 'faraday', '~> 0.8'
28
+ s.add_dependency 'rack', '>= 1.0'
29
+ s.add_dependency 'sucker_punch', '~> 2.0'
30
+
31
+ s.add_development_dependency 'aws-sdk-sqs', '~> 1.0'
32
+ s.add_development_dependency 'excon', '~> 0.53'
33
+ s.add_development_dependency 'rspec', '~> 3.8'
34
+ s.add_development_dependency 'rack-test', '~> 1.1'
35
+ s.add_development_dependency 'rake', '~> 10.0'
36
+ s.add_development_dependency 'timecop', '~> 0.8'
37
+ s.add_development_dependency 'webmock', '~> 3.0'
38
+ s.add_development_dependency 'simplecov', '~> 0.16'
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipkin-tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.1
4
+ version: 0.36.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franklin Hu
@@ -10,10 +10,11 @@ authors:
10
10
  - Jordi Polo
11
11
  - Julien Feltesse
12
12
  - Scott Steeg
13
+ - Yohei Kitamura
13
14
  autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
- date: 2019-04-15 00:00:00.000000000 Z
17
+ date: 2019-04-24 00:00:00.000000000 Z
17
18
  dependencies:
18
19
  - !ruby/object:Gem::Dependency
19
20
  name: faraday
@@ -174,13 +175,24 @@ email:
174
175
  - franklin@twitter.com
175
176
  - tyler@monkeypox.org
176
177
  - jamescway@gmail.com
177
- - jcarres@mdsol.com
178
- - jfeltesse@mdsol.com
179
- - ssteeg@mdsol.com
178
+ - jcarres@medidata.com
179
+ - jfeltesse@medidata.com
180
+ - ssteeg@medidata.com
181
+ - ykitamura@medidata.com
180
182
  executables: []
181
183
  extensions: []
182
184
  extra_rdoc_files: []
183
185
  files:
186
+ - ".gitignore"
187
+ - ".rspec"
188
+ - ".travis.yml"
189
+ - CHANGELOG.md
190
+ - Gemfile
191
+ - LICENSE
192
+ - NOTICE.md
193
+ - README.md
194
+ - RELEASE.md
195
+ - Rakefile
184
196
  - lib/zipkin-tracer.rb
185
197
  - lib/zipkin-tracer/application.rb
186
198
  - lib/zipkin-tracer/config.rb
@@ -202,10 +214,13 @@ files:
202
214
  - lib/zipkin-tracer/zipkin_null_sender.rb
203
215
  - lib/zipkin-tracer/zipkin_sender_base.rb
204
216
  - lib/zipkin-tracer/zipkin_sqs_sender.rb
205
- homepage: https://github.com/openzipkin/zipkin-tracer
217
+ - zipkin-tracer.gemspec
218
+ homepage:
206
219
  licenses:
207
220
  - Apache-2.0
208
- metadata: {}
221
+ metadata:
222
+ homepage_uri: https://github.com/openzipkin/zipkin-ruby
223
+ changelog_uri: https://github.com/openzipkin/zipkin-ruby/blob/master/CHANGELOG.md
209
224
  post_install_message:
210
225
  rdoc_options: []
211
226
  require_paths:
@@ -219,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
234
  requirements:
220
235
  - - ">="
221
236
  - !ruby/object:Gem::Version
222
- version: 1.3.5
237
+ version: '0'
223
238
  requirements: []
224
239
  rubygems_version: 3.0.3
225
240
  signing_key: