datadog-json_logger 0.1.3 → 0.1.4

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: beb6fb82518d662d8db07b415cc953e99fc67348208aa5f34a1b02111ce487a8
4
- data.tar.gz: d555d69fe127aaedd4505b69e0d790cc03d43eb23a711895cc46fc35cd10d19c
3
+ metadata.gz: ba2bce053c01ef4787e60b782e1796f050d0d1462af869de7f09594a18bb1476
4
+ data.tar.gz: 980509d54903433e0a4e755c3a2d73e96a192ad8a732bf1c119dc675846f8563
5
5
  SHA512:
6
- metadata.gz: 6710e8f18de45387168fafc58bfb54d84731af279707a9c1788c60f569b846dd581d080d8f7e8ebb8e70e24f2d66ff88829ca5e9d1e51cfb2f7c6550ba36abc8
7
- data.tar.gz: a707d9786bf1fb06ce3607b134fd6feb892d60287f94eb7e87888d76ffcb56872d8faa513f8c81cf43db18d9de65770f66814f5147884deb2efa56e29f7c04a0
6
+ metadata.gz: 89da523671f52049de515a7299ab7f664d03925d777c16648de762859807c88f0fbdf3a20ed1ce438fcb4fdb9c6b459cf6674e7057a2daa62dadc65cde9b7580
7
+ data.tar.gz: e75b0d5ae7c83847ebd3aeca11611f05f11a5ac4ce7edfc7cb768e7fe4b91d6451d3d5dffd2f932faf38eb7985b8e8752419b0e09e1c8309caf55fcce826bacc
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Datadog
4
4
  module Loggers
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
@@ -16,16 +16,21 @@ module Datadog
16
16
  class SinatraMiddleware
17
17
  attr_reader :app, :logger
18
18
 
19
- def initialize(app, logger)
19
+ def initialize(app, logger, opt = {})
20
20
  @app = app
21
21
  @logger = logger
22
+ @raise_exceptions = opt.fetch(:raise_exceptions, false)
22
23
  end
23
24
 
24
25
  def call(env)
25
26
  request = Rack::Request.new(env)
26
27
  start_time = Time.now
27
28
 
28
- status, headers, body = safely_process_request(env)
29
+ status, headers, body = if @raise_exceptions
30
+ app.call(env)
31
+ else
32
+ safely_process_request(env)
33
+ end
29
34
  end_time = Time.now
30
35
 
31
36
  log_request(request, env, status, headers, start_time, end_time)
@@ -39,8 +44,8 @@ module Datadog
39
44
 
40
45
  def safely_process_request(env)
41
46
  app.call(env)
42
- rescue StandardError
43
- [500, { "Content-Type": "text/html" }, ["Internal Server Error"]]
47
+ rescue StandardError => e
48
+ [500, { "Content-Type": "application/json" }, [e.class.name, e.message].join(": ")]
44
49
  end
45
50
 
46
51
  def log_request(request, env, status, headers, start_time, end_time)
@@ -7,14 +7,13 @@ end
7
7
  module Datadog
8
8
  class SinatraMiddleware
9
9
  @app: untyped
10
-
11
10
  @logger: Logger
11
+ @raise_exceptions: bool
12
12
 
13
13
  attr_reader app: untyped
14
-
15
14
  attr_reader logger: Logger
16
15
 
17
- def initialize: (untyped app, Logger logger) -> void
16
+ def initialize: (untyped app, Logger logger, ?Hash[Symbol, untyped] opt) -> void
18
17
 
19
18
  def call: (untyped env) -> untyped
20
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog-json_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eth3rnit3