moesif_rack 1.2.0 → 1.2.1

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
- SHA1:
3
- metadata.gz: a3430c81bf72498e9f28af81f8a3499ebd65ec42
4
- data.tar.gz: e290f3cc3f22d2f7fb8dc08df23970e33177c5c3
2
+ SHA256:
3
+ metadata.gz: 7e1428b66ed485afba9cf2ab43971601e9669ff206898b3154ae4cc0f5acc9ea
4
+ data.tar.gz: d0d43c941dc9d4f6e3de05481ce9ff72e8abea7c7dc7c1e7654d3b9c62d8aace
5
5
  SHA512:
6
- metadata.gz: 9f40f2d4e9e939823de3335562a31a375e8674c1b3e7ce290971d2063d6ca2320992b37e3d20f547500e06606bfb0c4d244e58c72caf66c5832cea8bffd42dca
7
- data.tar.gz: 86a3f26d882c26a5f3875ed62600289e87edb70dbdd8f57aa36a5fd7940c2bf19af52ef9fdf61c9e179a8443bfcc11981ada257c711fabf05843ff14a298c1d2
6
+ metadata.gz: e9210baad343a849dd783bdcf5bab64110b4dda2a03d63f27b4d618227d66e93294a02130815d1d71b72c358e0831e33bbfe4e83411497f940bb47faaf5b503e
7
+ data.tar.gz: 9be04c33ed72ecaa24305ecddab2d647031f1f08178a825921fb025a2664bcbf51cdb2c76239733d34b0fdc7d6474dc9f8b162aef97c5a1d99964d77ea78dd9e
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016 Moesif, Inc
1
+ Copyright (c) 2018 Moesif, Inc
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -213,4 +213,4 @@ limitations under the License.
213
213
  distributed under the License is distributed on an "AS IS" BASIS,
214
214
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
215
215
  See the License for the specific language governing permissions and
216
- limitations under the License.
216
+ limitations under the License.
data/README.md CHANGED
@@ -1,10 +1,15 @@
1
1
  # Moesif Middleware for Ruby on Rails and Rack
2
2
 
3
- Rack Middleware that logs _incoming_ API calls to Moesif for advanced error analysis for apps built on Ruby on Rails / Rack.
3
+ [![Built For rack][ico-built-for]][link-built-for]
4
+ [![Latest Version][ico-version]][link-package]
5
+ [![Total Downloads][ico-downloads]][link-downloads]
6
+ [![Software License][ico-license]][link-license]
7
+ [![Source Code][ico-source]][link-source]
4
8
 
5
- [Source Code on GitHub](https://github.com/moesif/moesif-rack)
9
+ Rack Middleware that logs _incoming_ API calls to Moesif's AI-powered API analytics service.
10
+ Supports Ruby on Rails apps and other Ruby frameworks built on Rack.
6
11
 
7
- [Ruby Gem](https://rubygems.org/gems/moesif_rack)
12
+ [Source Code on GitHub](https://github.com/moesif/moesif-rack)
8
13
 
9
14
  ## How to install
10
15
 
@@ -15,7 +20,7 @@ gem install moesif_rack
15
20
  and if you have a `Gemfile` in your project, please add this line to
16
21
 
17
22
  ```
18
- gem 'moesif_rack', '~> 1.1.0'
23
+ gem 'moesif_rack', '~> 1.2.0'
19
24
 
20
25
  ```
21
26
 
@@ -190,4 +195,16 @@ for reference.
190
195
 
191
196
  ## Other integrations
192
197
 
193
- To view more more documentation on integration options, please visit __[the Integration Options Documentation](https://www.moesif.com/docs/getting-started/integration-options/).__
198
+ To view more more documentation on integration options, please visit __[the Integration Options Documentation](https://www.moesif.com/docs/getting-started/integration-options/).
199
+
200
+ [ico-built-for]: https://img.shields.io/badge/built%20for-rack-blue.svg
201
+ [ico-version]: https://img.shields.io/gem/v/moesif_rack.svg
202
+ [ico-downloads]: https://img.shields.io/gem/dt/moesif_rack.svg
203
+ [ico-license]: https://img.shields.io/badge/License-Apache%202.0-green.svg
204
+ [ico-source]: https://img.shields.io/github/last-commit/moesif/moesif-rack.svg?style=social
205
+
206
+ [link-built-for]: https://github.com/rack/rack
207
+ [link-package]: https://rubygems.org/gems/moesif_rack
208
+ [link-downloads]: https://rubygems.org/gems/moesif_rack
209
+ [link-license]: https://raw.githubusercontent.com/Moesif/moesif-rack/master/LICENSE
210
+ [link-source]: https://github.com/moesif/moesif-rack
@@ -21,6 +21,10 @@ module MoesifRack
21
21
  @mask_data = options['mask_data']
22
22
  @skip = options['skip']
23
23
  @debug = options['debug']
24
+ @sampling_percentage = options['sampling_percentage'] || 100
25
+ if not @sampling_percentage.is_a? Numeric
26
+ raise "Sampling Percentage should be a number"
27
+ end
24
28
  end
25
29
 
26
30
  def call env
@@ -128,7 +132,17 @@ module MoesifRack
128
132
  end
129
133
  # Perform the API call through the SDK function
130
134
  begin
131
- @api_controller.create_event(event_model)
135
+ @random_percentage = Random.rand(0.00..100.00)
136
+ if @sampling_percentage > @random_percentage
137
+ @api_controller.create_event(event_model)
138
+ if @debug
139
+ puts("Event successfully sent to Moesif")
140
+ end
141
+ else
142
+ if @debug
143
+ puts("Skipped Event due to sampling percentage: " + @sampling_percentage.to_s + " and random percentage: " + @random_percentage.to_s);
144
+ end
145
+ end
132
146
  rescue MoesifApi::APIException => e
133
147
  if e.response_code.between?(401, 403)
134
148
  puts "Unathorized accesss sending event to Moesif. Please verify your Application Id."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moesif_rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moesif, Inc
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-10-11 00:00:00.000000000 Z
12
+ date: 2018-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 2.6.7
100
+ rubygems_version: 2.7.7
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: moesif_rack