chore: ignore traces from (*API).workspaceAgentCoordinate after accept (#4178)

This commit is contained in:
Colin Adler
2022-09-23 15:21:44 -05:00
committed by GitHub
parent 4c8be34d81
commit 95aea104c7
2 changed files with 14 additions and 1 deletions

View File

@ -1,10 +1,20 @@
package tracing
import (
"context"
"runtime"
"strings"
"go.opentelemetry.io/otel/trace"
)
var NoopSpan trace.Span
func init() {
tracer := trace.NewNoopTracerProvider().Tracer("")
_, NoopSpan = tracer.Start(context.Background(), "")
}
const TracerName = "coderd"
func FuncName() string {

View File

@ -364,8 +364,11 @@ func (api *API) workspaceAgentCoordinate(rw http.ResponseWriter, r *http.Request
return
}
// end span so we don't get long lived trace data
// End span so we don't get long lived trace data.
tracing.EndHTTPSpan(r, http.StatusOK, trace.SpanFromContext(ctx))
// Ignore all trace spans after this.
ctx = trace.ContextWithSpan(ctx, tracing.NoopSpan)
api.Logger.Info(ctx, "accepting agent", slog.F("resource", resource), slog.F("agent", workspaceAgent))
defer conn.Close(websocket.StatusNormalClosure, "")