@@ -4,31 +4,31 @@ import (
4
4
"context"
5
5
"net/http"
6
6
7
- "github.com/chenquan/zero-flow/tag"
7
+ "github.com/chenquan/zero-flow/internal/ tag"
8
8
"github.com/zeromicro/go-zero/core/logx"
9
9
"go.opentelemetry.io/otel/attribute"
10
10
"go.opentelemetry.io/otel/trace"
11
11
)
12
12
13
13
var httpColorAttributeKey = attribute .Key ("http.header.color" )
14
14
15
- func TagHandler (headerTag string ) func (next http.Handler ) http.Handler {
15
+ func TagHandler (tagHeader string ) func (next http.Handler ) http.Handler {
16
16
return func (next http.Handler ) http.Handler {
17
17
return http .HandlerFunc (func (writer http.ResponseWriter , request * http.Request ) {
18
18
ctx := request .Context ()
19
- ctx = newBaggage (ctx , request , headerTag )
19
+ ctx = newBaggage (ctx , request , tagHeader )
20
20
next .ServeHTTP (writer , request .WithContext (ctx ))
21
21
})
22
22
}
23
23
}
24
24
25
- func newBaggage (ctx context.Context , request * http.Request , headerTag string ) context.Context {
25
+ func newBaggage (ctx context.Context , request * http.Request , tagHeader string ) context.Context {
26
26
span := trace .SpanFromContext (ctx )
27
- tagString := request .Header .Get (headerTag )
27
+ tagString := request .Header .Get (tagHeader )
28
28
if len (tagString ) == 0 {
29
29
return ctx
30
30
}
31
- logx .WithContext (ctx ).Debugw ("flow staining..." , logx .Field (" tag" , tagString ))
31
+ logx .WithContext (ctx ).Debugw ("flow staining..." , logx .Field (tag . Key , tagString ))
32
32
33
33
ctx = tag .ContextWithTag (ctx , tagString )
34
34
span .SetAttributes (httpColorAttributeKey .String (tagString ))
0 commit comments