dvFinishServerSpan function
Records response on a server span and sends its trace context back.
Implementation
void dvFinishServerSpan(DVSpan span, Response response) {
span.setAttribute('http.response.status_code', response.status);
// 5xx only. A 404 is the client asking for something that is not there,
// and counting it as a server error makes an error rate that alerts on
// ordinary traffic.
if (response.status >= 500) {
span.status = DVSpanStatus.error;
span.setAttribute('error.type', '${response.status}');
}
// Sent back so a support ticket can quote a trace id. Without it the id
// exists only in the backend and nobody outside can name one.
if (response.headers.get('traceparent') == null) {
response.headers.set('traceparent', span.context.toHeader());
}
}