appsignal_extensions 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.rubocop.yml +55 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +4 -1
- data/Gemfile.lock +69 -0
- data/LICENSE.txt +33 -20
- data/README.md +31 -36
- data/Rakefile +8 -18
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/appsignal_extensions/middleware.rb +121 -119
- data/lib/appsignal_extensions/version.rb +1 -1
- data/lib/appsignal_extensions.rb +3 -3
- metadata +44 -26
- data/.document +0 -5
- data/.gitignore +0 -50
- data/appsignal_extensions.gemspec +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63c64921d6a8d4799fdd49929f6d4e421223b0bd75f7cb2cfaa0d26237dc90bb
|
4
|
+
data.tar.gz: 60c63643466f458e5a05c2878ebf2b7237da3aea425f23c958e17365e7424467
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a13a20b6abad1b33837eff4953164750d0be8a94b571cc4a3014fffc1178273d9361f56a718fc32c78fa89844aa3997aa0e7934f3a8bbb4b4831cd381eff50b
|
7
|
+
data.tar.gz: b8c48abd4ba16088a42fcbaa98c41fa15c5e2796b47ea73c8ee05d56c40ea1ac7d2878d647ea765cbab06ac5a2a910290f5cd093df9da7ddbf34e01b99916ce3
|
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: disable
|
3
|
+
TargetRubyVersion: 2.6
|
4
|
+
|
5
|
+
Layout/ArgumentAlignment:
|
6
|
+
EnforcedStyle: with_fixed_indentation
|
7
|
+
|
8
|
+
Layout/MultilineMethodCallIndentation:
|
9
|
+
EnforcedStyle: indented
|
10
|
+
|
11
|
+
Layout/LineLength:
|
12
|
+
Max: 120
|
13
|
+
Severity: convention
|
14
|
+
|
15
|
+
Lint/AmbiguousBlockAssociation:
|
16
|
+
Exclude:
|
17
|
+
- "spec/**/*"
|
18
|
+
|
19
|
+
Metrics/BlockLength:
|
20
|
+
Exclude:
|
21
|
+
- "spec/**/*"
|
22
|
+
- "*.gemspec"
|
23
|
+
|
24
|
+
Metrics/MethodLength:
|
25
|
+
Max: 50
|
26
|
+
|
27
|
+
Metrics/AbcSize:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Naming/AccessorMethodName:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/Documentation:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/FrozenStringLiteralComment:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Style/IfUnlessModifier:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Style/StringLiterals:
|
43
|
+
EnforcedStyle: double_quotes
|
44
|
+
|
45
|
+
Style/FormatStringToken:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Style/GuardClause:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Lint/MissingSuper:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Lint/RescueException:
|
55
|
+
Enabled: false
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at gerard@wetransfer.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
appsignal_extensions (2.0.1)
|
5
|
+
appsignal (~> 2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
appsignal (2.11.10)
|
11
|
+
rack
|
12
|
+
ast (2.4.2)
|
13
|
+
diff-lcs (1.5.0)
|
14
|
+
parallel (1.21.0)
|
15
|
+
parser (3.1.0.0)
|
16
|
+
ast (~> 2.4.1)
|
17
|
+
psych (4.0.3)
|
18
|
+
stringio
|
19
|
+
rack (2.2.3)
|
20
|
+
rack-test (1.1.0)
|
21
|
+
rack (>= 1.0, < 3)
|
22
|
+
rainbow (3.1.1)
|
23
|
+
rake (13.0.6)
|
24
|
+
rdoc (6.4.0)
|
25
|
+
psych (>= 4.0.0)
|
26
|
+
regexp_parser (2.2.0)
|
27
|
+
rexml (3.2.5)
|
28
|
+
rspec (3.10.0)
|
29
|
+
rspec-core (~> 3.10.0)
|
30
|
+
rspec-expectations (~> 3.10.0)
|
31
|
+
rspec-mocks (~> 3.10.0)
|
32
|
+
rspec-core (3.10.1)
|
33
|
+
rspec-support (~> 3.10.0)
|
34
|
+
rspec-expectations (3.10.2)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.10.0)
|
37
|
+
rspec-mocks (3.10.2)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.10.0)
|
40
|
+
rspec-support (3.10.3)
|
41
|
+
rubocop (1.25.0)
|
42
|
+
parallel (~> 1.10)
|
43
|
+
parser (>= 3.1.0.0)
|
44
|
+
rainbow (>= 2.2.2, < 4.0)
|
45
|
+
regexp_parser (>= 1.8, < 3.0)
|
46
|
+
rexml
|
47
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
48
|
+
ruby-progressbar (~> 1.7)
|
49
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
50
|
+
rubocop-ast (1.15.1)
|
51
|
+
parser (>= 3.0.1.1)
|
52
|
+
ruby-progressbar (1.11.0)
|
53
|
+
stringio (3.0.1)
|
54
|
+
unicode-display_width (2.1.0)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
appsignal_extensions!
|
61
|
+
bundler (~> 2.0)
|
62
|
+
rack-test
|
63
|
+
rake (~> 13)
|
64
|
+
rdoc (~> 6)
|
65
|
+
rspec (~> 3.10.0)
|
66
|
+
rubocop (~> 1.21)
|
67
|
+
|
68
|
+
BUNDLED WITH
|
69
|
+
2.3.4
|
data/LICENSE.txt
CHANGED
@@ -1,20 +1,33 @@
|
|
1
|
-
Copyright
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
the
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
Copyright 2021 WeTransfer
|
2
|
+
|
3
|
+
Hippocratic License Version Number: 2.1.
|
4
|
+
|
5
|
+
Purpose. The purpose of this License is for the Licensor named above to permit the Licensee (as defined below) broad permission, if consistent with Human Rights Laws and Human Rights Principles (as each is defined below), to use and work with the Software (as defined below) within the full scope of Licensor’s copyright and patent rights, if any, in the Software, while ensuring attribution and protecting the Licensor from liability.
|
6
|
+
|
7
|
+
Permission and Conditions. The Licensor grants permission by this license (“License”), free of charge, to the extent of Licensor’s rights under applicable copyright and patent law, to any person or entity (the “Licensee”) obtaining a copy of this software and associated documentation files (the “Software”), to do everything with the Software that would otherwise infringe (i) the Licensor’s copyright in the Software or (ii) any patent claims to the Software that the Licensor can license or becomes able to license, subject to all of the following terms and conditions:
|
8
|
+
|
9
|
+
- Acceptance. This License is automatically offered to every person and entity subject to its terms and conditions. Licensee accepts this License and agrees to its terms and conditions by taking any action with the Software that, absent this License, would infringe any intellectual property right held by Licensor.
|
10
|
+
|
11
|
+
- Notice. Licensee must ensure that everyone who gets a copy of any part of this Software from Licensee, with or without changes, also receives the License and the above copyright notice (and if included by the Licensor, patent, trademark and attribution notice). Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software. For clarity, although Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee with additional or different terms, the portion of the Software not modified must be distributed pursuant to this License. If anyone notifies Licensee in writing that Licensee has not complied with this Notice section, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice. If Licensee does not do so, Licensee’s License (and all rights licensed hereunder) shall end immediately.
|
12
|
+
|
13
|
+
- Compliance with Human Rights Principles and Human Rights Laws.
|
14
|
+
|
15
|
+
1. Human Rights Principles.
|
16
|
+
|
17
|
+
(a) Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights and the United Nations Global Compact that define recognized principles of international human rights (the “Human Rights Principles”). Licensee shall use the Software in a manner consistent with Human Rights Principles.
|
18
|
+
|
19
|
+
(b) Unless the Licensor and Licensee agree otherwise, any dispute, controversy, or claim arising out of or relating to (i) Section 1(a) regarding Human Rights Principles, including the breach of Section 1(a), termination of this License for breach of the Human Rights Principles, or invalidity of Section 1(a) or (ii) a determination of whether any Law is consistent or in conflict with Human Rights Principles pursuant to Section 2, below, shall be settled by arbitration in accordance with the Hague Rules on Business and Human Rights Arbitration (the “Rules”); provided, however, that Licensee may elect not to participate in such arbitration, in which event this License (and all rights licensed hereunder) shall end immediately. The number of arbitrators shall be one unless the Rules require otherwise.
|
20
|
+
|
21
|
+
Unless both the Licensor and Licensee agree to the contrary: (1) All documents and information concerning the arbitration shall be public and may be disclosed by any party; (2) The repository referred to under Article 43 of the Rules shall make available to the public in a timely manner all documents concerning the arbitration which are communicated to it, including all submissions of the parties, all evidence admitted into the record of the proceedings, all transcripts or other recordings of hearings and all orders, decisions and awards of the arbitral tribunal, subject only to the arbitral tribunal's powers to take such measures as may be necessary to safeguard the integrity of the arbitral process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3) Article 26(6) of the Rules shall not apply.
|
22
|
+
|
23
|
+
2. Human Rights Laws. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any Human Rights Laws. “Human Rights Laws” means any applicable laws, regulations, or rules (collectively, “Laws”) that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights; provided, however, that such Laws are consistent and not in conflict with Human Rights Principles (a dispute over the consistency or a conflict between Laws and Human Rights Principles shall be determined by arbitration as stated above). Where the Human Rights Laws of more than one jurisdiction are applicable or in conflict with respect to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
|
24
|
+
|
25
|
+
3. Indemnity. Licensee shall hold harmless and indemnify Licensor (and any other contributor) against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor’s reasonable attorneys’ fees, arising out of or relating to Licensee’s use of the Software in violation of Human Rights Laws or Human Rights Principles.
|
26
|
+
|
27
|
+
- Failure to Comply. Any failure of Licensee to act according to the terms and conditions of this License is both a breach of the License and an infringement of the intellectual property rights of the Licensor (subject to exceptions under Laws, e.g., fair use). In the event of a breach or infringement, the terms and conditions of this License may be enforced by Licensor under the Laws of any jurisdiction to which Licensee is subject. Licensee also agrees that the Licensor may enforce the terms and conditions of this License against Licensee through specific performance (or similar remedy under Laws) to the extent permitted by Laws. For clarity, except in the event of a breach of this License, infringement, or as otherwise stated in this License, Licensor may not terminate this License with Licensee.
|
28
|
+
|
29
|
+
- Enforceability and Interpretation. If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction; provided, however, subject to a court modification pursuant to the immediately following sentence, if any term or provision of this License pertaining to Human Rights Laws or Human Rights Principles is deemed invalid, illegal, or unenforceable against Licensee by a court of competent jurisdiction, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by Laws, the court may modify this License to affect the original purpose that the Software be used in compliance with Human Rights Principles and Human Rights Laws as closely as possible. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
|
30
|
+
|
31
|
+
- Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM.
|
32
|
+
|
33
|
+
This Hippocratic License is an Ethical Source license (https://ethicalsource.dev) and is offered for use by licensors and licensees at their own risk, on an “AS IS” basis, and with no warranties express or implied, to the maximum extent permitted by Laws.
|
data/README.md
CHANGED
@@ -1,48 +1,43 @@
|
|
1
|
-
#
|
1
|
+
# AppsignalExtensions
|
2
2
|
|
3
|
-
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/appsignal_extensions`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
|
-
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
6
|
|
7
|
-
|
8
|
-
possible. Simplest use is just like the standard Rack listener in Appsignal:
|
7
|
+
## Installation
|
9
8
|
|
10
|
-
|
9
|
+
Add this line to your application's Gemfile:
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
```ruby
|
12
|
+
gem 'appsignal_extensions'
|
13
|
+
```
|
14
14
|
|
15
|
-
|
16
|
-
object continues. Therefore, you can use this middleware for long-polling too (long bodies
|
17
|
-
which `yield` chunked content and so on).
|
15
|
+
And then execute:
|
18
16
|
|
19
|
-
|
20
|
-
response called 'appsignal.suspend'. If you set that header to a truthy value, the transaction
|
21
|
-
is not going to be closed for you. You can then close the transaction with your Thin `errback`
|
22
|
-
proc or similar, or close it explicitly in the `close` handler of your response body.
|
17
|
+
$ bundle install
|
23
18
|
|
24
|
-
|
25
|
-
and you can do things to the transaction manually. For instance:
|
26
|
-
|
27
|
-
->(env) {
|
28
|
-
env['appsignal.transaction'].set_action('MyHandler#perform')
|
29
|
-
...
|
30
|
-
}
|
19
|
+
Or install it yourself as:
|
31
20
|
|
32
|
-
|
33
|
-
special `NullTransaction` object instead which responds to all the same methods as a real
|
34
|
-
`Appsignal::Transaction`, so that you can avoid redundant nil checks.
|
21
|
+
$ gem install appsignal_extensions
|
35
22
|
|
36
|
-
##
|
37
|
-
|
38
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
39
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
40
|
-
* Fork the project.
|
41
|
-
* Start a feature/bugfix branch.
|
42
|
-
* Commit and push until you are happy with your contribution.
|
43
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
44
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
23
|
+
## Usage
|
45
24
|
|
46
|
-
|
25
|
+
TODO: Write usage instructions here
|
47
26
|
|
48
|
-
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/appsignal_extensions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/appsignal_extensions/blob/main/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the AppsignalExtensions project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/appsignal_extensions/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,22 +1,12 @@
|
|
1
|
-
#
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler'
|
4
|
-
require 'bundler/gem_tasks'
|
1
|
+
# frozen_string_literal: true
|
5
2
|
|
6
|
-
require
|
7
|
-
require
|
8
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
9
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
10
|
-
end
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
11
5
|
|
12
|
-
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
13
7
|
|
14
|
-
require
|
15
|
-
Rake::RDocTask.new do |rdoc|
|
16
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
8
|
+
require "rubocop/rake_task"
|
17
9
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
-
end
|
10
|
+
RuboCop::RakeTask.new
|
11
|
+
|
12
|
+
task default: %i[spec rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "appsignal_extensions"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -1,133 +1,135 @@
|
|
1
|
-
require
|
1
|
+
require "delegate"
|
2
2
|
|
3
3
|
# Used to open an Appsignal transaction, but to let the callee close
|
4
4
|
# it when it is done. The standard Rack middleware for Appsignal
|
5
5
|
# closes the transaction as soon as the response triplet gets returned,
|
6
6
|
# we need to keep the transaction open as long as the response is being read.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
module AppsignalExtensions
|
8
|
+
class Middleware
|
9
|
+
# Appsignal::Transaction has no #close method, you have to use a global
|
10
|
+
# function call instead. We wrap it with a simple proxy that provides
|
11
|
+
# close
|
12
|
+
class Close < SimpleDelegator
|
13
|
+
# Closes the current Appsignal transaction
|
14
|
+
def close
|
15
|
+
Appsignal::Transaction.complete_current! if Appsignal.active?
|
16
|
+
end
|
16
17
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
18
|
+
|
19
|
+
# Acts as a null-object replacement for the Appsignal transaction if there is no
|
20
|
+
# transaction to provide (when Appsignal is not defined under jRuby or when
|
21
|
+
# Appsignal is not configured or disabled). Supports the basic method set
|
22
|
+
# that is important for us.
|
23
|
+
class NullTransaction
|
24
|
+
# @return [void]
|
25
|
+
def set_action(*); end
|
26
|
+
|
27
|
+
# @return [void]
|
28
|
+
def set_metadata(*); end
|
29
|
+
|
30
|
+
# @return [void]
|
31
|
+
def set_http_or_background_queue_start(*); end
|
32
|
+
|
33
|
+
# @return [void]
|
34
|
+
def set_error(*); end
|
35
|
+
|
36
|
+
# @return [void]
|
37
|
+
def close(*); end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Acts as a wrapper for Rack response bodies. Ensures that the transaction attached to
|
41
|
+
# the request gets closed after the body #each returns or raises
|
42
|
+
class TransactionClosingBody
|
43
|
+
def initialize(body, transaction)
|
44
|
+
@body = body
|
45
|
+
@transaction = transaction
|
46
|
+
end
|
47
|
+
|
48
|
+
def each(&block)
|
49
|
+
@body.each(&block)
|
50
|
+
rescue Exception => e
|
51
|
+
@transaction.set_error(e)
|
52
|
+
raise e
|
53
|
+
ensure
|
54
|
+
@transaction.close
|
55
|
+
end
|
56
|
+
|
57
|
+
def close
|
58
|
+
@body.close if @body.respond_to?(:close)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Creates a new Appsignal middleware handler with the given Rack app as a callee
|
63
|
+
#
|
64
|
+
# @param app[#call] the Rack app
|
65
|
+
def initialize(app)
|
66
|
+
@app = app
|
67
|
+
end
|
68
|
+
|
69
|
+
# Calls the application, captures errors, sets up wrappers and so forth
|
70
|
+
#
|
71
|
+
# @param env[Hash] the Rack env
|
72
|
+
# @return [Array] the Rack response triplet from upstream
|
73
|
+
def call(env)
|
74
|
+
request = ::Rack::Request.new(env)
|
75
|
+
env["action_dispatch.request_id"] ||= SecureRandom.uuid
|
76
|
+
if Appsignal.active?
|
77
|
+
call_with_appsignal(env, request)
|
78
|
+
else
|
79
|
+
call_with_null_transaction(env, request)
|
80
|
+
end
|
45
81
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def call_and_capture(env, transaction, request)
|
86
|
+
env["appsignal.transaction"] = transaction
|
87
|
+
app_name = @app.is_a?(Module) ? @app.to_s : @app.class.to_s # Set the class name properly
|
88
|
+
transaction.set_action(format("%s#%s", app_name, "call"))
|
89
|
+
transaction.set_metadata("path", request.path)
|
90
|
+
transaction.set_metadata("method", request.request_method)
|
91
|
+
transaction.set_http_or_background_queue_start
|
92
|
+
s, h, b = @app.call(env)
|
93
|
+
|
94
|
+
# If the app we called wants to close the transaction on it's own, return the response. This
|
95
|
+
# is useful if the app will clean up or close the transaction within an async.callback block,
|
96
|
+
# or within the long response body, or within a hijack proc.
|
97
|
+
return [s, h, b] if h.delete("appsignal.suspend")
|
98
|
+
|
99
|
+
# If the app didn't ask for the explicit suspend, Wrap the response in a self-closing wrapper
|
100
|
+
# so that the transaction is closed once the response is read in full. This wrapper only works
|
101
|
+
# with response bodies that support #each().
|
102
|
+
closing_wrapper = TransactionClosingBody.new(b, transaction)
|
103
|
+
[s, h, closing_wrapper]
|
49
104
|
rescue Exception => e
|
50
|
-
|
105
|
+
# If the raise happens immediately (not in the response read cycle)
|
106
|
+
# set the error and close the transaction so that the data gets sent
|
107
|
+
# to Appsignal right away, and ensure it gets closed
|
108
|
+
transaction.set_error(e)
|
109
|
+
transaction.close
|
51
110
|
raise e
|
52
|
-
ensure
|
53
|
-
@transaction.close
|
54
111
|
end
|
55
|
-
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
# Creates a new Appsignal middleware handler with the given Rack app as a callee
|
62
|
-
#
|
63
|
-
# @param app[#call] the Rack app
|
64
|
-
def initialize(app)
|
65
|
-
@app = app
|
66
|
-
end
|
67
|
-
|
68
|
-
# Calls the application, captures errors, sets up wrappers and so forth
|
69
|
-
#
|
70
|
-
# @param env[Hash] the Rack env
|
71
|
-
# @return [Array] the Rack response triplet from upstream
|
72
|
-
def call(env)
|
73
|
-
request = ::Rack::Request.new(env)
|
74
|
-
env['action_dispatch.request_id'] ||= SecureRandom.uuid
|
75
|
-
if Appsignal.active?
|
76
|
-
call_with_appsignal(env, request)
|
77
|
-
else
|
78
|
-
call_with_null_transaction(env, request)
|
112
|
+
|
113
|
+
def call_with_null_transaction(env, request)
|
114
|
+
# Supply the app with a null transaction
|
115
|
+
call_and_capture(env, NullTransaction.new, request)
|
79
116
|
end
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
return [s, h, b] if h.delete('appsignal.suspend')
|
97
|
-
|
98
|
-
# If the app didn't ask for the explicit suspend, Wrap the response in a self-closing wrapper
|
99
|
-
# so that the transaction is closed once the response is read in full. This wrapper only works
|
100
|
-
# with response bodies that support #each().
|
101
|
-
closing_wrapper = TransactionClosingBody.new(b, transaction)
|
102
|
-
[s, h, closing_wrapper]
|
103
|
-
rescue Exception => e
|
104
|
-
# If the raise happens immediately (not in the response read cycle)
|
105
|
-
# set the error and close the transaction so that the data gets sent
|
106
|
-
# to Appsignal right away, and ensure it gets closed
|
107
|
-
transaction.set_error(e)
|
108
|
-
transaction.close
|
109
|
-
raise e
|
110
|
-
end
|
111
|
-
|
112
|
-
def call_with_null_transaction(env, request)
|
113
|
-
# Supply the app with a null transaction
|
114
|
-
call_and_capture(env, NullTransaction.new, request)
|
115
|
-
end
|
116
|
-
|
117
|
-
def call_with_appsignal(env, request)
|
118
|
-
bare_transaction = Appsignal::Transaction.create(
|
119
|
-
env.fetch('action_dispatch.request_id'),
|
120
|
-
Appsignal::Transaction::HTTP_REQUEST,
|
121
|
-
request
|
122
|
-
)
|
123
|
-
|
124
|
-
# Let the app do something to the appsignal transaction if it wants to
|
125
|
-
# Instrument a `process_action`, to set params/action name
|
126
|
-
transaction = Close.new(bare_transaction)
|
127
|
-
status, headers, body = Appsignal.instrument('process_action.rack') do
|
128
|
-
call_and_capture(env, transaction, request)
|
117
|
+
|
118
|
+
def call_with_appsignal(env, request)
|
119
|
+
bare_transaction = Appsignal::Transaction.create(
|
120
|
+
env.fetch("action_dispatch.request_id"),
|
121
|
+
Appsignal::Transaction::HTTP_REQUEST,
|
122
|
+
request
|
123
|
+
)
|
124
|
+
|
125
|
+
# Let the app do something to the appsignal transaction if it wants to
|
126
|
+
# Instrument a `process_action`, to set params/action name
|
127
|
+
transaction = Close.new(bare_transaction)
|
128
|
+
status, headers, body = Appsignal.instrument("process_action.rack") do
|
129
|
+
call_and_capture(env, transaction, request)
|
130
|
+
end
|
131
|
+
|
132
|
+
[status, headers, body]
|
129
133
|
end
|
130
|
-
|
131
|
-
[status, headers, body]
|
132
134
|
end
|
133
135
|
end
|
data/lib/appsignal_extensions.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "appsignal"
|
2
2
|
|
3
3
|
module AppsignalExtensions
|
4
|
-
require_relative
|
5
|
-
require_relative
|
4
|
+
require_relative "appsignal_extensions/version"
|
5
|
+
require_relative "appsignal_extensions/middleware"
|
6
6
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
|
-
|
9
|
-
|
8
|
+
- grdw
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: appsignal
|
@@ -25,19 +26,19 @@ dependencies:
|
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '2'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
+
name: bundler
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
32
|
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
+
version: '2.0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
39
|
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
+
version: '2.0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: rack-test
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,19 +54,19 @@ dependencies:
|
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '0'
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
57
|
+
name: rake
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
60
|
- - "~>"
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
+
version: '13'
|
62
63
|
type: :development
|
63
64
|
prerelease: false
|
64
65
|
version_requirements: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
67
|
- - "~>"
|
67
68
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
+
version: '13'
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
71
|
name: rdoc
|
71
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,43 +82,61 @@ dependencies:
|
|
81
82
|
- !ruby/object:Gem::Version
|
82
83
|
version: '6'
|
83
84
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
85
|
+
name: rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 3.10.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 3.10.0
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rubocop
|
85
100
|
requirement: !ruby/object:Gem::Requirement
|
86
101
|
requirements:
|
87
102
|
- - "~>"
|
88
103
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
104
|
+
version: '1.21'
|
90
105
|
type: :development
|
91
106
|
prerelease: false
|
92
107
|
version_requirements: !ruby/object:Gem::Requirement
|
93
108
|
requirements:
|
94
109
|
- - "~>"
|
95
110
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
111
|
+
version: '1.21'
|
97
112
|
description: Doing some more with Appsignal
|
98
|
-
email:
|
113
|
+
email:
|
114
|
+
- me@julik.nl
|
115
|
+
- gerard@wetransfer.com
|
99
116
|
executables: []
|
100
117
|
extensions: []
|
101
|
-
extra_rdoc_files:
|
102
|
-
- LICENSE.txt
|
103
|
-
- README.md
|
118
|
+
extra_rdoc_files: []
|
104
119
|
files:
|
105
|
-
- ".document"
|
106
|
-
- ".gitignore"
|
107
120
|
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- CODE_OF_CONDUCT.md
|
108
123
|
- Gemfile
|
124
|
+
- Gemfile.lock
|
109
125
|
- LICENSE.txt
|
110
126
|
- README.md
|
111
127
|
- Rakefile
|
112
|
-
-
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
113
130
|
- lib/appsignal_extensions.rb
|
114
131
|
- lib/appsignal_extensions/middleware.rb
|
115
132
|
- lib/appsignal_extensions/version.rb
|
116
133
|
homepage: https://gitlab.wetransfer.net/julik/appsignal_extensions
|
117
134
|
licenses:
|
118
135
|
- MIT
|
119
|
-
metadata:
|
120
|
-
|
136
|
+
metadata:
|
137
|
+
homepage_uri: https://gitlab.wetransfer.net/julik/appsignal_extensions
|
138
|
+
source_code_uri: https://gitlab.wetransfer.net/julik/appsignal_extensions
|
139
|
+
post_install_message:
|
121
140
|
rdoc_options: []
|
122
141
|
require_paths:
|
123
142
|
- lib
|
@@ -125,16 +144,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
144
|
requirements:
|
126
145
|
- - ">="
|
127
146
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
147
|
+
version: 2.6.0
|
129
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
149
|
requirements:
|
131
150
|
- - ">="
|
132
151
|
- !ruby/object:Gem::Version
|
133
152
|
version: '0'
|
134
153
|
requirements: []
|
135
|
-
|
136
|
-
|
137
|
-
signing_key:
|
154
|
+
rubygems_version: 3.2.22
|
155
|
+
signing_key:
|
138
156
|
specification_version: 4
|
139
157
|
summary: Suspend an Appsignal transaction for long responses
|
140
158
|
test_files: []
|
data/.document
DELETED
data/.gitignore
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# rcov generated
|
2
|
-
coverage
|
3
|
-
coverage.data
|
4
|
-
|
5
|
-
# rdoc generated
|
6
|
-
rdoc
|
7
|
-
|
8
|
-
# yard generated
|
9
|
-
doc
|
10
|
-
.yardoc
|
11
|
-
|
12
|
-
# bundler
|
13
|
-
.bundle
|
14
|
-
Gemfile.lock
|
15
|
-
|
16
|
-
# jeweler generated
|
17
|
-
pkg
|
18
|
-
|
19
|
-
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
20
|
-
#
|
21
|
-
# * Create a file at ~/.gitignore
|
22
|
-
# * Include files you want ignored
|
23
|
-
# * Run: git config --global core.excludesfile ~/.gitignore
|
24
|
-
#
|
25
|
-
# After doing this, these files will be ignored in all your git projects,
|
26
|
-
# saving you from having to 'pollute' every project you touch with them
|
27
|
-
#
|
28
|
-
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
29
|
-
#
|
30
|
-
# For MacOS:
|
31
|
-
#
|
32
|
-
#.DS_Store
|
33
|
-
|
34
|
-
# For TextMate
|
35
|
-
#*.tmproj
|
36
|
-
#tmtags
|
37
|
-
|
38
|
-
# For emacs:
|
39
|
-
#*~
|
40
|
-
#\#*
|
41
|
-
#.\#*
|
42
|
-
|
43
|
-
# For vim:
|
44
|
-
#*.swp
|
45
|
-
|
46
|
-
# For redcar:
|
47
|
-
#.redcar
|
48
|
-
|
49
|
-
# For rubinius:
|
50
|
-
#*.rbc
|
@@ -1,33 +0,0 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'appsignal_extensions/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "appsignal_extensions"
|
7
|
-
s.version = AppsignalExtensions::VERSION
|
8
|
-
|
9
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
|
-
s.require_paths = ["lib"]
|
11
|
-
s.authors = ["Julik Tarkhanov"]
|
12
|
-
s.date = "2016-03-17"
|
13
|
-
s.description = "Doing some more with Appsignal"
|
14
|
-
s.email = "me@julik.nl"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
-
f.match(%r{^(test|spec|features)/})
|
21
|
-
end
|
22
|
-
s.homepage = "https://gitlab.wetransfer.net/julik/appsignal_extensions"
|
23
|
-
s.licenses = ["MIT"]
|
24
|
-
s.rubygems_version = "2.2.2"
|
25
|
-
s.summary = "Suspend an Appsignal transaction for long responses"
|
26
|
-
s.specification_version = 4
|
27
|
-
s.add_runtime_dependency(%q<appsignal>, ["~> 2"])
|
28
|
-
s.add_development_dependency(%q<rake>, ["~> 10"])
|
29
|
-
s.add_development_dependency(%q<rack-test>, [">= 0"])
|
30
|
-
s.add_development_dependency(%q<rspec>, ["~> 3.2.0"])
|
31
|
-
s.add_development_dependency(%q<rdoc>, ["~> 6"])
|
32
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
33
|
-
end
|