semlogr-faraday 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +36 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +3 -0
- data/LICENSE.md +21 -0
- data/README.md +47 -0
- data/Rakefile +8 -0
- data/bin/console +7 -0
- data/bin/setup +7 -0
- data/lib/semlogr/faraday/request_correlator.rb +20 -0
- data/lib/semlogr/faraday/version.rb +5 -0
- data/lib/semlogr/faraday.rb +12 -0
- data/semlogr-faraday.gemspec +29 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 49b7851150bc4dc0e64ddb2a2b790888a3d5705f15df1656dc6dd35cf28521db
|
4
|
+
data.tar.gz: 07f786bd6eef15486aee52b3637a53ca8f078f1c8a62a127792e0176c16bc5ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f694f3f36680d656b425bdb5dd41dc58e239ab2b8eaa1f89384347bb58daa08b6b8b503d9546e5c48c052a471be7c8751201ea8495df89ffe593367fe6f19569
|
7
|
+
data.tar.gz: 889fc17386e499d8f8ecd6364a4a3556e2670b45cf7ae2df593475587d7e7d3ba56b57bc7c8e84a69b3076f57e59c94a72a0ceaf0adcdd4b1ec2d39bdbce2ef1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
|
4
|
+
Documentation:
|
5
|
+
Enabled: false
|
6
|
+
OrderedGems:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Layout/MultilineMethodCallIndentation:
|
10
|
+
EnforcedStyle: indented
|
11
|
+
|
12
|
+
# Do not use Rubocop to enforce complexity rules, these will me
|
13
|
+
# managed via the PR prorcess to not let in clearly complex code.
|
14
|
+
Metrics/ClassLength:
|
15
|
+
Enabled: false
|
16
|
+
Metrics/ModuleLength:
|
17
|
+
Enabled: false
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Enabled: false
|
20
|
+
Metrics/BlockNesting:
|
21
|
+
Enabled: false
|
22
|
+
Metrics/AbcSize:
|
23
|
+
Enabled: false
|
24
|
+
Metrics/CyclomaticComplexity:
|
25
|
+
Enabled: false
|
26
|
+
Metrics/ParameterLists:
|
27
|
+
Enabled: false
|
28
|
+
Metrics/BlockLength:
|
29
|
+
Enabled: false
|
30
|
+
Metrics/PerceivedComplexity:
|
31
|
+
Enabled: false
|
32
|
+
Metrics/LineLength:
|
33
|
+
Enabled: false
|
34
|
+
|
35
|
+
Style/EmptyMethod:
|
36
|
+
EnforcedStyle: expanded
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
### 0.1.2
|
4
|
+
|
5
|
+
- Change request logger to log only path without query string
|
6
|
+
|
7
|
+
### 0.1.1
|
8
|
+
|
9
|
+
- Add support for filtering requests by path for the request logger
|
10
|
+
- Add log correlator middleware which provides the ability to propogate a correlation id from a request header to the Semlogr ambient log context
|
11
|
+
|
12
|
+
### 0.1.0
|
13
|
+
|
14
|
+
- Initial release
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Semlogr
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+

|
2
|
+
|
3
|
+
# Semlogr integration for Faraday
|
4
|
+
|
5
|
+
This integration provides the ability to propogate a correlation id from the current log Semlogr context to
|
6
|
+
your outgoing Faraday requests.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
To install:
|
11
|
+
|
12
|
+
gem install semlogr-faraday
|
13
|
+
|
14
|
+
Or if using bundler, add semlogr to your Gemfile:
|
15
|
+
|
16
|
+
gem 'semlogr-faraday'
|
17
|
+
|
18
|
+
then:
|
19
|
+
|
20
|
+
bundle install
|
21
|
+
|
22
|
+
## Getting Started
|
23
|
+
|
24
|
+
Simply configure the RequestCorrelator middleware on your Faraday instance, it will propogate the `correlation_id` property from your current Semlogr ambient log context as an outgoing X-Correlation-Id header on the request.
|
25
|
+
|
26
|
+
This can be used in combination with the [semlogr-rack](https://github.com/semlogr/semlogr-rack) extension to
|
27
|
+
provide a full end to end proprogation of correlation ids between your services.
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
require 'semlogr/faraday'
|
31
|
+
|
32
|
+
faraday = Faraday.new 'http://test.com' do |c|
|
33
|
+
c.request :semlogr_request_correlator
|
34
|
+
|
35
|
+
c.adapter Faraday.default_adapter
|
36
|
+
end
|
37
|
+
|
38
|
+
faraday.get('/test')
|
39
|
+
```
|
40
|
+
|
41
|
+
## Development
|
42
|
+
|
43
|
+
After cloning the repository run `bundle install` to get up and running, to run the specs just run `rake spec`.
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
See anything broken or something you would like to improve? feel free to submit an issue or better yet a pull request!
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'semlogr'
|
2
|
+
|
3
|
+
module Semlogr
|
4
|
+
module Faraday
|
5
|
+
class RequestCorrelator
|
6
|
+
def initialize(app, opts = {})
|
7
|
+
@app = app
|
8
|
+
@id_property = opts[:id_property] || :correlation_id
|
9
|
+
@id_header = opts[:id_header] || 'X-Correlation-Id'
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
correlation_id = Semlogr::LogContext.get_property(@id_property)
|
14
|
+
env[:request_headers][@id_header] = correlation_id if correlation_id
|
15
|
+
|
16
|
+
@app.call(env)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'semlogr/faraday/request_correlator'
|
2
|
+
require 'faraday'
|
3
|
+
|
4
|
+
module Semlogr
|
5
|
+
module Faraday
|
6
|
+
if ::Faraday::Middleware.respond_to?(:register_middleware)
|
7
|
+
::Faraday::Request.register_middleware(
|
8
|
+
semlogr_request_correlator: -> { Semlogr::Faraday::RequestCorrelator }
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'semlogr/faraday/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'semlogr-faraday'
|
8
|
+
spec.version = Semlogr::Faraday::VERSION
|
9
|
+
spec.authors = ['Stefan Sedich']
|
10
|
+
spec.email = ['stefan.sedich@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Semlogr integration for faraday.'
|
13
|
+
spec.description = 'Semlogr integration for faraday providing features such as correlation id propogation.'
|
14
|
+
spec.homepage = 'https://github.com/semlogr/semlogr-faraday'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'faraday', '~> 0.12'
|
22
|
+
spec.add_dependency 'semlogr', '~> 0.3'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
25
|
+
spec.add_development_dependency 'pry', '~> 0.11'
|
26
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 0.53'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: semlogr-faraday
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefan Sedich
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.12'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: semlogr
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.13'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '12.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '12.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.53'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.53'
|
111
|
+
description: Semlogr integration for faraday providing features such as correlation
|
112
|
+
id propogation.
|
113
|
+
email:
|
114
|
+
- stefan.sedich@gmail.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- CHANGELOG.md
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE.md
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- bin/console
|
128
|
+
- bin/setup
|
129
|
+
- lib/semlogr/faraday.rb
|
130
|
+
- lib/semlogr/faraday/request_correlator.rb
|
131
|
+
- lib/semlogr/faraday/version.rb
|
132
|
+
- semlogr-faraday.gemspec
|
133
|
+
homepage: https://github.com/semlogr/semlogr-faraday
|
134
|
+
licenses: []
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.7.3
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Semlogr integration for faraday.
|
156
|
+
test_files: []
|