MCPcopy Index your code
hub / github.com/coder/coder / EndHTTPSpan

Function EndHTTPSpan

coderd/tracing/httpmw.go:79–96  ·  view source on GitHub ↗

EndHTTPSpan captures request and response data after the handler is done.

(r *http.Request, status int, span trace.Span)

Source from the content-addressed store, hash-verified

77
78// EndHTTPSpan captures request and response data after the handler is done.
79func EndHTTPSpan(r *http.Request, status int, span trace.Span) {
80 // set the resource name as we get it only once the handler is executed
81 route := chi.RouteContext(r.Context()).RoutePattern()
82 span.SetName(fmt.Sprintf("%s %s", r.Method, route))
83 span.SetAttributes(netconv.Transport("tcp"))
84 span.SetAttributes(httpconv.ServerRequest("coderd", r)...)
85 span.SetAttributes(semconv.HTTPRouteKey.String(route))
86
87 // 0 status means one has not yet been sent in which case net/http library will write StatusOK
88 if status == 0 {
89 status = http.StatusOK
90 }
91 span.SetAttributes(semconv.HTTPStatusCodeKey.Int(status))
92 span.SetStatus(httpconv.ServerStatus(status))
93
94 // finally end span
95 span.End()
96}
97
98type tracerNameKey struct{}
99

Callers 2

proxyWorkspaceAppMethod · 0.92
MiddlewareFunction · 0.85

Calls 4

TransportMethod · 0.80
IntMethod · 0.80
ContextMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected