atatus 1.5.0 → 1.6.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: 8f1224097b7365777c25187cfc37e91183820049468b600c440a267e56eedab3
4
- data.tar.gz: bfa687f00c9fc260b2b1c2530f98221feb145097ea950327dd50ed28d3c93f49
3
+ metadata.gz: fdb76c9559c230c2e772a5878d82486da076104089c39302722fccca8f0c22db
4
+ data.tar.gz: 20233ccdea5269e3b3eb6c7c348091a161f875fbd1946554bdd314ee09f55ba2
5
5
  SHA512:
6
- metadata.gz: c534a65922f5a3b4a82965af2eeeabd2b1f6d634cad3857054a2c4ae517a7fcda79bd6d9664874c1bd411078d7e0adfc27eba1c4c523d24e5195299b42fefb81
7
- data.tar.gz: '078b28a6a86fa7d96c726e14f8cd8a8892efad31d839b843d58c6fd1c7229b7d8df36a21eaaea550ba2dcdd14431165ee317d31d0bb0bf34539f25f320b7d200'
6
+ metadata.gz: c0dfd9f4d6ecddad2036b1b289ec864ea0edbc5f0949bfd76639b741e5a6be6ca2da9840347b10950635a235df37c20c9464505675e022b10d5c9341dc2807c1
7
+ data.tar.gz: 38d6f642f6f413e8c0ed989ba28d70bb9ce9643525fa28156ce8853e3781c1b3d3e9329d06d9ed0d8b7096a7d6799ad8817701012007a443f9a44a47ecf16136
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
7
 
8
+ ## 1.6.0 (Fri, 24 Dec 2021)
9
+
10
+ - Added support for set custom data.
11
+ - Fixed the span timing issue.
12
+
13
+
8
14
  ## 1.5.0 (Thu, 27 May 2021)
9
15
 
10
16
  - Fixed issue in status code conversion.
@@ -7,7 +7,7 @@ require 'atatus/collector/hist'
7
7
  require 'atatus/collector/layer'
8
8
  require 'atatus/collector/transport'
9
9
 
10
- SpanTiming = Struct.new(:start, :end)
10
+ SpanTiming = Struct.new(:name, :type, :subtype, :start, :end, :duration, :id, :transaction_id)
11
11
 
12
12
  module Atatus
13
13
  module Collector
@@ -204,16 +204,7 @@ module Atatus
204
204
 
205
205
  if span.timestamp >= txn.timestamp
206
206
  start = Util.ms(span.timestamp - txn.timestamp)
207
- spans_tuple.push(SpanTiming.new(start, start + Util.ms(span.duration)))
208
- if !@txns_agg[txn.name].spans.key?(span.name)
209
- kind = Layer.span_kind(span.type)
210
- type = Layer.span_type(span.subtype)
211
- @txns_agg[txn.name].spans[span.name] = Layer.new(type, kind, span.duration)
212
- @txns_agg[txn.name].spans[span.name].id = span.id
213
- @txns_agg[txn.name].spans[span.name].pid = span.transaction_id
214
- else
215
- @txns_agg[txn.name].spans[span.name].aggregate! span.duration
216
- end
207
+ spans_tuple.push(SpanTiming.new(span.name, span.type, span.subtype, start, start + Util.ms(span.duration), span.duration, span.id, span.transaction_id))
217
208
  end
218
209
  end
219
210
  end
@@ -222,6 +213,37 @@ module Atatus
222
213
  ruby_time = Util.ms(txn.duration)
223
214
  else
224
215
  spans_tuple.sort! {| a, b | a[:start] <=> b[:start] }
216
+ j = 0
217
+ while j < spans_tuple.length
218
+ if spans_tuple[j].subtype == 'controller' || spans_tuple[j].subtype == 'view' || spans_tuple[j].subtype == 'tilt'
219
+ k = j+1
220
+ while k < spans_tuple.length
221
+ if spans_tuple[k].start >= spans_tuple[j].end
222
+ break
223
+ else
224
+ if spans_tuple[k].end <= spans_tuple[j].end
225
+ spans_tuple[j].duration -= Util.us(spans_tuple[k].end - spans_tuple[k].start)
226
+ else
227
+ spans_tuple[j].duration -= Util.us(spans_tuple[j].end - spans_tuple[k].start)
228
+ end
229
+ end
230
+ k += 1
231
+ end
232
+ end
233
+
234
+ if !@txns_agg[txn.name].spans.key?(spans_tuple[j].name)
235
+ kind = Layer.span_kind(spans_tuple[j].type)
236
+ type = Layer.span_type(spans_tuple[j].subtype)
237
+ @txns_agg[txn.name].spans[spans_tuple[j].name] = Layer.new(type, kind, spans_tuple[j].duration)
238
+ @txns_agg[txn.name].spans[spans_tuple[j].name].id = spans_tuple[j].id
239
+ @txns_agg[txn.name].spans[spans_tuple[j].name].pid = spans_tuple[j].transaction_id
240
+ else
241
+ @txns_agg[txn.name].spans[spans_tuple[j].name].aggregate! spans_tuple[j].duration
242
+ end
243
+
244
+ j += 1
245
+ end
246
+
225
247
  ruby_time = spans_tuple[0].start
226
248
  span_end = spans_tuple[0].end
227
249
  j = 0
@@ -283,11 +305,13 @@ module Atatus
283
305
  end
284
306
  end
285
307
 
308
+ trace_id = ""
309
+ trace_id = txn.trace_id if !txn.trace_id.nil?
286
310
  if @error_requests_agg.length < 20
287
- @error_requests_agg.push({'name' => txn.name, 'context' => txn.context})
311
+ @error_requests_agg.push({'name' => txn.name, 'txn_id' => txn.id, 'trace_id' => trace_id, 'context' => txn.context})
288
312
  else
289
313
  i = rand(20)
290
- @error_requests_agg[i] = {'name' => txn.name, 'context' => txn.context}
314
+ @error_requests_agg[i] = {'name' => txn.name, 'txn_id' => txn.id, 'trace_id' => trace_id, 'context' => txn.context}
291
315
  end
292
316
  end
293
317
  end
@@ -237,11 +237,17 @@ module Atatus
237
237
  then
238
238
  next
239
239
  end
240
+ txn_id = ""
241
+ txn_id = txn.id if !txn.id.nil?
242
+ trace_id = ""
243
+ trace_id = txn.trace_id if !txn.trace_id.nil?
240
244
 
241
245
  trace = {}
242
246
  trace[:name] = txn.name
243
247
  trace[:type] = @config.framework_name || AGENT_NAME
244
248
  trace[:kind] = AGENT_NAME
249
+ trace[:txnId] = txn_id
250
+ trace[:traceId] = trace_id
245
251
  trace[:start] = txn.timestamp
246
252
  trace[:duration] = Util.ms(txn.duration)
247
253
  if !txn.context.nil?
@@ -249,6 +255,28 @@ module Atatus
249
255
  end
250
256
  trace[:entries] = []
251
257
  trace[:funcs] = []
258
+
259
+ if
260
+ !txn.context.nil? &&
261
+ defined?(txn.context.custom) &&
262
+ !txn.context.custom.nil? &&
263
+ !txn.context.custom.empty?
264
+ then
265
+ trace[:customData] = txn.context.custom
266
+ end
267
+
268
+ if
269
+ !txn.context.nil? &&
270
+ defined?(txn.context.user) &&
271
+ !txn.context.user.nil? &&
272
+ !txn.context.user.empty?
273
+ then
274
+ trace[:user] = {}
275
+ trace[:user][:id] = txn.context.user.id
276
+ trace[:user][:email] = txn.context.user.email
277
+ trace[:user][:username] = txn.context.user.username
278
+ end
279
+
252
280
  i = 0
253
281
 
254
282
  if
@@ -347,11 +375,39 @@ module Atatus
347
375
  then
348
376
  next
349
377
  end
378
+ txn_id = ""
379
+ txn_id = v['txn_id'] if v.key?('txn_id')
380
+ trace_id = ""
381
+ trace_id = v['trace_id'] if v.key?('trace_id')
350
382
  error_request = {}
351
383
  error_request[:name] = v['name']
352
384
  error_request[:type] = @config.framework_name || AGENT_NAME
353
385
  error_request[:kind] = AGENT_NAME
386
+ error_request[:txnId] = txn_id
387
+ error_request[:traceId] = trace_id
354
388
  error_request[:request] = build_request(v['context'])
389
+
390
+ if
391
+ !v['context'].nil? &&
392
+ defined?(v['context'].custom) &&
393
+ !v['context'].custom.nil? &&
394
+ !v['context'].custom.empty?
395
+ then
396
+ error_request[:customData] = v['context'].custom
397
+ end
398
+
399
+ if
400
+ !v['context'].nil? &&
401
+ defined?(v['context'].user) &&
402
+ !v['context'].user.nil? &&
403
+ !v['context'].user.empty?
404
+ then
405
+ error_request[:user] = {}
406
+ error_request[:user][:id] = v['context'].user.id
407
+ error_request[:user][:email] = v['context'].user.email
408
+ error_request[:user][:username] = v['context'].user.username
409
+ end
410
+
355
411
  error_requests << error_request
356
412
  end
357
413
  error_requests
@@ -384,9 +440,39 @@ module Atatus
384
440
  error[:transaction] = v.transaction[:name]
385
441
  end
386
442
 
443
+ txn_id = ""
444
+ txn_id = v.transaction_id if !v.transaction_id.nil?
445
+ trace_id = ""
446
+ trace_id = v.trace_id if !v.trace_id.nil?
447
+
448
+ error[:txnId] = txn_id
449
+ error[:traceId] = trace_id
450
+
387
451
  if !v.context.nil?
388
452
  error[:request] = build_request(v.context)
389
453
  end
454
+
455
+ if
456
+ !v.context.nil? &&
457
+ defined?(v.context.custom) &&
458
+ !v.context.custom.nil? &&
459
+ !v.context.custom.empty?
460
+ then
461
+ error[:customData] = v.context.custom
462
+ end
463
+
464
+ if
465
+ !v.context.nil? &&
466
+ defined?(v.context.user) &&
467
+ !v.context.user.nil? &&
468
+ !v.context.user.empty?
469
+ then
470
+ error[:user] = {}
471
+ error[:user][:id] = v.context.user.id
472
+ error[:user][:email] = v.context.user.email
473
+ error[:user][:username] = v.context.user.username
474
+ end
475
+
390
476
  error[:exceptions] = []
391
477
  exception = {}
392
478
  exception[:class] = v.exception.type
@@ -51,6 +51,7 @@ module Atatus
51
51
  'sqlite'=> 'SQLite',
52
52
  'controller' => 'Controller',
53
53
  'view' => 'View',
54
+ 'tilt' => 'Tilt',
54
55
  'http' => 'External Requests',
55
56
  'http2' => 'External Requests',
56
57
  'http_rb' => 'External Requests',
@@ -86,6 +86,10 @@ module Atatus
86
86
 
87
87
  Util.reverse_merge!(error.context.labels, transaction.context.labels)
88
88
  Util.reverse_merge!(error.context.custom, transaction.context.custom)
89
+
90
+ return unless transaction.context.user
91
+
92
+ error.context.user = transaction.context.user
89
93
  end
90
94
  end
91
95
  end
@@ -19,5 +19,5 @@
19
19
 
20
20
  module Atatus
21
21
  AGENT_NAME = 'Ruby'
22
- VERSION = '1.5.0'
22
+ VERSION = '1.6.0'
23
23
  end
data/lib/atatus.rb CHANGED
@@ -352,6 +352,14 @@ module Atatus
352
352
  end
353
353
  end
354
354
 
355
+ # Provide further context for the current transaction
356
+ #
357
+ # @param custom [Hash] A hash with custom information. Can be nested.
358
+ # @return [Hash] The current custom context
359
+ def set_custom_data(custom)
360
+ agent&.set_custom_context(custom)
361
+ end
362
+
355
363
  # Provide further context for the current transaction
356
364
  #
357
365
  # @param custom [Hash] A hash with custom information. Can be nested.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atatus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atatus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-27 00:00:00.000000000 Z
11
+ date: 2021-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby