ЛР7 на 4: HTTPS, mTLS, OpenBao AppRole и ротация leaf.
Skeleton contracts / contracts (pull_request) Blocked by required conditions
Skeleton contracts / contracts (pull_request) Blocked by required conditions
Smoke/security/grade4/persistence/failover пройдены; REPORT и DEFENSE.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package telemetry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
func Incoming(r *http.Request) context.Context {
|
||||
return otel.GetTextMapPropagator().Extract(r.Context(), propagation.HeaderCarrier(r.Header))
|
||||
}
|
||||
|
||||
type roundTripper struct{ next http.RoundTripper }
|
||||
|
||||
func Transport(next http.RoundTripper) http.RoundTripper {
|
||||
if next == nil {
|
||||
next = http.DefaultTransport
|
||||
}
|
||||
return &roundTripper{next: next}
|
||||
}
|
||||
|
||||
func (t *roundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
|
||||
ctx, span := Start(r.Context(), "s3.request", trace.SpanKindClient)
|
||||
defer span.End()
|
||||
resp, err := t.next.RoundTrip(r.Clone(ctx))
|
||||
Failure(span, err)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func RoutePattern(r *http.Request) string {
|
||||
if rc := chi.RouteContext(r.Context()); rc != nil {
|
||||
if pattern := rc.RoutePattern(); pattern != "" {
|
||||
return pattern
|
||||
}
|
||||
}
|
||||
return r.URL.Path
|
||||
}
|
||||
Reference in New Issue
Block a user