@@ -1109,6 +1109,9 @@ def test_with_errors(self):
1109
1109
"project_slug" : self .gen1_project .slug ,
1110
1110
"level" : "fatal" ,
1111
1111
"title" : error .title ,
1112
+ "timestamp" : error .timestamp ,
1113
+ "generation" : 0 ,
1114
+ "event_type" : "error" ,
1112
1115
} in gen1_event ["errors" ]
1113
1116
assert {
1114
1117
"event_id" : error1 .event_id ,
@@ -1118,8 +1121,182 @@ def test_with_errors(self):
1118
1121
"project_slug" : self .gen1_project .slug ,
1119
1122
"level" : "warning" ,
1120
1123
"title" : error1 .title ,
1124
+ "timestamp" : error1 .timestamp ,
1125
+ "generation" : 0 ,
1126
+ "event_type" : "error" ,
1121
1127
} in gen1_event ["errors" ]
1122
1128
1129
+ def test_with_only_orphan_errors_with_same_span_ids (self ):
1130
+ span_id = uuid4 ().hex [:16 ]
1131
+ start , end = self .get_start_end (10000 )
1132
+
1133
+ # Error 1
1134
+ error_data = load_data (
1135
+ "javascript" ,
1136
+ timestamp = end ,
1137
+ )
1138
+ error_data ["contexts" ]["trace" ] = {
1139
+ "type" : "trace" ,
1140
+ "trace_id" : self .trace_id ,
1141
+ "span_id" : span_id ,
1142
+ }
1143
+ error_data ["level" ] = "fatal"
1144
+ error = self .store_event (error_data , project_id = self .project .id )
1145
+
1146
+ # Error 2 before after Error 1
1147
+ error_data1 = load_data (
1148
+ "javascript" ,
1149
+ timestamp = start ,
1150
+ )
1151
+ error_data1 ["level" ] = "warning"
1152
+ error_data1 ["contexts" ]["trace" ] = {
1153
+ "type" : "trace" ,
1154
+ "trace_id" : self .trace_id ,
1155
+ "span_id" : span_id ,
1156
+ }
1157
+ error1 = self .store_event (error_data1 , project_id = self .project .id )
1158
+
1159
+ with self .feature (
1160
+ [* self .FEATURES , "organizations:performance-tracing-without-performance" ]
1161
+ ):
1162
+ response = self .client .get (
1163
+ self .url ,
1164
+ data = {"project" : - 1 },
1165
+ format = "json" ,
1166
+ )
1167
+ assert response .status_code == 200 , response .content
1168
+ assert len (response .data ) == 2
1169
+ # Sorting by timestamp puts Error1 after Error2 in the response
1170
+ assert {
1171
+ "event_id" : error .event_id ,
1172
+ "issue_id" : error .group_id ,
1173
+ "span" : span_id ,
1174
+ "project_id" : self .project .id ,
1175
+ "project_slug" : self .project .slug ,
1176
+ "level" : "fatal" ,
1177
+ "title" : error .title ,
1178
+ "timestamp" : error .timestamp ,
1179
+ "generation" : 0 ,
1180
+ "event_type" : "error" ,
1181
+ } == response .data [1 ]
1182
+ assert {
1183
+ "event_id" : error1 .event_id ,
1184
+ "issue_id" : error1 .group_id ,
1185
+ "span" : span_id ,
1186
+ "project_id" : self .project .id ,
1187
+ "project_slug" : self .project .slug ,
1188
+ "level" : "warning" ,
1189
+ "title" : error1 .title ,
1190
+ "timestamp" : error1 .timestamp ,
1191
+ "generation" : 0 ,
1192
+ "event_type" : "error" ,
1193
+ } == response .data [0 ]
1194
+
1195
+ def test_with_only_orphan_errors_with_different_span_ids (self ):
1196
+ start , _ = self .get_start_end (1000 )
1197
+ span_id = uuid4 ().hex [:16 ]
1198
+ error_data = load_data (
1199
+ "javascript" ,
1200
+ timestamp = start ,
1201
+ )
1202
+ error_data ["contexts" ]["trace" ] = {
1203
+ "type" : "trace" ,
1204
+ "trace_id" : self .trace_id ,
1205
+ "span_id" : span_id ,
1206
+ }
1207
+ error_data ["level" ] = "fatal"
1208
+ error = self .store_event (error_data , project_id = self .project .id )
1209
+ error_data ["level" ] = "warning"
1210
+ span_id1 = uuid4 ().hex [:16 ]
1211
+ error_data ["contexts" ]["trace" ] = {
1212
+ "type" : "trace" ,
1213
+ "trace_id" : self .trace_id ,
1214
+ "span_id" : span_id1 ,
1215
+ }
1216
+ error1 = self .store_event (error_data , project_id = self .project .id )
1217
+
1218
+ with self .feature (
1219
+ [* self .FEATURES , "organizations:performance-tracing-without-performance" ]
1220
+ ):
1221
+ response = self .client .get (
1222
+ self .url ,
1223
+ data = {"project" : - 1 },
1224
+ format = "json" ,
1225
+ )
1226
+ assert response .status_code == 200 , response .content
1227
+ assert len (response .data ) == 2
1228
+ assert {
1229
+ "event_id" : error .event_id ,
1230
+ "issue_id" : error .group_id ,
1231
+ "span" : span_id ,
1232
+ "project_id" : self .project .id ,
1233
+ "project_slug" : self .project .slug ,
1234
+ "level" : "fatal" ,
1235
+ "title" : error .title ,
1236
+ "timestamp" : error .timestamp ,
1237
+ "generation" : 0 ,
1238
+ "event_type" : "error" ,
1239
+ } in response .data
1240
+ assert {
1241
+ "event_id" : error1 .event_id ,
1242
+ "issue_id" : error1 .group_id ,
1243
+ "span" : span_id1 ,
1244
+ "project_id" : self .project .id ,
1245
+ "project_slug" : self .project .slug ,
1246
+ "level" : "warning" ,
1247
+ "title" : error1 .title ,
1248
+ "timestamp" : error1 .timestamp ,
1249
+ "generation" : 0 ,
1250
+ "event_type" : "error" ,
1251
+ } in response .data
1252
+
1253
+ def test_with_mixup_of_orphan_errors_with_simple_trace_data (self ):
1254
+ self .load_trace ()
1255
+ start , _ = self .get_start_end (1000 )
1256
+ span_id = uuid4 ().hex [:16 ]
1257
+ error_data = load_data (
1258
+ "javascript" ,
1259
+ timestamp = start ,
1260
+ )
1261
+ error_data ["contexts" ]["trace" ] = {
1262
+ "type" : "trace" ,
1263
+ "trace_id" : self .trace_id ,
1264
+ "span_id" : span_id ,
1265
+ }
1266
+ error_data ["level" ] = "fatal"
1267
+ error = self .store_event (error_data , project_id = self .project .id )
1268
+ error_data ["level" ] = "warning"
1269
+ span_id1 = uuid4 ().hex [:16 ]
1270
+ error_data ["contexts" ]["trace" ] = {
1271
+ "type" : "trace" ,
1272
+ "trace_id" : self .trace_id ,
1273
+ "span_id" : span_id1 ,
1274
+ }
1275
+
1276
+ with self .feature (
1277
+ [* self .FEATURES , "organizations:performance-tracing-without-performance" ]
1278
+ ):
1279
+ response = self .client .get (
1280
+ self .url ,
1281
+ data = {"project" : - 1 },
1282
+ format = "json" ,
1283
+ )
1284
+ assert response .status_code == 200 , response .content
1285
+ assert len (response .data ) == 2
1286
+ self .assert_trace_data (response .data [0 ])
1287
+ assert {
1288
+ "event_id" : error .event_id ,
1289
+ "issue_id" : error .group_id ,
1290
+ "span" : span_id ,
1291
+ "project_id" : self .project .id ,
1292
+ "project_slug" : self .project .slug ,
1293
+ "level" : "fatal" ,
1294
+ "title" : error .title ,
1295
+ "timestamp" : error .timestamp ,
1296
+ "generation" : 0 ,
1297
+ "event_type" : "error" ,
1298
+ } in response .data
1299
+
1123
1300
def test_with_default (self ):
1124
1301
self .load_trace ()
1125
1302
start , _ = self .get_start_end (1000 )
@@ -1143,6 +1320,9 @@ def test_with_default(self):
1143
1320
"project_slug" : self .gen1_project .slug ,
1144
1321
"level" : "debug" ,
1145
1322
"title" : "this is a log message" ,
1323
+ "timestamp" : default_event .timestamp ,
1324
+ "generation" : 0 ,
1325
+ "event_type" : "error" ,
1146
1326
} in root_event ["errors" ]
1147
1327
1148
1328
def test_pruning_root (self ):
0 commit comments