diff --git a/connector/muffler.go b/connector/muffler.go index 94869917..d1bd63e4 100644 --- a/connector/muffler.go +++ b/connector/muffler.go @@ -36,9 +36,7 @@ func (smp *muffler) ShouldSample(p sdktrace.SamplingParameters) sdktrace.Samplin } else { // Do not sample Prometheus requests to the metrics core microservice // :8080/metrics.sys/collect or :8080/metrics.sys:443/collect - slash := strings.Index(p.Name, "/") - if slash >= 0 { - path := p.Name[slash+1:] + if _, path, ok := strings.Cut(p.Name, "/"); ok { if path == "metrics.sys/collect" || path == "metrics.sys:443/collect" { sample = false } diff --git a/coreservices/httpingress/service.go b/coreservices/httpingress/service.go index efff1b39..a47c38c9 100644 --- a/coreservices/httpingress/service.go +++ b/coreservices/httpingress/service.go @@ -310,11 +310,13 @@ func (svc *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) { } else { ww.Write([]byte(http.StatusText(statusCode) + " {" + span.TraceID() + "}")) } - if statusCode < 500 { - svc.LogWarn(ctx, "Serving", log.Error(err), log.String("url", urlStr), log.Int("status", statusCode)) - } else { - svc.LogError(ctx, "Serving", log.Error(err), log.String("url", urlStr), log.Int("status", statusCode)) + logFunc := svc.LogError + if statusCode == http.StatusNotFound { + logFunc = svc.LogInfo + } else if statusCode < 500 { + logFunc = svc.LogWarn } + logFunc(ctx, "Serving", log.Error(err), log.String("url", urlStr), log.Int("status", statusCode)) // OpenTelemetry: record the error, adding the request attributes span.SetRequest(r) diff --git a/coreservices/httpingress/version-gen.go b/coreservices/httpingress/version-gen.go index 77a33367..936a20e2 100644 --- a/coreservices/httpingress/version-gen.go +++ b/coreservices/httpingress/version-gen.go @@ -9,12 +9,12 @@ Neither may be used, copied or distributed without the express written consent o package httpingress -const Version = 220 -const SourceCodeSHA256 = "66cd6c86d9932dcf7ec3637fb2917dc5e6222ca476bad4aa243bc6d235430f3c" -const Timestamp = "2024-06-01T13:28:32.885983Z" +const Version = 221 +const SourceCodeSHA256 = "81f9ab4226eb0472c30a29a90e558725d70f60abfafca8a6b97d5f435738b6e7" +const Timestamp = "2024-06-01T15:27:38.223416Z" /* { - "ver": 220, - "sha256": "66cd6c86d9932dcf7ec3637fb2917dc5e6222ca476bad4aa243bc6d235430f3c", - "ts": "2024-06-01T13:28:32.885983Z" + "ver": 221, + "sha256": "81f9ab4226eb0472c30a29a90e558725d70f60abfafca8a6b97d5f435738b6e7", + "ts": "2024-06-01T15:27:38.223416Z" } */ diff --git a/trc/span.go b/trc/span.go index 453206ee..15038f83 100644 --- a/trc/span.go +++ b/trc/span.go @@ -27,18 +27,33 @@ var _ = Span(SpanImpl{}) // Ensure interface // Span represents an operation that is being traced. type Span interface { + // End completes the span. + // Updates to the span are not allowed after this method has been called. End() + // SetError sets the status of the span to error. SetError(err error) + // SetOK sets the status of the span to OK, with the indicated response status code. SetOK(statusCode int) + // Log records a log event on the span. Log(severity string, message string, fields ...log.Field) + // SetString tags the span during its creation. SetString(k string, v string) + // SetStrings tags the span during its creation. SetStrings(k string, v []string) + // SetBool tags the span during its creation. SetBool(k string, v bool) + // SetInt tags the span during its creation. SetInt(k string, v int) + // SetFloat tags the span during its creation. SetFloat(k string, v float64) + // SetRequest tags the span with the request data. + // Warning: this has a large memory footprint. SetRequest(r *http.Request) + // SetClientIP tags the span during its creation with the IP address and port number of the client. SetClientIP(ip string) + // IsEmpty indicates if the span is not initialized. IsEmpty() bool + // TraceID is an identifier that groups related spans together. TraceID() string } @@ -52,10 +67,8 @@ func NewSpan(ts trace.Span) Span { return SpanImpl{Span: ts} } -// End completes the Span. The Span is considered complete and ready to be -// delivered through the rest of the telemetry pipeline after this method -// is called. Therefore, updates to the Span are not allowed after this -// method has been called. +// End completes the span. +// Updates to the span are not allowed after this method has been called. func (s SpanImpl) End() { if s.Span == nil { return @@ -184,7 +197,8 @@ func (s SpanImpl) SetFloat(k string, v float64) { s.Span.SetAttributes(attribute.Float64(k, v)) } -// SetRequest tags the span during its creation with the request data. +// SetRequest tags the span with the request data. +// Warning: this has a large memory footprint. func (s SpanImpl) SetRequest(r *http.Request) { if s.Span == nil { return