@@ -42,11 +42,11 @@ export const tracing = fastifyPlugin(
42
42
const span = trace . getSpan ( context . active ( ) )
43
43
44
44
if ( span ) {
45
- // We collect logs only in full and logs mode
45
+ // We collect logs only in full, logs,debug mode
46
46
if (
47
47
tracingEnabled &&
48
48
request . tracingMode &&
49
- ! [ 'full' , 'logs' ] . includes ( request . tracingMode )
49
+ ! [ 'full' , 'logs' , 'debug' ] . includes ( request . tracingMode )
50
50
) {
51
51
traceCollector . clearTrace ( span . spanContext ( ) . traceId )
52
52
}
@@ -68,7 +68,7 @@ export const traceServerTime = fastifyPlugin(
68
68
const spans = traceCollector . getSpansForTrace ( traceId )
69
69
if ( spans ) {
70
70
try {
71
- const serverTimingHeaders = spansToServerTimings ( spans )
71
+ const serverTimingHeaders = spansToServerTimings ( spans , reply . statusCode >= 500 )
72
72
73
73
request . serverTimings = serverTimingHeaders
74
74
@@ -94,12 +94,15 @@ export const traceServerTime = fastifyPlugin(
94
94
} )
95
95
96
96
fastify . addHook ( 'onRequestAbort' , async ( req ) => {
97
- const traceId = trace . getSpan ( context . active ( ) ) ?. spanContext ( ) . traceId
97
+ const span = trace . getSpan ( context . active ( ) )
98
+ const traceId = span ?. spanContext ( ) . traceId
99
+
100
+ span ?. setAttribute ( 'req_aborted' , true )
98
101
99
102
if ( traceId ) {
100
103
const spans = traceCollector . getSpansForTrace ( traceId )
101
104
if ( spans ) {
102
- req . serverTimings = spansToServerTimings ( spans )
105
+ req . serverTimings = spansToServerTimings ( spans , true )
103
106
}
104
107
traceCollector . clearTrace ( traceId )
105
108
}
@@ -155,6 +158,8 @@ function spansToServerTimings(
155
158
spanName,
156
159
duration,
157
160
action : span . item . attributes [ 'db.statement' ] ,
161
+ error : span . item . attributes . error ,
162
+ status : span . item . status ,
158
163
host : hostName
159
164
? isIP ( hostName )
160
165
? hostName
0 commit comments