elastic-apm 3.11.1 → 3.12.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
  SHA256:
3
- metadata.gz: 54d7b5d46523e74fc797ec2030a355b6137e92a40ecb8242a9a79d551d6b2f89
4
- data.tar.gz: ba614dd32ce665845f09d9c840fff0f6e8a34637a703f849a7b22edbeb350d25
3
+ metadata.gz: 0c810b4e9b4f1149873235af4d1ddd6b4a85acf7734c491a42d21777443d57a0
4
+ data.tar.gz: f63af16c444a3a5499cd9246b1d11bba2cd9a7a31efed58bfd23d5b1c8b3e0d3
5
5
  SHA512:
6
- metadata.gz: fd0d35a56be409fd3ee55352d68a9ef7cfd13add082edb41ca971bde54895c70babd30025e6a87134123a999be2732b476a8868b3db617b9f315940124f8e2ad
7
- data.tar.gz: 75e7e737b4f927dbbbb6b828ae5c628b3e37334409a43b1e94cc09cb9b403dcbb7030e766e49cadba9683536032119514f022570abb97c066fce6a59959dbf6f
6
+ metadata.gz: ed48f7f3870b346a17ec5e263c90c67f68b1f355a4900c3a79ae998bf689b1b549e6658d7c4165b934091669734bea561acf9991b82446a6ca4164558a488301
7
+ data.tar.gz: f87f347bf3a72e8d331e95d95ceca640d12754cb049ce4c39097b03b75d022c347f95062d3e311e0fb0cbc90f61050449ed1bd6f39f8682c95e935fccf7509f9
@@ -35,6 +35,14 @@ endif::[]
35
35
  [[release-notes-3.x]]
36
36
  === Ruby Agent version 3.x
37
37
 
38
+ [[release-notes-3.12.0]]
39
+ ==== 3.12.0 (2020-11-10)
40
+
41
+ [float]
42
+ ===== Added
43
+
44
+ - Add outcome to transactions and spans {pull}883[#883]
45
+
38
46
  [[release-notes-3.11.1]]
39
47
  ==== 3.11.1 (2020-11-05)
40
48
 
@@ -433,6 +433,7 @@ end
433
433
  - `name`: String
434
434
  - `type`: String
435
435
  - `result`: String
436
+ - `outcome`: String ('unknown', 'success', 'failure', nil)
436
437
  - `trace_id`: String (readonly)
437
438
 
438
439
  [float]
@@ -457,7 +458,7 @@ If your service generates the HTML page dynamically, initializing the
457
458
  JavaScript RUM agent with the value of this method allows analyzing the time
458
459
  spent in the browser vs in the backend services.
459
460
 
460
- To enable the JavaScript RUM agent, initilialize the RUM agent with the Ruby
461
+ To enable the JavaScript RUM agent, initialize the RUM agent with the Ruby
461
462
  agent's current transaction:
462
463
 
463
464
  [source,html]
@@ -183,7 +183,12 @@ module ElasticAPM
183
183
  context: context,
184
184
  trace_context: trace_context
185
185
  )
186
- yield transaction
186
+ result = yield transaction
187
+ transaction&.outcome ||= Transaction::Outcome::SUCCESS
188
+ result
189
+ rescue
190
+ transaction&.outcome ||= Transaction::Outcome::FAILURE
191
+ raise
187
192
  ensure
188
193
  end_transaction
189
194
  end
@@ -287,7 +292,14 @@ module ElasticAPM
287
292
  parent: parent,
288
293
  sync: sync
289
294
  )
290
- yield span
295
+ result = yield span
296
+ span&.outcome =
297
+ Span::Outcome::SUCCESS unless span&.outcome
298
+ result
299
+ rescue
300
+ span&.outcome =
301
+ Span::Outcome::FAILURE unless span&.outcome
302
+ raise
291
303
  ensure
292
304
  end_span
293
305
  end
@@ -41,9 +41,14 @@ module ElasticAPM
41
41
  ElasticAPM.report(e, context: context, handled: false)
42
42
  raise
43
43
  ensure
44
- if resp && transaction
45
- status, headers, _body = resp
46
- transaction.add_response(status, headers: headers.dup)
44
+ if transaction
45
+ if resp
46
+ status, headers, _body = resp
47
+ transaction.add_response(status, headers: headers.dup)
48
+ transaction&.outcome = Transaction::Outcome.from_http_status(status)
49
+ else
50
+ transaction&.outcome = Transaction::Outcome::FAILURE
51
+ end
47
52
  end
48
53
 
49
54
  ElasticAPM.end_transaction http_result(status)
@@ -25,6 +25,17 @@ module ElasticAPM
25
25
  extend Forwardable
26
26
  include ChildDurations::Methods
27
27
 
28
+ # @api private
29
+ class Outcome
30
+ FAILURE = "failure"
31
+ SUCCESS = "success"
32
+ UNKNOWN = "unknown"
33
+
34
+ def self.from_http_status(code)
35
+ code.to_i >= 400 ? FAILURE : SUCCESS
36
+ end
37
+ end
38
+
28
39
  DEFAULT_TYPE = 'custom'
29
40
 
30
41
  # rubocop:disable Metrics/ParameterLists
@@ -67,6 +78,7 @@ module ElasticAPM
67
78
  :action,
68
79
  :name,
69
80
  :original_backtrace,
81
+ :outcome,
70
82
  :subtype,
71
83
  :trace_context,
72
84
  :type
@@ -42,9 +42,11 @@ module ElasticAPM
42
42
  transaction = ElasticAPM.start_transaction(job_name, TYPE)
43
43
  job.invoke_job_without_apm(*args, &block)
44
44
  transaction&.done 'success'
45
+ transaction&.outcome = Transaction::Outcome::SUCCESS
45
46
  rescue ::Exception => e
46
47
  ElasticAPM.report(e, handled: false)
47
48
  transaction&.done 'error'
49
+ transaction&.outcome = Transaction::Outcome::FAILURE
48
50
  raise
49
51
  ensure
50
52
  ElasticAPM.end_transaction
@@ -89,6 +89,7 @@ module ElasticAPM
89
89
  http.status_code = result.status.to_s
90
90
  end
91
91
 
92
+ span&.outcome = Span::Outcome.from_http_status(result.status)
92
93
  result
93
94
  end
94
95
  end
@@ -61,6 +61,7 @@ module ElasticAPM
61
61
  http.status_code = result.status.to_s
62
62
  end
63
63
 
64
+ span&.outcome = Span::Outcome.from_http_status(result.status)
64
65
  result
65
66
  end
66
67
  end
@@ -44,11 +44,15 @@ module ElasticAPM
44
44
  end
45
45
 
46
46
  def failed(event)
47
- pop_event(event)
47
+ span = pop_event(event)
48
+ span&.outcome = Span::Outcome::FAILURE
49
+ span
48
50
  end
49
51
 
50
52
  def succeeded(event)
51
- pop_event(event)
53
+ span = pop_event(event)
54
+ span&.outcome = Span::Outcome::SUCCESS
55
+ span
52
56
  end
53
57
 
54
58
  private
@@ -96,6 +96,7 @@ module ElasticAPM
96
96
  http.status_code = result.code
97
97
  end
98
98
 
99
+ span&.outcome = Span::Outcome.from_http_status(result.code)
99
100
  result
100
101
  end
101
102
  end
@@ -39,9 +39,11 @@ module ElasticAPM
39
39
  begin
40
40
  result = execute_without_apm(*args)
41
41
 
42
- transaction.result = 'success' if transaction
42
+ transaction&.result = 'success'
43
+ transaction&.outcome = Transaction::Outcome::SUCCESS
43
44
  rescue StandardError => e
44
- transaction.result = 'error' if transaction
45
+ transaction&.result = 'error'
46
+ transaction&.outcome = Transaction::Outcome::FAILURE
45
47
  ElasticAPM.report(e)
46
48
 
47
49
  raise
@@ -36,10 +36,12 @@ module ElasticAPM
36
36
  name = @payload && @payload['class']&.to_s
37
37
  transaction = ElasticAPM.start_transaction(name, TYPE)
38
38
  perform_without_elastic_apm
39
- transaction.done 'success'
39
+ transaction&.done 'success'
40
+ transaction&.outcome = Transaction::Outcome::SUCCESS
40
41
  rescue ::Exception => e
41
42
  ElasticAPM.report(e, handled: false)
42
- transaction.done 'error' if transaction
43
+ transaction&.done 'error'
44
+ transaction&.outcome = Transaction::Outcome::FAILURE
43
45
  raise
44
46
  ensure
45
47
  ElasticAPM.end_transaction
@@ -61,7 +61,12 @@ module ElasticAPM
61
61
  action: ACTION,
62
62
  context: context
63
63
  )
64
- yield.tap do |result|
64
+ log_connection_yield_without_apm(
65
+ sql,
66
+ connection,
67
+ args,
68
+ &block
69
+ ).tap do |result|
65
70
  if name =~ /^(UPDATE|DELETE)/
66
71
  if connection.respond_to?(:changes)
67
72
  span.context.db.rows_affected = connection.changes
@@ -70,7 +75,11 @@ module ElasticAPM
70
75
  end
71
76
  end
72
77
  end
78
+ rescue
79
+ span&.outcome = Span::Outcome::FAILURE
80
+ raise
73
81
  ensure
82
+ span&.outcome ||= Span::Outcome::SUCCESS
74
83
  ElasticAPM.end_span
75
84
  end
76
85
  end
@@ -37,9 +37,11 @@ module ElasticAPM
37
37
  yield
38
38
 
39
39
  transaction&.done :success
40
+ transaction&.outcome = Transaction::Outcome::SUCCESS
40
41
  rescue ::Exception => e
41
42
  ElasticAPM.report(e, handled: false)
42
43
  transaction&.done :error
44
+ transaction&.outcome = Transaction::Outcome::FAILURE
43
45
  raise
44
46
  ensure
45
47
  ElasticAPM.end_transaction
@@ -35,9 +35,11 @@ module ElasticAPM
35
35
  yield
36
36
 
37
37
  transaction&.done :success
38
+ transaction&.outcome = Transaction::Outcome::SUCCESS
38
39
  rescue ::Exception => e
39
40
  ElasticAPM.report(e, handled: false)
40
41
  transaction&.done :error
42
+ transaction&.outcome = Transaction::Outcome::FAILURE
41
43
  raise
42
44
  ensure
43
45
  ElasticAPM.end_transaction
@@ -57,11 +57,13 @@ module ElasticAPM
57
57
 
58
58
  res = @app.call(deserialized_msg, delivery_info, metadata, handler)
59
59
  transaction&.done(:success)
60
+ transaction&.outcome = Transaction::Outcome::SUCCESS
60
61
 
61
62
  res
62
63
  rescue ::Exception => e
63
64
  ElasticAPM.report(e, handled: false)
64
65
  transaction&.done(:error)
66
+ transaction&.outcome = Transaction::Outcome::FAILURE
65
67
  raise
66
68
  ensure
67
69
  ElasticAPM.end_transaction
@@ -35,12 +35,14 @@ module ElasticAPM
35
35
  transaction = ElasticAPM.start_transaction(name, TYPE)
36
36
  __run_perform_without_elastic_apm(*args)
37
37
  transaction.done 'success'
38
+ transaction&.outcome = Transaction::Outcome::SUCCESS
38
39
  rescue ::Exception => e
39
40
  # Note that SuckerPunch by default doesn't raise the errors from
40
41
  # the user-defined JobClass#perform method as it uses an error
41
42
  # handler, accessed via `SuckerPunch.exception_handler`.
42
43
  ElasticAPM.report(e, handled: false)
43
44
  transaction.done 'error'
45
+ transaction&.outcome = Transaction::Outcome::FAILURE
44
46
  raise
45
47
  ensure
46
48
  ElasticAPM.end_transaction
@@ -20,6 +20,18 @@
20
20
  module ElasticAPM
21
21
  # @api private
22
22
  class Transaction
23
+
24
+ # @api private
25
+ class Outcome
26
+ FAILURE = "failure"
27
+ SUCCESS = "success"
28
+ UNKNOWN = "unknown"
29
+
30
+ def self.from_http_status(code)
31
+ code.to_i >= 500 ? FAILURE : SUCCESS
32
+ end
33
+ end
34
+
23
35
  extend Forwardable
24
36
  include ChildDurations::Methods
25
37
 
@@ -74,7 +86,7 @@ module ElasticAPM
74
86
  end
75
87
  # rubocop:enable Metrics/ParameterLists
76
88
 
77
- attr_accessor :name, :type, :result
89
+ attr_accessor :name, :type, :result, :outcome
78
90
 
79
91
  attr_reader(
80
92
  :breakdown_metrics,
@@ -43,7 +43,8 @@ module ElasticAPM
43
43
  stacktrace: span.stacktrace.to_a,
44
44
  timestamp: span.timestamp,
45
45
  trace_id: span.trace_id,
46
- sample_rate: span.sample_rate
46
+ sample_rate: span.sample_rate,
47
+ outcome: keyword_field(span.outcome)
47
48
  }
48
49
  }
49
50
  end
@@ -35,6 +35,7 @@ module ElasticAPM
35
35
  name: keyword_field(transaction.name),
36
36
  type: keyword_field(transaction.type),
37
37
  result: keyword_field(transaction.result.to_s),
38
+ outcome: keyword_field(transaction.outcome),
38
39
  duration: ms(transaction.duration),
39
40
  timestamp: transaction.timestamp,
40
41
  sampled: transaction.sampled?,
@@ -18,5 +18,5 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  module ElasticAPM
21
- VERSION = '3.11.1'
21
+ VERSION = '3.12.0'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.1
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-05 00:00:00.000000000 Z
11
+ date: 2020-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
- description:
41
+ description:
42
42
  email:
43
43
  - mikkel@elastic.co
44
44
  executables: []
@@ -245,7 +245,7 @@ licenses:
245
245
  - Apache-2.0
246
246
  metadata:
247
247
  source_code_uri: https://github.com/elastic/apm-agent-ruby
248
- post_install_message:
248
+ post_install_message:
249
249
  rdoc_options: []
250
250
  require_paths:
251
251
  - lib
@@ -260,8 +260,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  - !ruby/object:Gem::Version
261
261
  version: '0'
262
262
  requirements: []
263
- rubygems_version: 3.0.3
264
- signing_key:
263
+ rubygems_version: 3.0.6
264
+ signing_key:
265
265
  specification_version: 4
266
266
  summary: The official Elastic APM agent for Ruby
267
267
  test_files: []