hubstep 0.1.1 → 1.0.0

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
  SHA1:
3
- metadata.gz: 12049128293bd8dd6ebfd5a63eb7bab3d0d07307
4
- data.tar.gz: 335afba8aa1d6a9f4376ce9af4309fe410491e5e
3
+ metadata.gz: c22f34ac228b96f97da79906e29da1fcd3bdfe5e
4
+ data.tar.gz: 88446428797ff70c345ae63ca52853d4cb4bbc49
5
5
  SHA512:
6
- metadata.gz: fad83ef49dc17ffb0a16ed7244ce3723d396cc5248832f0ddbb95efa5a4df207645c93fea20e1902639dcb3a70e9bc8ff028f71f419a344db19fe206479f366e
7
- data.tar.gz: 2babb2d26a745b96661f5c65833dfb316228f23ef812ec7d918d17259e687c3a2c2553d678caad9b8cae0632e6649c4e3235b9e2cf7bc49fbd52372c3df1748c
6
+ metadata.gz: eb1c73bb2a4208720038d164a08a4b0be533693cd1a2bd5b332db16d48d54cba02e0f5f9b58ea5d65d8a107809066674427cb38476d74f56332cc0c4411550d8
7
+ data.tar.gz: d4f1b84bf2e291b724f900be0f3fe228e49d5f792a2bbc061c6b56039c06edd4dfadc98b6b298f52c81af58e87cb6f9e90cc3a5c7ae950622c3acdb78763b332
@@ -0,0 +1,33 @@
1
+ ## Contributing
2
+
3
+ [fork]: https://github.com/github/hubstep/fork
4
+ [pr]: https://github.com/github/hubstep/compare
5
+ [style]: https://github.com/styleguide/ruby
6
+ [code-of-conduct]: CODE_OF_CONDUCT.md
7
+
8
+ Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
9
+
10
+ Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
11
+
12
+ ## Submitting a pull request
13
+
14
+ 0. [Fork][fork] and clone the repository
15
+ 0. Configure and install the dependencies: `script/bootstrap`
16
+ 0. Make sure the tests pass on your machine: `rake`
17
+ 0. Create a new branch: `git checkout -b my-branch-name`
18
+ 0. Make your change, add tests, and make sure the tests still pass
19
+ 0. Push to your fork and [submit a pull request][pr]
20
+ 0. Pat your self on the back and wait for your pull request to be reviewed and merged.
21
+
22
+ Here are a few things you can do that will increase the likelihood of your pull request being accepted:
23
+
24
+ - Follow the [style guide][style].
25
+ - Write tests.
26
+ - Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
27
+ - Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
28
+
29
+ ## Resources
30
+
31
+ - [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/)
32
+ - [Using Pull Requests](https://help.github.com/articles/using-pull-requests/)
33
+ - [GitHub Help](https://help.github.com)
@@ -6,6 +6,17 @@ module HubStep
6
6
  module Rack
7
7
  # Rack middleware for wrapping a request in a span.
8
8
  class Middleware
9
+ SPAN = "#{name}.span"
10
+
11
+ # Get the span that represents this request
12
+ #
13
+ # env - a Rack env Hash
14
+ #
15
+ # Returns a Span.
16
+ def self.get_span(env)
17
+ env[SPAN]
18
+ end
19
+
9
20
  # Create a Middleware
10
21
  #
11
22
  # tracer - a HubStep::Tracer instance
@@ -31,24 +42,28 @@ module HubStep
31
42
 
32
43
  def trace(env)
33
44
  @tracer.span("Rack #{env["REQUEST_METHOD"]}") do |span|
34
- span.configure do
35
- add_tags(span, ::Rack::Request.new(env))
36
- end
45
+ env[SPAN] = span
46
+
47
+ span.configure { record_request(span, env) }
37
48
 
38
49
  result = yield
39
50
 
40
- span.set_tag("http.status_code", result[0].to_s)
51
+ span.configure { record_response(span, *result) }
41
52
 
42
53
  result
43
54
  end
44
55
  end
45
56
 
46
- def add_tags(span, request)
47
- tags(request).each do |key, value|
57
+ def record_request(span, env)
58
+ tags(::Rack::Request.new(env)).each do |key, value|
48
59
  span.set_tag(key, value)
49
60
  end
50
61
  end
51
62
 
63
+ def record_response(span, status, _headers, _body)
64
+ span.set_tag("http.status_code", status)
65
+ end
66
+
52
67
  def tags(request)
53
68
  tags = {
54
69
  "component" => "rack",
@@ -47,17 +47,6 @@ module HubStep
47
47
  self.enabled = original
48
48
  end
49
49
 
50
- # Get the topmost span in the stack
51
- #
52
- # This is the span that has no parent span; the rest of the spans in the
53
- # stack descend from it.
54
- #
55
- # Returns a LightStep::Span or InertSpan.
56
- def top_span
57
- span = @spans.first if enabled?
58
- span || InertSpan.instance
59
- end
60
-
61
50
  # Get the bottommost span in the stack
62
51
  #
63
52
  # This is the span that has no children.
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module HubStep
3
- VERSION = "0.1.1"
3
+ VERSION = "1.0.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubstep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Roben
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-16 00:00:00.000000000 Z
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lightstep
@@ -148,6 +148,7 @@ files:
148
148
  - ".ruby-version"
149
149
  - ".travis.yml"
150
150
  - CODE_OF_CONDUCT.md
151
+ - CONTRIBUTING.md
151
152
  - Gemfile
152
153
  - LICENSE.txt
153
154
  - README.md