mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-09 19:52:30 +02:00
Properly set the net.host.name
and http.url
tags in OpenTelemetry traces
This commit is contained in:
@@ -6,6 +6,9 @@
|
|||||||
- (pro) Add [monochrome](https://docs.imgproxy.net/latest/usage/processing#monochrome) processing option.
|
- (pro) Add [monochrome](https://docs.imgproxy.net/latest/usage/processing#monochrome) processing option.
|
||||||
- (pro) Add [duotone](https://docs.imgproxy.net/latest/usage/processing#duotone) processing option.
|
- (pro) Add [duotone](https://docs.imgproxy.net/latest/usage/processing#duotone) processing option.
|
||||||
|
|
||||||
|
# Change
|
||||||
|
- Properly set the `net.host.name` and `http.url` tags in OpenTelemetry traces.
|
||||||
|
|
||||||
# Fix
|
# Fix
|
||||||
- Fix handling `#` symbols in `local://`, `s3://`, `gcs://`, `abs://`, and `swift://` URLs.
|
- Fix handling `#` symbols in `local://`, `s3://`, `gcs://`, `abs://`, and `swift://` URLs.
|
||||||
- Fix `IMGPROXY_FALLBACK_IMAGE_HTTP_CODE` value check. Allow `0` value.
|
- Fix `IMGPROXY_FALLBACK_IMAGE_HTTP_CODE` value check. Allow `0` value.
|
||||||
|
@@ -35,8 +35,8 @@ import (
|
|||||||
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
|
sdkmetric "go.opentelemetry.io/otel/sdk/metric"
|
||||||
"go.opentelemetry.io/otel/sdk/resource"
|
"go.opentelemetry.io/otel/sdk/resource"
|
||||||
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
||||||
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
|
semconv "go.opentelemetry.io/otel/semconv/v1.20.0"
|
||||||
"go.opentelemetry.io/otel/semconv/v1.17.0/httpconv"
|
"go.opentelemetry.io/otel/semconv/v1.20.0/httpconv"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
|
||||||
@@ -397,10 +397,16 @@ func StartRootSpan(ctx context.Context, rw http.ResponseWriter, r *http.Request)
|
|||||||
ctx = propagator.Extract(ctx, propagation.HeaderCarrier(r.Header))
|
ctx = propagator.Extract(ctx, propagation.HeaderCarrier(r.Header))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server := r.Host
|
||||||
|
if len(server) == 0 {
|
||||||
|
server = "imgproxy"
|
||||||
|
}
|
||||||
|
|
||||||
ctx, span := tracer.Start(
|
ctx, span := tracer.Start(
|
||||||
ctx, "/request",
|
ctx, "/request",
|
||||||
trace.WithSpanKind(trace.SpanKindServer),
|
trace.WithSpanKind(trace.SpanKindServer),
|
||||||
trace.WithAttributes(httpconv.ServerRequest("imgproxy", r)...),
|
trace.WithAttributes(httpconv.ServerRequest(server, r)...),
|
||||||
|
trace.WithAttributes(semconv.HTTPURL(r.RequestURI)),
|
||||||
)
|
)
|
||||||
ctx = context.WithValue(ctx, hasSpanCtxKey{}, struct{}{})
|
ctx = context.WithValue(ctx, hasSpanCtxKey{}, struct{}{})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user