Skip to content

Commit

Permalink
Fix alloc test
Browse files Browse the repository at this point in the history
  • Loading branch information
lucastt committed Mar 19, 2024
1 parent 6f6ab9c commit 5f873fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 6 additions & 2 deletions filters/tracing/statebagtotag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/trace/noop"

"github.com/zalando/skipper/filters"
"github.com/zalando/skipper/filters/filtertest"
Expand Down Expand Up @@ -66,9 +67,12 @@ func TestStateBagToTag(t *testing.T) {
func TestStateBagToTagAllocs(t *testing.T) {
req := &http.Request{Header: http.Header{}}

span := &tracing.SpanWrapper{Ot: tracingtest.NewOtSpan("start_span")}
tr := noop.NewTracerProvider().Tracer("start_tracer")
sCtx, span := tr.Start(req.Context(), "start_span")
req.WithContext(sCtx)

Check failure on line 72 in filters/tracing/statebagtotag_test.go

View workflow job for this annotation

GitHub Actions / tests

WithContext doesn't have side effects and its return value is ignored (SA4017)

req = req.WithContext(tracing.ContextWithSpan(req.Context(), span))
ctx := &filtertest.Context{FRequest: req, FStateBag: map[string]interface{}{"item": "val"}}
ctx := &filtertest.Context{FRequest: req, FStateBag: map[string]interface{}{"item": "val"}, FTracer: tr}

f, err := NewStateBagToTag().CreateFilter([]interface{}{"item", "tag"})
require.NoError(t, err)
Expand Down
2 changes: 0 additions & 2 deletions tracing/tracingtest/testtracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Package tracingtest provides an OpenTracing implementation for testing purposes.
package tracingtest

import (
"fmt"
"net/http"
"time"

Expand Down Expand Up @@ -165,7 +164,6 @@ func (s *OtSpan) SetOperationName(operationName string) tracing.Span {

// Adds a tag to the span.
func (s *OtSpan) SetTag(key string, value interface{}) tracing.Span {
fmt.Println("key: ", key, "; value: ", value)
s.Tags[key] = value
return s
}
Expand Down

0 comments on commit 5f873fa

Please sign in to comment.