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 +4 -4
- data/lib/opentrace/payload_builder.rb +47 -3
- data/lib/opentrace/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e5c67d0aecd2be7ec0624bd339bda99a46d8c2de8d0a04009d6778f94cefee3d
|
|
4
|
+
data.tar.gz: 0b54c97978becc24a2339e1f615de4f715388fc9247dc88099880dc7e1532a43
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
data/lib/opentrace/version.rb
CHANGED