Skip to content

Commit

Permalink
add tracingTagOnResponse to Filters(); use pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-c-wilhelm committed Sep 21, 2023
1 parent 40a2214 commit 02c8a60
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions filters/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func Filters() []filters.Spec {
tracing.NewBaggageToTagFilter(),
tracing.NewTag(),
tracing.NewStateBagToTag(),
tracing.NewTagOnResponse(),
//lint:ignore SA1019 due to backward compatibility
accesslog.NewAccessLogDisabled(),
accesslog.NewDisableAccessLog(),
Expand Down
12 changes: 6 additions & 6 deletions filters/tracing/tagonresponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ type tagOnResponseFilter struct {

// NewTagOnResponse creates a filter specification for the tracingTagOnResponse filter.
func NewTagOnResponse() filters.Spec {
return tagOnResponseSpec{}
return &tagOnResponseSpec{}
}

func (s tagOnResponseSpec) Name() string {
func (s *tagOnResponseSpec) Name() string {
return filters.TracingTagOnResponseName
}

func (s tagOnResponseSpec) CreateFilter(args []interface{}) (filters.Filter, error) {
func (s *tagOnResponseSpec) CreateFilter(args []interface{}) (filters.Filter, error) {
if len(args) != 2 {
return nil, filters.ErrInvalidFilterParameters
}
Expand All @@ -38,15 +38,15 @@ func (s tagOnResponseSpec) CreateFilter(args []interface{}) (filters.Filter, err
return nil, filters.ErrInvalidFilterParameters
}

return tagOnResponseFilter{
return &tagOnResponseFilter{
tagName: tagName,
tagValue: eskip.NewTemplate(tagValue),
}, nil
}

func (f tagOnResponseFilter) Request(filters.FilterContext) {}
func (f *tagOnResponseFilter) Request(filters.FilterContext) {}

func (f tagOnResponseFilter) Response(ctx filters.FilterContext) {
func (f *tagOnResponseFilter) Response(ctx filters.FilterContext) {
req := ctx.Request()
span := opentracing.SpanFromContext(req.Context())
if span == nil {
Expand Down
2 changes: 1 addition & 1 deletion filters/tracing/tagonresponse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestTracingTagOnResponseNil(t *testing.T) {
}

func TestTracingTagOnResponseTagName(t *testing.T) {
if (tagOnResponseSpec{}).Name() != filters.TracingTagOnResponseName {
if (&tagOnResponseSpec{}).Name() != filters.TracingTagOnResponseName {
t.Error("Wrong tag spec name")
}
}
Expand Down

0 comments on commit 02c8a60

Please sign in to comment.