From 035f3c4a37e3a84adeb357b343a7ae3a4f0ade6a Mon Sep 17 00:00:00 2001 From: Vincent Free Date: Sat, 15 Oct 2022 22:47:59 +0200 Subject: [PATCH] update go version and change to a client kind --- SECURITY.md | 1 + go.mod | 2 +- otelmiddleware/tracing.go | 9 ++++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 45329e3..59fba0a 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,6 +4,7 @@ | Version | Supported | | ------- | ------------------ | +| 0.0.7 | :white_check_mark: | | 0.0.6 | :white_check_mark: | | 0.0.5 | :white_check_mark: | | < 0.0.5 | :x: | diff --git a/go.mod b/go.mod index 08e8837..671f781 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/vincentfree/opentelemetry-http -go 1.18 +go 1.19 require ( go.opentelemetry.io/otel v1.11.0 diff --git a/otelmiddleware/tracing.go b/otelmiddleware/tracing.go index 4ce269f..70295b6 100644 --- a/otelmiddleware/tracing.go +++ b/otelmiddleware/tracing.go @@ -7,12 +7,12 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/propagation" - semconv "go.opentelemetry.io/otel/semconv/v1.7.0" + semconv "go.opentelemetry.io/otel/semconv/v1.11.0" "go.opentelemetry.io/otel/trace" ) // version is used as the instrumentation version. -const version = "0.0.6" +const version = "0.0.7" // TraceOption takes a traceConfig struct and applies changes. // It can be passed to the TraceWithOptions function to configure a traceConfig struct. @@ -57,10 +57,13 @@ func TraceWithOptions(opt ...TraceOption) func(next http.Handler) http.Handler { ctx := config.propagator.Extract(requestCtx, propagation.HeaderCarrier(r.Header)) // the standard trace.SpanStartOption options whom are applied to every server handler. opts := []trace.SpanStartOption{ + trace.WithAttributes(semconv.NetAttributesFromHTTPRequest("tcp", r)...), trace.WithAttributes(semconv.EndUserAttributesFromHTTPRequest(r)...), trace.WithAttributes(semconv.HTTPServerAttributesFromHTTPRequest(r.Host, extractRoute(r.RequestURI), r)...), - trace.WithSpanKind(trace.SpanKindServer), + trace.WithAttributes(semconv.HTTPClientAttributesFromHTTPRequest(r)...), + trace.WithAttributes(semconv.TelemetrySDKLanguageGo), + trace.WithSpanKind(trace.SpanKindClient), } // check for the traceConfig.attributes if present apply them to the trace.Span. if len(config.attributes) > 0 {