fix code style issues

This commit is contained in:
David Hontecillas
2025-06-03 15:47:57 +02:00
parent 762148e3a4
commit 707b65b97b
3 changed files with 4 additions and 5 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ func clientAddr(r *http.Request, trustedProxies map[string]bool) string {
if r.RemoteAddr == "" {
return ""
}
if trustedProxies == nil || len(trustedProxies) == 0 {
if len(trustedProxies) == 0 {
return r.RemoteAddr
}
+2 -2
View File
@@ -80,7 +80,7 @@ func NewTrackingHandlerWithTrustedProxies(next http.Handler, trustedProxies []st
if !gCfg.DisableMetrics {
var metricsAttrs []attribute.KeyValue
for _, kv := range gCfg.MetricsStaticAttributes {
if len(kv.Key) > 0 && len(kv.Value) > 0 {
if kv.Key != "" && kv.Value != "" {
metricsAttrs = append(metricsAttrs, attribute.String(kv.Key, kv.Value))
}
}
@@ -92,7 +92,7 @@ func NewTrackingHandlerWithTrustedProxies(next http.Handler, trustedProxies []st
if !gCfg.DisableTraces {
tracesAttrs := []attribute.KeyValue{attribute.String("krakend.stage", "global")}
for _, kv := range gCfg.TracesStaticAttributes {
if len(kv.Key) > 0 && len(kv.Value) > 0 {
if kv.Key != "" && kv.Value != "" > 0 {
tracesAttrs = append(tracesAttrs, attribute.String(kv.Key, kv.Value))
}
}
+1 -2
View File
@@ -51,8 +51,7 @@ func (t *tracesHTTP) start(r *http.Request, tr *tracking) *http.Request {
trace.WithSpanKind(trace.SpanKindServer))
r = r.WithContext(tr.ctx)
var attrs []attribute.KeyValue
attrs = otelhttp.TraceIncomingRequestAttrs(r, t.trustedProxies)
attrs := otelhttp.TraceIncomingRequestAttrs(r, t.trustedProxies)
tr.span.SetAttributes(attrs...)
if len(t.fixedAttrs) > 0 {