opentrace 0.15.0 → 0.15.1

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: ad0233533a9c236a70cf379346c1f64f7ffecc58cf91ce413e55665e8b4f5675
4
- data.tar.gz: 92d7052f7901fad33897b767441ea01f8ed299bc47d90d43153110a2fdd22c1e
3
+ metadata.gz: e5c67d0aecd2be7ec0624bd339bda99a46d8c2de8d0a04009d6778f94cefee3d
4
+ data.tar.gz: 0b54c97978becc24a2339e1f615de4f715388fc9247dc88099880dc7e1532a43
5
5
  SHA512:
6
- metadata.gz: 6f9b631bf0faab3e6671a41eccc04039339f2f95cfa90a6c380517572256c08c3115bb4c30ddae230933bac18f8c9858195a55beacda27ff2e44c5efb02ef4f7
7
- data.tar.gz: 3671e28a4393225a5e891c09a38a734b974c05b70fd393ff892b06bb816fd5954880f7eab5da257248fe025df948f96b0fb94b2f526338d060a928514d5a4917
6
+ metadata.gz: 60bc99ef6e4e950851358a9dbf3b2b8342209f81ff24d58eb248c07362657d4c040c1f60e6e8fdb3cb56d625cac4f8b9a4641e953241a1af52195f27232790f6
7
+ data.tar.gz: d655b2237f513c8b3fe8a12e936086937fc80b1f50d5bb3766b6e5ef3ed1a137d90bf9798546aa99413633dba9e9588c87f2b99d4e54e226c0842fea720f309e
@@ -28,12 +28,18 @@ module OpenTrace
28
28
 
29
29
  static_ctx = OpenTrace.send(:static_context)
30
30
  static_ctx.each { |k, v| meta[k] ||= v }
31
- meta[:request_id] ||= request_id if request_id
32
31
 
33
32
  # Extract trace_id from metadata if user provided it there
34
33
  meta_trace_id = meta.delete(:trace_id)
35
34
  effective_trace_id = meta_trace_id || trace_id
36
35
 
36
+ # Promote indexed fields to top-level (remove from metadata to avoid duplication)
37
+ commit_hash = meta.delete(:git_sha)
38
+ effective_request_id = meta.delete(:request_id) || request_id
39
+ exception_class = meta.delete(:exception_class)
40
+ error_fingerprint = meta.delete(:error_fingerprint)
41
+ source_file, source_line = extract_source_location(meta[:backtrace])
42
+
37
43
  payload = {
38
44
  timestamp: format_timestamp(ts),
39
45
  level: level.to_s.upcase,
@@ -43,6 +49,12 @@ module OpenTrace
43
49
  metadata: meta.compact
44
50
  }
45
51
 
52
+ payload[:commit_hash] = commit_hash if commit_hash
53
+ payload[:request_id] = effective_request_id.to_s if effective_request_id
54
+ payload[:exception_class] = exception_class if exception_class
55
+ payload[:error_fingerprint] = error_fingerprint if error_fingerprint
56
+ payload[:source_file] = source_file if source_file
57
+ payload[:source_line] = source_line if source_line && source_line > 0
46
58
  payload[:event_type] = event_type.to_s if event_type
47
59
  payload[:trace_id] = effective_trace_id.to_s if effective_trace_id
48
60
  payload[:span_id] = span_id if span_id
@@ -69,13 +81,19 @@ module OpenTrace
69
81
  meta[:user_id] = cached_ctx[:user_id]
70
82
  end
71
83
 
84
+ exception_class = nil
85
+ error_fingerprint = nil
86
+ source_file = nil
87
+ source_line = nil
88
+
72
89
  if exc_class
73
- meta[:exception_class] = exc_class
90
+ exception_class = exc_class
74
91
  meta[:exception_message] = exc_message&.slice(0, 500)
75
92
  if exc_backtrace
76
93
  cleaned = clean_backtrace(exc_backtrace)
77
94
  meta[:backtrace] = cleaned.first(15)
78
- meta[:error_fingerprint] = OpenTrace.send(:compute_error_fingerprint, exc_class, cleaned)
95
+ error_fingerprint = OpenTrace.send(:compute_error_fingerprint, exc_class, cleaned)
96
+ source_file, source_line = extract_source_location(cleaned)
79
97
  end
80
98
  end
81
99
 
@@ -119,6 +137,10 @@ module OpenTrace
119
137
  end
120
138
  meta[:transaction_name] = transaction_name if transaction_name
121
139
 
140
+ # Promote indexed fields to top-level (remove from metadata to avoid duplication)
141
+ commit_hash = meta.delete(:git_sha)
142
+ effective_request_id = meta.delete(:request_id) || request_id
143
+
122
144
  payload = {
123
145
  timestamp: format_timestamp(started),
124
146
  level: level,
@@ -127,6 +149,12 @@ module OpenTrace
127
149
  message: message,
128
150
  metadata: meta.compact
129
151
  }
152
+ payload[:commit_hash] = commit_hash if commit_hash
153
+ payload[:request_id] = effective_request_id.to_s if effective_request_id
154
+ payload[:exception_class] = exception_class if exception_class
155
+ payload[:error_fingerprint] = error_fingerprint if error_fingerprint
156
+ payload[:source_file] = source_file if source_file
157
+ payload[:source_line] = source_line if source_line && source_line > 0
130
158
  payload[:trace_id] = trace_id.to_s if trace_id
131
159
  payload[:span_id] = span_id if span_id
132
160
  payload[:parent_span_id] = parent_span_id if parent_span_id
@@ -145,6 +173,22 @@ module OpenTrace
145
173
  end
146
174
  end
147
175
 
176
+ # Extract source file and line number from the first app-relevant backtrace line.
177
+ # Format: "app/controllers/users_controller.rb:42:in `show'"
178
+ def extract_source_location(backtrace)
179
+ return [nil, nil] unless backtrace.is_a?(Array) && !backtrace.empty?
180
+
181
+ line = backtrace.first.to_s
182
+ parts = line.split(":", 3)
183
+ return [nil, nil] if parts.length < 2
184
+
185
+ file = parts[0]
186
+ line_num = parts[1].to_i
187
+ [file, line_num]
188
+ rescue StandardError
189
+ [nil, nil]
190
+ end
191
+
148
192
  def clean_backtrace(backtrace)
149
193
  if defined?(::Rails) && ::Rails.respond_to?(:backtrace_cleaner)
150
194
  ::Rails.backtrace_cleaner.clean(backtrace)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenTrace
4
- VERSION = "0.15.0"
4
+ VERSION = "0.15.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTrace