log_bench 0.5.1 → 0.5.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c2d50ada733ae04ce5cfdfdf02b676efb555456f9578b24cf82a5e3985e339f
4
- data.tar.gz: de27a1741e63115c4aa4c35bb7ed35823a8fe722ff0067fe6901ce2c42599295
3
+ metadata.gz: c3cadcab03882aae96975ccfc7af0ce41c0e45cb8fed84182e012b1401c6b701
4
+ data.tar.gz: 0c9137a70a659e69c3abbedbea4e530bc255f866c77dbdb1495f47dd0a1ffe98
5
5
  SHA512:
6
- metadata.gz: 7b03dc3daa739c3b0f2b6fedb33013515f8da626f80c2c4f68c47ac86fa39351510ec6735812890ad72df7b58d1cdcbc762798f236939579c130542065c08118
7
- data.tar.gz: f5cff1495402c5dd22bd16ce288a7d11bbf80fc41d0bff0abd2dc95b56b0db290168531a087dcadd827f89ed548ebc3933353013fe2af65c64fb535fc1d5ff64
6
+ metadata.gz: cbedbfc86537d8343f4e44d531a7183112dd010432994c30321285948cf2cbf79fd76ecceba8bc73ab2a0f007ad8690bea584f3d2a7681b905ec8f4fd4696051
7
+ data.tar.gz: a1d6c1f51b317c5e04ced37994de4024c35548e36b8a0c57a179c5984c2a0dafeb7f49d524d4abdfb0ebb644a84f5e2d5bc680bfc2d93e46e4ce2d69f33f3e63
@@ -23,7 +23,7 @@ module LogBench
23
23
 
24
24
  def extract_from_json(data)
25
25
  super
26
- message = data["message"] || ""
26
+ message = Parser.normalize_message(data["message"])
27
27
  return unless call_line_message?(data)
28
28
 
29
29
  self.content = message.strip
@@ -40,7 +40,7 @@ module LogBench
40
40
  end
41
41
 
42
42
  def call_line_message?(data)
43
- message = data["message"] || ""
43
+ message = Parser.normalize_message(data["message"])
44
44
  message.include?("↳")
45
45
  end
46
46
  end
@@ -9,7 +9,7 @@ module LogBench
9
9
  self.json_data = json_data
10
10
  self.timestamp = parse_timestamp(json_data["timestamp"])
11
11
  self.request_id = json_data["request_id"]
12
- self.content = json_data["message"] || ""
12
+ self.content = Parser.normalize_message(json_data["message"])
13
13
  self.type = :other
14
14
  end
15
15
 
@@ -83,28 +83,42 @@ module LogBench
83
83
  data["method"] && data["path"] && data["status"]
84
84
  end
85
85
 
86
+ def self.normalize_message(message)
87
+ case message
88
+ when String
89
+ message
90
+ when Array
91
+ message.join(" ")
92
+ when NilClass
93
+ ""
94
+ else
95
+ message.to_s
96
+ end
97
+ end
98
+
86
99
  def self.sql_message?(data)
87
- message = data["message"] || ""
100
+ message = normalize_message(data["message"])
88
101
  %w[SELECT INSERT UPDATE DELETE TRANSACTION BEGIN COMMIT ROLLBACK SAVEPOINT].any? { |op| message.include?(op) }
89
102
  end
90
103
 
91
104
  def self.cache_message?(data)
92
- message = data["message"] || ""
105
+ message = normalize_message(data["message"])
93
106
  message.include?("CACHE")
94
107
  end
95
108
 
96
109
  def self.call_stack_message?(data)
97
- message = data["message"] || ""
110
+ message = normalize_message(data["message"])
98
111
  message.include?("↳")
99
112
  end
100
113
 
101
114
  def self.job_enqueue_message?(data)
102
- message = data["message"] || ""
115
+ message = normalize_message(data["message"])
103
116
  message.match?(/Enqueued .+ \(Job ID: .+\)/)
104
117
  end
105
118
 
106
119
  def self.extract_job_id_from_enqueue(message)
107
- match = message.match(/Job ID: ([^\)]+)/)
120
+ normalized_message = normalize_message(message)
121
+ match = normalized_message.match(/Job ID: ([^\)]+)/)
108
122
  match[1] if match
109
123
  end
110
124
 
@@ -113,7 +127,18 @@ module LogBench
113
127
  return unless entry.is_a?(JobEnqueueEntry)
114
128
  return unless defined?(App::State)
115
129
 
116
- App::State.instance.register_job_enqueue(entry.job_id, entry.request_id)
130
+ # If entry has a request_id, use it directly
131
+ request_id = entry.request_id
132
+
133
+ # If no request_id, check if this enqueue happened inside another job
134
+ # by looking at the tags to find the parent job's request_id
135
+ if !request_id && entry.respond_to?(:json_data)
136
+ tags = entry.json_data["tags"]
137
+ parent_job_id, _parent_job_class = extract_job_info_from_tags(tags)
138
+ request_id = App::State.instance.request_id_for_job(parent_job_id) if parent_job_id
139
+ end
140
+
141
+ App::State.instance.register_job_enqueue(entry.job_id, request_id)
117
142
  end
118
143
 
119
144
  # Enrich job execution logs with request_id and colored prefix
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LogBench
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.3"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_bench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamín Silva
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-11-06 00:00:00.000000000 Z
10
+ date: 2025-11-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: zeitwerk