[#44] add tracing support refactoring
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
parent
8a22991326
commit
cdaab4feab
9 changed files with 78 additions and 137 deletions
|
@ -77,6 +77,7 @@ func StartHTTPServerSpan(ctx context.Context, req *fasthttp.RequestCtx, operatio
|
|||
attribute.String("http.path", string(req.Path())),
|
||||
semconv.HTTPMethod(string(req.Method())),
|
||||
semconv.RPCService("frostfs-http-gw"),
|
||||
attribute.String("http.query", req.QueryArgs().String()),
|
||||
), trace.WithSpanKind(trace.SpanKindServer))
|
||||
return tracing.StartSpanFromContext(ctx, operationName, opts...)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"git.frostfs.info/TrueCloudLab/frostfs-http-gw/resolver"
|
||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool"
|
||||
"github.com/valyala/fasthttp"
|
||||
)
|
||||
|
||||
// GetContainerID decode container id, if it's not a valid container id
|
||||
|
@ -43,3 +44,13 @@ func GetEpochDurations(ctx context.Context, p *pool.Pool) (*EpochDurations, erro
|
|||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// SetContextToRequest adds new context to fasthttp request.
|
||||
func SetContextToRequest(ctx context.Context, c *fasthttp.RequestCtx) {
|
||||
c.SetUserValue("context", ctx)
|
||||
}
|
||||
|
||||
// GetContextFromRequest returns main context from fasthttp request context.
|
||||
func GetContextFromRequest(c *fasthttp.RequestCtx) context.Context {
|
||||
return c.UserValue("context").(context.Context)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue