diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f04d5f440c..554cdb94587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - The `Minimum` field of the `LogProcessor` in `go.opentelemetry.io/contrib/processors/minsev` is removed. Use `NewLogProcessor` to configure this setting. (#6116) +- The deprecated `go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron` package is removed. (#6186) - The deprecated `go.opentelemetry.io/contrib/samplers/aws/xray` package is removed. (#6187) diff --git a/CODEOWNERS b/CODEOWNERS index 47b50e98c1a..4aed012511e 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -50,7 +50,6 @@ instrumentation/github.com/gorilla/mux/otelmux/ @open-te instrumentation/github.com/labstack/echo/otelecho/ @open-telemetry/go-approvers instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/ @open-telemetry/go-approvers instrumentation/google.golang.org/grpc/otelgrpc/ @open-telemetry/go-approvers @dashpole -instrumentation/gopkg.in/macaron.v1/otelmacaron/ @open-telemetry/go-approvers instrumentation/host/ @open-telemetry/go-approvers @dmathieu instrumentation/net/http/httptrace/otelhttptrace/ @open-telemetry/go-approvers @dmathieu diff --git a/instrumentation/README.md b/instrumentation/README.md index fbc8e0ac657..77fe61c45c1 100644 --- a/instrumentation/README.md +++ b/instrumentation/README.md @@ -49,7 +49,6 @@ The following instrumentation packages are provided for popular Go packages and | [github.com/labstack/echo](./github.com/labstack/echo/otelecho) | | ✓ | | [go.mongodb.org/mongo-driver](./go.mongodb.org/mongo-driver/mongo/otelmongo) | | ✓ | | [google.golang.org/grpc](./google.golang.org/grpc/otelgrpc) | ✓ | ✓ | -| [gopkg.in/macaron.v1](./gopkg.in/macaron.v1/otelmacaron) | | ✓ | | [host](./host) | ✓ | | | [net/http](./net/http/otelhttp) | ✓ | ✓ | | [net/http/httptrace](./net/http/httptrace/otelhttptrace) | | ✓ | diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/config.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/config.go deleted file mode 100644 index 8b14022267f..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/config.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package otelmacaron // import "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron" - -import ( - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/propagation" - "go.opentelemetry.io/otel/trace" -) - -// config is a group of options for this instrumentation. -type config struct { - TracerProvider trace.TracerProvider - Propagators propagation.TextMapPropagator -} - -// Option applies an option value for a config. -type Option interface { - apply(*config) -} - -// newConfig returns a config configured with all the passed Options. -func newConfig(opts []Option) *config { - c := &config{ - Propagators: otel.GetTextMapPropagator(), - TracerProvider: otel.GetTracerProvider(), - } - for _, o := range opts { - o.apply(c) - } - return c -} - -type propagatorsOption struct{ p propagation.TextMapPropagator } - -func (o propagatorsOption) apply(c *config) { - if o.p != nil { - c.Propagators = o.p - } -} - -// WithPropagators returns an Option to use the Propagators when extracting -// and injecting trace context from HTTP requests. -func WithPropagators(p propagation.TextMapPropagator) Option { - return propagatorsOption{p: p} -} - -type tracerProviderOption struct{ tp trace.TracerProvider } - -func (o tracerProviderOption) apply(c *config) { - if o.tp != nil { - c.TracerProvider = o.tp - } -} - -// WithTracerProvider returns an Option to use the TracerProvider when -// creating a Tracer. -func WithTracerProvider(tp trace.TracerProvider) Option { - return tracerProviderOption{tp: tp} -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/doc.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/doc.go deleted file mode 100644 index d700bec1131..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Package otelmacaron instruments gopkg.in/macaron.v1. -// -// Currently only the routing of a received message can be instrumented. To do -// it, use the Middleware function. -// -// Deprecated: otelmacaron has no Code Owner. -// After August 21, 2024, it may no longer be supported and may stop -// receiving new releases unless a new Code Owner is found. See -// [this issue] if you would like to become the Code Owner of this module. -// -// [this issue]: https://github.com/open-telemetry/opentelemetry-go-contrib/issues/5552 -package otelmacaron // import "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron" diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/Dockerfile b/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/Dockerfile deleted file mode 100644 index 33545cf96a4..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 -FROM golang:alpine AS base -COPY . /src/ -WORKDIR /src/instrumentation/gopkg.in/macaron.v1/otelmacaron/example - -FROM base AS macaron-server -RUN go install ./server.go -CMD ["/go/bin/server"] diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/README.md b/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/README.md deleted file mode 100644 index a0f5349aa9a..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# gopkg.in/macaron.v1/otelmacaron instrumentation example - -:warning: Deprecated: otelmacaron has no Code Owner. diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/docker-compose.yml b/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/docker-compose.yml deleted file mode 100644 index c0ff7f51534..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/docker-compose.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 -version: "3.7" -services: - macaron-client: - image: golang:alpine - networks: - - example - command: - - "/bin/sh" - - "-c" - - "wget http://macaron-server:8080/users/123 && cat 123" - depends_on: - - macaron-server - macaron-server: - build: - dockerfile: $PWD/Dockerfile - context: ../../../../.. - ports: - - "8080:80" - command: - - "/bin/sh" - - "-c" - - "/go/bin/server" - networks: - - example - environment: - - PORT=80 -networks: - example: diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/go.mod b/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/go.mod deleted file mode 100644 index 295c058c67d..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/go.mod +++ /dev/null @@ -1,30 +0,0 @@ -// Deprecated: otelmacaron has no Code Owner. -module go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/example - -go 1.22 - -replace ( - go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron => ../ - go.opentelemetry.io/contrib/propagators/b3 => ../../../../../propagators/b3 -) - -require ( - go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron v0.55.0 - go.opentelemetry.io/otel v1.30.0 - go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.30.0 - go.opentelemetry.io/otel/sdk v1.30.0 - go.opentelemetry.io/otel/trace v1.30.0 - gopkg.in/macaron.v1 v1.5.0 -) - -require ( - github.com/go-logr/logr v1.4.2 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-macaron/inject v0.0.0-20200308113650-138e5925c53b // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/unknwon/com v1.0.1 // indirect - go.opentelemetry.io/otel/metric v1.30.0 // indirect - golang.org/x/crypto v0.28.0 // indirect - golang.org/x/sys v0.26.0 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect -) diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/go.sum b/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/go.sum deleted file mode 100644 index 5b915042963..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/go.sum +++ /dev/null @@ -1,51 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-macaron/inject v0.0.0-20200308113650-138e5925c53b h1:/aWj44HoEycE4MDi2HZf4t+XI7hKwZRltZf4ih5tB2c= -github.com/go-macaron/inject v0.0.0-20200308113650-138e5925c53b/go.mod h1:VFI2o2q9kYsC4o7VP1HrEVosiZZTd+MVT3YZx4gqvJw= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRidnzC1Oq86fpX1q/iEv2KJdrCtttYjT4= -github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= -github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= -github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= -github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8= -github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs= -github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= -go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= -go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.30.0 h1:kn1BudCgwtE7PxLqcZkErpD8GKqLZ6BSzeW9QihQJeM= -go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.30.0/go.mod h1:ljkUDtAMdleoi9tIG1R6dJUpVwDcYjw3J2Q6Q/SuiC0= -go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= -go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= -go.opentelemetry.io/otel/sdk v1.30.0 h1:cHdik6irO49R5IysVhdn8oaiR9m8XluDaJAs4DfOrYE= -go.opentelemetry.io/otel/sdk v1.30.0/go.mod h1:p14X4Ok8S+sygzblytT1nqG98QG2KYKv++HE0LY/mhg= -go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= -go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/macaron.v1 v1.5.0 h1:/dXJaeQagWLjVjCrKH8dgSSU7yG4qTv6rBKpqhYaCyc= -gopkg.in/macaron.v1 v1.5.0/go.mod h1:sAYUd2r8Q+jLnCN4/ZmdAYHzQn67agV5sAqKFQgrRrw= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/server.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/server.go deleted file mode 100644 index 85d4d010b5d..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/example/server.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package main - -import ( - "context" - "log" - - "gopkg.in/macaron.v1" - - "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron" // nolint:staticcheck // deprecated. - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/attribute" - stdout "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" - "go.opentelemetry.io/otel/propagation" - sdktrace "go.opentelemetry.io/otel/sdk/trace" - oteltrace "go.opentelemetry.io/otel/trace" -) - -var tracer = otel.Tracer("macaron-server") - -func main() { - tp, err := initTracer() - if err != nil { - log.Fatal(err) - } - defer func() { - if err := tp.Shutdown(context.Background()); err != nil { - log.Printf("Error shutting down tracer provider: %v", err) - } - }() - m := macaron.Classic() - m.Use(otelmacaron.Middleware("my-server")) - m.Get("/users/:id", func(ctx *macaron.Context) string { - id := ctx.Params("id") - name := getUser(ctx.Req.Context(), id) - return name - }) - m.Run() -} - -func initTracer() (*sdktrace.TracerProvider, error) { - exporter, err := stdout.New(stdout.WithPrettyPrint()) - if err != nil { - return nil, err - } - tp := sdktrace.NewTracerProvider( - sdktrace.WithSampler(sdktrace.AlwaysSample()), - sdktrace.WithBatcher(exporter), - ) - otel.SetTracerProvider(tp) - otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) - return tp, nil -} - -func getUser(ctx context.Context, id string) string { - _, span := tracer.Start(ctx, "getUser", oteltrace.WithAttributes(attribute.String("id", id))) - defer span.End() - if id == "123" { - return "otelmacaron tester" - } - return "unknown" -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/go.mod b/instrumentation/gopkg.in/macaron.v1/otelmacaron/go.mod deleted file mode 100644 index 472259ff427..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/go.mod +++ /dev/null @@ -1,27 +0,0 @@ -// Deprecated: otelmacaron has no Code Owner. -module go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron - -go 1.22 - -replace go.opentelemetry.io/contrib/propagators/b3 => ../../../../propagators/b3 - -require ( - github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/contrib/propagators/b3 v1.30.0 - go.opentelemetry.io/otel v1.30.0 - go.opentelemetry.io/otel/trace v1.30.0 - gopkg.in/macaron.v1 v1.5.0 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-logr/logr v1.4.2 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-macaron/inject v0.0.0-20200308113650-138e5925c53b // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/unknwon/com v1.0.1 // indirect - go.opentelemetry.io/otel/metric v1.30.0 // indirect - golang.org/x/crypto v0.28.0 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/go.sum b/instrumentation/gopkg.in/macaron.v1/otelmacaron/go.sum deleted file mode 100644 index c556202bc18..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/go.sum +++ /dev/null @@ -1,45 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-macaron/inject v0.0.0-20200308113650-138e5925c53b h1:/aWj44HoEycE4MDi2HZf4t+XI7hKwZRltZf4ih5tB2c= -github.com/go-macaron/inject v0.0.0-20200308113650-138e5925c53b/go.mod h1:VFI2o2q9kYsC4o7VP1HrEVosiZZTd+MVT3YZx4gqvJw= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRidnzC1Oq86fpX1q/iEv2KJdrCtttYjT4= -github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= -github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= -github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= -github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8= -github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs= -github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= -go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= -go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= -go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= -go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= -go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/macaron.v1 v1.5.0 h1:/dXJaeQagWLjVjCrKH8dgSSU7yG4qTv6rBKpqhYaCyc= -gopkg.in/macaron.v1 v1.5.0/go.mod h1:sAYUd2r8Q+jLnCN4/ZmdAYHzQn67agV5sAqKFQgrRrw= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/gen.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/gen.go deleted file mode 100644 index 3e07663e279..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/gen.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package semconvutil // import "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil" - -// Generate semconvutil package: -//go:generate gotmpl --body=../../../../../../internal/shared/semconvutil/httpconv_test.go.tmpl "--data={}" --out=httpconv_test.go -//go:generate gotmpl --body=../../../../../../internal/shared/semconvutil/httpconv.go.tmpl "--data={}" --out=httpconv.go -//go:generate gotmpl --body=../../../../../../internal/shared/semconvutil/netconv_test.go.tmpl "--data={}" --out=netconv_test.go -//go:generate gotmpl --body=../../../../../../internal/shared/semconvutil/netconv.go.tmpl "--data={}" --out=netconv.go diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/httpconv.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/httpconv.go deleted file mode 100644 index ae5563010b6..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/httpconv.go +++ /dev/null @@ -1,575 +0,0 @@ -// Code created by gotmpl. DO NOT MODIFY. -// source: internal/shared/semconvutil/httpconv.go.tmpl - -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package semconvutil // import "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil" - -import ( - "fmt" - "net/http" - "strings" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/codes" - semconv "go.opentelemetry.io/otel/semconv/v1.20.0" -) - -// HTTPClientResponse returns trace attributes for an HTTP response received by a -// client from a server. It will return the following attributes if the related -// values are defined in resp: "http.status.code", -// "http.response_content_length". -// -// This does not add all OpenTelemetry required attributes for an HTTP event, -// it assumes ClientRequest was used to create the span with a complete set of -// attributes. If a complete set of attributes can be generated using the -// request contained in resp. For example: -// -// append(HTTPClientResponse(resp), ClientRequest(resp.Request)...) -func HTTPClientResponse(resp *http.Response) []attribute.KeyValue { - return hc.ClientResponse(resp) -} - -// HTTPClientRequest returns trace attributes for an HTTP request made by a client. -// The following attributes are always returned: "http.url", "http.method", -// "net.peer.name". The following attributes are returned if the related values -// are defined in req: "net.peer.port", "user_agent.original", -// "http.request_content_length". -func HTTPClientRequest(req *http.Request) []attribute.KeyValue { - return hc.ClientRequest(req) -} - -// HTTPClientRequestMetrics returns metric attributes for an HTTP request made by a client. -// The following attributes are always returned: "http.method", "net.peer.name". -// The following attributes are returned if the -// related values are defined in req: "net.peer.port". -func HTTPClientRequestMetrics(req *http.Request) []attribute.KeyValue { - return hc.ClientRequestMetrics(req) -} - -// HTTPClientStatus returns a span status code and message for an HTTP status code -// value received by a client. -func HTTPClientStatus(code int) (codes.Code, string) { - return hc.ClientStatus(code) -} - -// HTTPServerRequest returns trace attributes for an HTTP request received by a -// server. -// -// The server must be the primary server name if it is known. For example this -// would be the ServerName directive -// (https://httpd.apache.org/docs/2.4/mod/core.html#servername) for an Apache -// server, and the server_name directive -// (http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name) for an -// nginx server. More generically, the primary server name would be the host -// header value that matches the default virtual host of an HTTP server. It -// should include the host identifier and if a port is used to route to the -// server that port identifier should be included as an appropriate port -// suffix. -// -// If the primary server name is not known, server should be an empty string. -// The req Host will be used to determine the server instead. -// -// The following attributes are always returned: "http.method", "http.scheme", -// "http.target", "net.host.name". The following attributes are returned if -// they related values are defined in req: "net.host.port", "net.sock.peer.addr", -// "net.sock.peer.port", "user_agent.original", "http.client_ip". -func HTTPServerRequest(server string, req *http.Request) []attribute.KeyValue { - return hc.ServerRequest(server, req) -} - -// HTTPServerRequestMetrics returns metric attributes for an HTTP request received by a -// server. -// -// The server must be the primary server name if it is known. For example this -// would be the ServerName directive -// (https://httpd.apache.org/docs/2.4/mod/core.html#servername) for an Apache -// server, and the server_name directive -// (http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name) for an -// nginx server. More generically, the primary server name would be the host -// header value that matches the default virtual host of an HTTP server. It -// should include the host identifier and if a port is used to route to the -// server that port identifier should be included as an appropriate port -// suffix. -// -// If the primary server name is not known, server should be an empty string. -// The req Host will be used to determine the server instead. -// -// The following attributes are always returned: "http.method", "http.scheme", -// "net.host.name". The following attributes are returned if they related -// values are defined in req: "net.host.port". -func HTTPServerRequestMetrics(server string, req *http.Request) []attribute.KeyValue { - return hc.ServerRequestMetrics(server, req) -} - -// HTTPServerStatus returns a span status code and message for an HTTP status code -// value returned by a server. Status codes in the 400-499 range are not -// returned as errors. -func HTTPServerStatus(code int) (codes.Code, string) { - return hc.ServerStatus(code) -} - -// httpConv are the HTTP semantic convention attributes defined for a version -// of the OpenTelemetry specification. -type httpConv struct { - NetConv *netConv - - HTTPClientIPKey attribute.Key - HTTPMethodKey attribute.Key - HTTPRequestContentLengthKey attribute.Key - HTTPResponseContentLengthKey attribute.Key - HTTPRouteKey attribute.Key - HTTPSchemeHTTP attribute.KeyValue - HTTPSchemeHTTPS attribute.KeyValue - HTTPStatusCodeKey attribute.Key - HTTPTargetKey attribute.Key - HTTPURLKey attribute.Key - UserAgentOriginalKey attribute.Key -} - -var hc = &httpConv{ - NetConv: nc, - - HTTPClientIPKey: semconv.HTTPClientIPKey, - HTTPMethodKey: semconv.HTTPMethodKey, - HTTPRequestContentLengthKey: semconv.HTTPRequestContentLengthKey, - HTTPResponseContentLengthKey: semconv.HTTPResponseContentLengthKey, - HTTPRouteKey: semconv.HTTPRouteKey, - HTTPSchemeHTTP: semconv.HTTPSchemeHTTP, - HTTPSchemeHTTPS: semconv.HTTPSchemeHTTPS, - HTTPStatusCodeKey: semconv.HTTPStatusCodeKey, - HTTPTargetKey: semconv.HTTPTargetKey, - HTTPURLKey: semconv.HTTPURLKey, - UserAgentOriginalKey: semconv.UserAgentOriginalKey, -} - -// ClientResponse returns attributes for an HTTP response received by a client -// from a server. The following attributes are returned if the related values -// are defined in resp: "http.status.code", "http.response_content_length". -// -// This does not add all OpenTelemetry required attributes for an HTTP event, -// it assumes ClientRequest was used to create the span with a complete set of -// attributes. If a complete set of attributes can be generated using the -// request contained in resp. For example: -// -// append(ClientResponse(resp), ClientRequest(resp.Request)...) -func (c *httpConv) ClientResponse(resp *http.Response) []attribute.KeyValue { - /* The following semantic conventions are returned if present: - http.status_code int - http.response_content_length int - */ - var n int - if resp.StatusCode > 0 { - n++ - } - if resp.ContentLength > 0 { - n++ - } - - attrs := make([]attribute.KeyValue, 0, n) - if resp.StatusCode > 0 { - attrs = append(attrs, c.HTTPStatusCodeKey.Int(resp.StatusCode)) - } - if resp.ContentLength > 0 { - attrs = append(attrs, c.HTTPResponseContentLengthKey.Int(int(resp.ContentLength))) - } - return attrs -} - -// ClientRequest returns attributes for an HTTP request made by a client. The -// following attributes are always returned: "http.url", "http.method", -// "net.peer.name". The following attributes are returned if the related values -// are defined in req: "net.peer.port", "user_agent.original", -// "http.request_content_length", "user_agent.original". -func (c *httpConv) ClientRequest(req *http.Request) []attribute.KeyValue { - /* The following semantic conventions are returned if present: - http.method string - user_agent.original string - http.url string - net.peer.name string - net.peer.port int - http.request_content_length int - */ - - /* The following semantic conventions are not returned: - http.status_code This requires the response. See ClientResponse. - http.response_content_length This requires the response. See ClientResponse. - net.sock.family This requires the socket used. - net.sock.peer.addr This requires the socket used. - net.sock.peer.name This requires the socket used. - net.sock.peer.port This requires the socket used. - http.resend_count This is something outside of a single request. - net.protocol.name The value is the Request is ignored, and the go client will always use "http". - net.protocol.version The value in the Request is ignored, and the go client will always use 1.1 or 2.0. - */ - n := 3 // URL, peer name, proto, and method. - var h string - if req.URL != nil { - h = req.URL.Host - } - peer, p := firstHostPort(h, req.Header.Get("Host")) - port := requiredHTTPPort(req.URL != nil && req.URL.Scheme == "https", p) - if port > 0 { - n++ - } - useragent := req.UserAgent() - if useragent != "" { - n++ - } - if req.ContentLength > 0 { - n++ - } - - attrs := make([]attribute.KeyValue, 0, n) - - attrs = append(attrs, c.method(req.Method)) - - var u string - if req.URL != nil { - // Remove any username/password info that may be in the URL. - userinfo := req.URL.User - req.URL.User = nil - u = req.URL.String() - // Restore any username/password info that was removed. - req.URL.User = userinfo - } - attrs = append(attrs, c.HTTPURLKey.String(u)) - - attrs = append(attrs, c.NetConv.PeerName(peer)) - if port > 0 { - attrs = append(attrs, c.NetConv.PeerPort(port)) - } - - if useragent != "" { - attrs = append(attrs, c.UserAgentOriginalKey.String(useragent)) - } - - if l := req.ContentLength; l > 0 { - attrs = append(attrs, c.HTTPRequestContentLengthKey.Int64(l)) - } - - return attrs -} - -// ClientRequestMetrics returns metric attributes for an HTTP request made by a client. The -// following attributes are always returned: "http.method", "net.peer.name". -// The following attributes are returned if the related values -// are defined in req: "net.peer.port". -func (c *httpConv) ClientRequestMetrics(req *http.Request) []attribute.KeyValue { - /* The following semantic conventions are returned if present: - http.method string - net.peer.name string - net.peer.port int - */ - - n := 2 // method, peer name. - var h string - if req.URL != nil { - h = req.URL.Host - } - peer, p := firstHostPort(h, req.Header.Get("Host")) - port := requiredHTTPPort(req.URL != nil && req.URL.Scheme == "https", p) - if port > 0 { - n++ - } - - attrs := make([]attribute.KeyValue, 0, n) - attrs = append(attrs, c.method(req.Method), c.NetConv.PeerName(peer)) - - if port > 0 { - attrs = append(attrs, c.NetConv.PeerPort(port)) - } - - return attrs -} - -// ServerRequest returns attributes for an HTTP request received by a server. -// -// The server must be the primary server name if it is known. For example this -// would be the ServerName directive -// (https://httpd.apache.org/docs/2.4/mod/core.html#servername) for an Apache -// server, and the server_name directive -// (http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name) for an -// nginx server. More generically, the primary server name would be the host -// header value that matches the default virtual host of an HTTP server. It -// should include the host identifier and if a port is used to route to the -// server that port identifier should be included as an appropriate port -// suffix. -// -// If the primary server name is not known, server should be an empty string. -// The req Host will be used to determine the server instead. -// -// The following attributes are always returned: "http.method", "http.scheme", -// "http.target", "net.host.name". The following attributes are returned if they -// related values are defined in req: "net.host.port", "net.sock.peer.addr", -// "net.sock.peer.port", "user_agent.original", "http.client_ip", -// "net.protocol.name", "net.protocol.version". -func (c *httpConv) ServerRequest(server string, req *http.Request) []attribute.KeyValue { - /* The following semantic conventions are returned if present: - http.method string - http.scheme string - net.host.name string - net.host.port int - net.sock.peer.addr string - net.sock.peer.port int - user_agent.original string - http.client_ip string - net.protocol.name string Note: not set if the value is "http". - net.protocol.version string - http.target string Note: doesn't include the query parameter. - */ - - /* The following semantic conventions are not returned: - http.status_code This requires the response. - http.request_content_length This requires the len() of body, which can mutate it. - http.response_content_length This requires the response. - http.route This is not available. - net.sock.peer.name This would require a DNS lookup. - net.sock.host.addr The request doesn't have access to the underlying socket. - net.sock.host.port The request doesn't have access to the underlying socket. - - */ - n := 4 // Method, scheme, proto, and host name. - var host string - var p int - if server == "" { - host, p = splitHostPort(req.Host) - } else { - // Prioritize the primary server name. - host, p = splitHostPort(server) - if p < 0 { - _, p = splitHostPort(req.Host) - } - } - hostPort := requiredHTTPPort(req.TLS != nil, p) - if hostPort > 0 { - n++ - } - peer, peerPort := splitHostPort(req.RemoteAddr) - if peer != "" { - n++ - if peerPort > 0 { - n++ - } - } - useragent := req.UserAgent() - if useragent != "" { - n++ - } - - clientIP := serverClientIP(req.Header.Get("X-Forwarded-For")) - if clientIP != "" { - n++ - } - - var target string - if req.URL != nil { - target = req.URL.Path - if target != "" { - n++ - } - } - protoName, protoVersion := netProtocol(req.Proto) - if protoName != "" && protoName != "http" { - n++ - } - if protoVersion != "" { - n++ - } - - attrs := make([]attribute.KeyValue, 0, n) - - attrs = append(attrs, c.method(req.Method)) - attrs = append(attrs, c.scheme(req.TLS != nil)) - attrs = append(attrs, c.NetConv.HostName(host)) - - if hostPort > 0 { - attrs = append(attrs, c.NetConv.HostPort(hostPort)) - } - - if peer != "" { - // The Go HTTP server sets RemoteAddr to "IP:port", this will not be a - // file-path that would be interpreted with a sock family. - attrs = append(attrs, c.NetConv.SockPeerAddr(peer)) - if peerPort > 0 { - attrs = append(attrs, c.NetConv.SockPeerPort(peerPort)) - } - } - - if useragent != "" { - attrs = append(attrs, c.UserAgentOriginalKey.String(useragent)) - } - - if clientIP != "" { - attrs = append(attrs, c.HTTPClientIPKey.String(clientIP)) - } - - if target != "" { - attrs = append(attrs, c.HTTPTargetKey.String(target)) - } - - if protoName != "" && protoName != "http" { - attrs = append(attrs, c.NetConv.NetProtocolName.String(protoName)) - } - if protoVersion != "" { - attrs = append(attrs, c.NetConv.NetProtocolVersion.String(protoVersion)) - } - - return attrs -} - -// ServerRequestMetrics returns metric attributes for an HTTP request received -// by a server. -// -// The server must be the primary server name if it is known. For example this -// would be the ServerName directive -// (https://httpd.apache.org/docs/2.4/mod/core.html#servername) for an Apache -// server, and the server_name directive -// (http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name) for an -// nginx server. More generically, the primary server name would be the host -// header value that matches the default virtual host of an HTTP server. It -// should include the host identifier and if a port is used to route to the -// server that port identifier should be included as an appropriate port -// suffix. -// -// If the primary server name is not known, server should be an empty string. -// The req Host will be used to determine the server instead. -// -// The following attributes are always returned: "http.method", "http.scheme", -// "net.host.name". The following attributes are returned if they related -// values are defined in req: "net.host.port". -func (c *httpConv) ServerRequestMetrics(server string, req *http.Request) []attribute.KeyValue { - /* The following semantic conventions are returned if present: - http.scheme string - http.route string - http.method string - http.status_code int - net.host.name string - net.host.port int - net.protocol.name string Note: not set if the value is "http". - net.protocol.version string - */ - - n := 3 // Method, scheme, and host name. - var host string - var p int - if server == "" { - host, p = splitHostPort(req.Host) - } else { - // Prioritize the primary server name. - host, p = splitHostPort(server) - if p < 0 { - _, p = splitHostPort(req.Host) - } - } - hostPort := requiredHTTPPort(req.TLS != nil, p) - if hostPort > 0 { - n++ - } - protoName, protoVersion := netProtocol(req.Proto) - if protoName != "" { - n++ - } - if protoVersion != "" { - n++ - } - - attrs := make([]attribute.KeyValue, 0, n) - - attrs = append(attrs, c.methodMetric(req.Method)) - attrs = append(attrs, c.scheme(req.TLS != nil)) - attrs = append(attrs, c.NetConv.HostName(host)) - - if hostPort > 0 { - attrs = append(attrs, c.NetConv.HostPort(hostPort)) - } - if protoName != "" { - attrs = append(attrs, c.NetConv.NetProtocolName.String(protoName)) - } - if protoVersion != "" { - attrs = append(attrs, c.NetConv.NetProtocolVersion.String(protoVersion)) - } - - return attrs -} - -func (c *httpConv) method(method string) attribute.KeyValue { - if method == "" { - return c.HTTPMethodKey.String(http.MethodGet) - } - return c.HTTPMethodKey.String(method) -} - -func (c *httpConv) methodMetric(method string) attribute.KeyValue { - method = strings.ToUpper(method) - switch method { - case http.MethodConnect, http.MethodDelete, http.MethodGet, http.MethodHead, http.MethodOptions, http.MethodPatch, http.MethodPost, http.MethodPut, http.MethodTrace: - default: - method = "_OTHER" - } - return c.HTTPMethodKey.String(method) -} - -func (c *httpConv) scheme(https bool) attribute.KeyValue { // nolint:revive - if https { - return c.HTTPSchemeHTTPS - } - return c.HTTPSchemeHTTP -} - -func serverClientIP(xForwardedFor string) string { - if idx := strings.Index(xForwardedFor, ","); idx >= 0 { - xForwardedFor = xForwardedFor[:idx] - } - return xForwardedFor -} - -func requiredHTTPPort(https bool, port int) int { // nolint:revive - if https { - if port > 0 && port != 443 { - return port - } - } else { - if port > 0 && port != 80 { - return port - } - } - return -1 -} - -// Return the request host and port from the first non-empty source. -func firstHostPort(source ...string) (host string, port int) { - for _, hostport := range source { - host, port = splitHostPort(hostport) - if host != "" || port > 0 { - break - } - } - return -} - -// ClientStatus returns a span status code and message for an HTTP status code -// value received by a client. -func (c *httpConv) ClientStatus(code int) (codes.Code, string) { - if code < 100 || code >= 600 { - return codes.Error, fmt.Sprintf("Invalid HTTP status code %d", code) - } - if code >= 400 { - return codes.Error, "" - } - return codes.Unset, "" -} - -// ServerStatus returns a span status code and message for an HTTP status code -// value returned by a server. Status codes in the 400-499 range are not -// returned as errors. -func (c *httpConv) ServerStatus(code int) (codes.Code, string) { - if code < 100 || code >= 600 { - return codes.Error, fmt.Sprintf("Invalid HTTP status code %d", code) - } - if code >= 500 { - return codes.Error, "" - } - return codes.Unset, "" -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/httpconv_test.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/httpconv_test.go deleted file mode 100644 index 868b09da277..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/httpconv_test.go +++ /dev/null @@ -1,510 +0,0 @@ -// Code created by gotmpl. DO NOT MODIFY. -// source: internal/shared/semconvutil/httpconv_test.go.tmpl - -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package semconvutil - -import ( - "net/http" - "net/http/httptest" - "net/url" - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/codes" -) - -func TestHTTPClientResponse(t *testing.T) { - const stat, n = 201, 397 - resp := &http.Response{ - StatusCode: stat, - ContentLength: n, - } - got := HTTPClientResponse(resp) - assert.Equal(t, 2, cap(got), "slice capacity") - assert.ElementsMatch(t, []attribute.KeyValue{ - attribute.Key("http.status_code").Int(stat), - attribute.Key("http.response_content_length").Int(n), - }, got) -} - -func TestHTTPSClientRequest(t *testing.T) { - req := &http.Request{ - Method: http.MethodGet, - URL: &url.URL{ - Scheme: "https", - Host: "127.0.0.1:443", - Path: "/resource", - }, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - } - - assert.ElementsMatch( - t, - []attribute.KeyValue{ - attribute.String("http.method", "GET"), - attribute.String("http.url", "https://127.0.0.1:443/resource"), - attribute.String("net.peer.name", "127.0.0.1"), - }, - HTTPClientRequest(req), - ) -} - -func TestHTTPSClientRequestMetrics(t *testing.T) { - req := &http.Request{ - Method: http.MethodGet, - URL: &url.URL{ - Scheme: "https", - Host: "127.0.0.1:443", - Path: "/resource", - }, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - } - - assert.ElementsMatch( - t, - []attribute.KeyValue{ - attribute.String("http.method", "GET"), - attribute.String("net.peer.name", "127.0.0.1"), - }, - HTTPClientRequestMetrics(req), - ) -} - -func TestHTTPClientRequest(t *testing.T) { - const ( - user = "alice" - n = 128 - agent = "Go-http-client/1.1" - ) - req := &http.Request{ - Method: http.MethodGet, - URL: &url.URL{ - Scheme: "http", - Host: "127.0.0.1:8080", - Path: "/resource", - }, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - Header: http.Header{ - "User-Agent": []string{agent}, - }, - ContentLength: n, - } - req.SetBasicAuth(user, "pswrd") - - assert.ElementsMatch( - t, - []attribute.KeyValue{ - attribute.String("http.method", "GET"), - attribute.String("http.url", "http://127.0.0.1:8080/resource"), - attribute.String("net.peer.name", "127.0.0.1"), - attribute.Int("net.peer.port", 8080), - attribute.String("user_agent.original", agent), - attribute.Int("http.request_content_length", n), - }, - HTTPClientRequest(req), - ) -} - -func TestHTTPClientRequestMetrics(t *testing.T) { - const ( - user = "alice" - n = 128 - agent = "Go-http-client/1.1" - ) - req := &http.Request{ - Method: http.MethodGet, - URL: &url.URL{ - Scheme: "http", - Host: "127.0.0.1:8080", - Path: "/resource", - }, - Proto: "HTTP/1.0", - ProtoMajor: 1, - ProtoMinor: 0, - Header: http.Header{ - "User-Agent": []string{agent}, - }, - ContentLength: n, - } - req.SetBasicAuth(user, "pswrd") - - assert.ElementsMatch( - t, - []attribute.KeyValue{ - attribute.String("http.method", "GET"), - attribute.String("net.peer.name", "127.0.0.1"), - attribute.Int("net.peer.port", 8080), - }, - HTTPClientRequestMetrics(req), - ) -} - -func TestHTTPClientRequestRequired(t *testing.T) { - req := new(http.Request) - var got []attribute.KeyValue - assert.NotPanics(t, func() { got = HTTPClientRequest(req) }) - want := []attribute.KeyValue{ - attribute.String("http.method", "GET"), - attribute.String("http.url", ""), - attribute.String("net.peer.name", ""), - } - assert.Equal(t, want, got) -} - -func TestHTTPServerRequest(t *testing.T) { - got := make(chan *http.Request, 1) - handler := func(w http.ResponseWriter, r *http.Request) { - got <- r - w.WriteHeader(http.StatusOK) - } - - srv := httptest.NewServer(http.HandlerFunc(handler)) - defer srv.Close() - - srvURL, err := url.Parse(srv.URL) - require.NoError(t, err) - srvPort, err := strconv.ParseInt(srvURL.Port(), 10, 32) - require.NoError(t, err) - - resp, err := srv.Client().Get(srv.URL) - require.NoError(t, err) - require.NoError(t, resp.Body.Close()) - - req := <-got - peer, peerPort := splitHostPort(req.RemoteAddr) - - const user = "alice" - req.SetBasicAuth(user, "pswrd") - - const clientIP = "127.0.0.5" - req.Header.Add("X-Forwarded-For", clientIP) - - assert.ElementsMatch(t, - []attribute.KeyValue{ - attribute.String("http.method", "GET"), - attribute.String("http.scheme", "http"), - attribute.String("net.host.name", srvURL.Hostname()), - attribute.Int("net.host.port", int(srvPort)), - attribute.String("net.sock.peer.addr", peer), - attribute.Int("net.sock.peer.port", peerPort), - attribute.String("user_agent.original", "Go-http-client/1.1"), - attribute.String("http.client_ip", clientIP), - attribute.String("net.protocol.version", "1.1"), - attribute.String("http.target", "/"), - }, - HTTPServerRequest("", req)) -} - -func TestHTTPServerRequestMetrics(t *testing.T) { - got := make(chan *http.Request, 1) - handler := func(w http.ResponseWriter, r *http.Request) { - got <- r - w.WriteHeader(http.StatusOK) - } - - srv := httptest.NewServer(http.HandlerFunc(handler)) - defer srv.Close() - - srvURL, err := url.Parse(srv.URL) - require.NoError(t, err) - srvPort, err := strconv.ParseInt(srvURL.Port(), 10, 32) - require.NoError(t, err) - - resp, err := srv.Client().Get(srv.URL) - require.NoError(t, err) - require.NoError(t, resp.Body.Close()) - - req := <-got - - assert.ElementsMatch(t, - []attribute.KeyValue{ - attribute.String("http.method", "GET"), - attribute.String("http.scheme", "http"), - attribute.String("net.host.name", srvURL.Hostname()), - attribute.Int("net.host.port", int(srvPort)), - attribute.String("net.protocol.name", "http"), - attribute.String("net.protocol.version", "1.1"), - }, - HTTPServerRequestMetrics("", req)) -} - -func TestHTTPServerName(t *testing.T) { - req := new(http.Request) - var got []attribute.KeyValue - const ( - host = "test.semconv.server" - port = 8080 - ) - portStr := strconv.Itoa(port) - server := host + ":" + portStr - assert.NotPanics(t, func() { got = HTTPServerRequest(server, req) }) - assert.Contains(t, got, attribute.String("net.host.name", host)) - assert.Contains(t, got, attribute.Int("net.host.port", port)) - - req = &http.Request{Host: "alt.host.name:" + portStr} - // The server parameter does not include a port, ServerRequest should use - // the port in the request Host field. - assert.NotPanics(t, func() { got = HTTPServerRequest(host, req) }) - assert.Contains(t, got, attribute.String("net.host.name", host)) - assert.Contains(t, got, attribute.Int("net.host.port", port)) -} - -func TestHTTPServerRequestFailsGracefully(t *testing.T) { - req := new(http.Request) - var got []attribute.KeyValue - assert.NotPanics(t, func() { got = HTTPServerRequest("", req) }) - want := []attribute.KeyValue{ - attribute.String("http.method", "GET"), - attribute.String("http.scheme", "http"), - attribute.String("net.host.name", ""), - } - assert.ElementsMatch(t, want, got) -} - -func TestHTTPMethod(t *testing.T) { - assert.Equal(t, attribute.String("http.method", "POST"), hc.method("POST")) - assert.Equal(t, attribute.String("http.method", "GET"), hc.method("")) - assert.Equal(t, attribute.String("http.method", "garbage"), hc.method("garbage")) -} - -func TestHTTPScheme(t *testing.T) { - assert.Equal(t, attribute.String("http.scheme", "http"), hc.scheme(false)) - assert.Equal(t, attribute.String("http.scheme", "https"), hc.scheme(true)) -} - -func TestHTTPServerClientIP(t *testing.T) { - tests := []struct { - xForwardedFor string - want string - }{ - {"", ""}, - {"127.0.0.1", "127.0.0.1"}, - {"127.0.0.1,127.0.0.5", "127.0.0.1"}, - } - for _, test := range tests { - got := serverClientIP(test.xForwardedFor) - assert.Equal(t, test.want, got, test.xForwardedFor) - } -} - -func TestRequiredHTTPPort(t *testing.T) { - tests := []struct { - https bool - port int - want int - }{ - {true, 443, -1}, - {true, 80, 80}, - {true, 8081, 8081}, - {false, 443, 443}, - {false, 80, -1}, - {false, 8080, 8080}, - } - for _, test := range tests { - got := requiredHTTPPort(test.https, test.port) - assert.Equal(t, test.want, got, test.https, test.port) - } -} - -func TestFirstHostPort(t *testing.T) { - host, port := "127.0.0.1", 8080 - hostport := "127.0.0.1:8080" - sources := [][]string{ - {hostport}, - {"", hostport}, - {"", "", hostport}, - {"", "", hostport, ""}, - {"", "", hostport, "127.0.0.3:80"}, - } - - for _, src := range sources { - h, p := firstHostPort(src...) - assert.Equal(t, host, h, src) - assert.Equal(t, port, p, src) - } -} - -func TestHTTPClientStatus(t *testing.T) { - tests := []struct { - code int - stat codes.Code - msg bool - }{ - {0, codes.Error, true}, - {http.StatusContinue, codes.Unset, false}, - {http.StatusSwitchingProtocols, codes.Unset, false}, - {http.StatusProcessing, codes.Unset, false}, - {http.StatusEarlyHints, codes.Unset, false}, - {http.StatusOK, codes.Unset, false}, - {http.StatusCreated, codes.Unset, false}, - {http.StatusAccepted, codes.Unset, false}, - {http.StatusNonAuthoritativeInfo, codes.Unset, false}, - {http.StatusNoContent, codes.Unset, false}, - {http.StatusResetContent, codes.Unset, false}, - {http.StatusPartialContent, codes.Unset, false}, - {http.StatusMultiStatus, codes.Unset, false}, - {http.StatusAlreadyReported, codes.Unset, false}, - {http.StatusIMUsed, codes.Unset, false}, - {http.StatusMultipleChoices, codes.Unset, false}, - {http.StatusMovedPermanently, codes.Unset, false}, - {http.StatusFound, codes.Unset, false}, - {http.StatusSeeOther, codes.Unset, false}, - {http.StatusNotModified, codes.Unset, false}, - {http.StatusUseProxy, codes.Unset, false}, - {306, codes.Unset, false}, - {http.StatusTemporaryRedirect, codes.Unset, false}, - {http.StatusPermanentRedirect, codes.Unset, false}, - {http.StatusBadRequest, codes.Error, false}, - {http.StatusUnauthorized, codes.Error, false}, - {http.StatusPaymentRequired, codes.Error, false}, - {http.StatusForbidden, codes.Error, false}, - {http.StatusNotFound, codes.Error, false}, - {http.StatusMethodNotAllowed, codes.Error, false}, - {http.StatusNotAcceptable, codes.Error, false}, - {http.StatusProxyAuthRequired, codes.Error, false}, - {http.StatusRequestTimeout, codes.Error, false}, - {http.StatusConflict, codes.Error, false}, - {http.StatusGone, codes.Error, false}, - {http.StatusLengthRequired, codes.Error, false}, - {http.StatusPreconditionFailed, codes.Error, false}, - {http.StatusRequestEntityTooLarge, codes.Error, false}, - {http.StatusRequestURITooLong, codes.Error, false}, - {http.StatusUnsupportedMediaType, codes.Error, false}, - {http.StatusRequestedRangeNotSatisfiable, codes.Error, false}, - {http.StatusExpectationFailed, codes.Error, false}, - {http.StatusTeapot, codes.Error, false}, - {http.StatusMisdirectedRequest, codes.Error, false}, - {http.StatusUnprocessableEntity, codes.Error, false}, - {http.StatusLocked, codes.Error, false}, - {http.StatusFailedDependency, codes.Error, false}, - {http.StatusTooEarly, codes.Error, false}, - {http.StatusUpgradeRequired, codes.Error, false}, - {http.StatusPreconditionRequired, codes.Error, false}, - {http.StatusTooManyRequests, codes.Error, false}, - {http.StatusRequestHeaderFieldsTooLarge, codes.Error, false}, - {http.StatusUnavailableForLegalReasons, codes.Error, false}, - {499, codes.Error, false}, - {http.StatusInternalServerError, codes.Error, false}, - {http.StatusNotImplemented, codes.Error, false}, - {http.StatusBadGateway, codes.Error, false}, - {http.StatusServiceUnavailable, codes.Error, false}, - {http.StatusGatewayTimeout, codes.Error, false}, - {http.StatusHTTPVersionNotSupported, codes.Error, false}, - {http.StatusVariantAlsoNegotiates, codes.Error, false}, - {http.StatusInsufficientStorage, codes.Error, false}, - {http.StatusLoopDetected, codes.Error, false}, - {http.StatusNotExtended, codes.Error, false}, - {http.StatusNetworkAuthenticationRequired, codes.Error, false}, - {600, codes.Error, true}, - } - - for _, test := range tests { - t.Run(strconv.Itoa(test.code), func(t *testing.T) { - c, msg := HTTPClientStatus(test.code) - assert.Equal(t, test.stat, c) - if test.msg && msg == "" { - t.Errorf("expected non-empty message for %d", test.code) - } else if !test.msg && msg != "" { - t.Errorf("expected empty message for %d, got: %s", test.code, msg) - } - }) - } -} - -func TestHTTPServerStatus(t *testing.T) { - tests := []struct { - code int - stat codes.Code - msg bool - }{ - {0, codes.Error, true}, - {http.StatusContinue, codes.Unset, false}, - {http.StatusSwitchingProtocols, codes.Unset, false}, - {http.StatusProcessing, codes.Unset, false}, - {http.StatusEarlyHints, codes.Unset, false}, - {http.StatusOK, codes.Unset, false}, - {http.StatusCreated, codes.Unset, false}, - {http.StatusAccepted, codes.Unset, false}, - {http.StatusNonAuthoritativeInfo, codes.Unset, false}, - {http.StatusNoContent, codes.Unset, false}, - {http.StatusResetContent, codes.Unset, false}, - {http.StatusPartialContent, codes.Unset, false}, - {http.StatusMultiStatus, codes.Unset, false}, - {http.StatusAlreadyReported, codes.Unset, false}, - {http.StatusIMUsed, codes.Unset, false}, - {http.StatusMultipleChoices, codes.Unset, false}, - {http.StatusMovedPermanently, codes.Unset, false}, - {http.StatusFound, codes.Unset, false}, - {http.StatusSeeOther, codes.Unset, false}, - {http.StatusNotModified, codes.Unset, false}, - {http.StatusUseProxy, codes.Unset, false}, - {306, codes.Unset, false}, - {http.StatusTemporaryRedirect, codes.Unset, false}, - {http.StatusPermanentRedirect, codes.Unset, false}, - {http.StatusBadRequest, codes.Unset, false}, - {http.StatusUnauthorized, codes.Unset, false}, - {http.StatusPaymentRequired, codes.Unset, false}, - {http.StatusForbidden, codes.Unset, false}, - {http.StatusNotFound, codes.Unset, false}, - {http.StatusMethodNotAllowed, codes.Unset, false}, - {http.StatusNotAcceptable, codes.Unset, false}, - {http.StatusProxyAuthRequired, codes.Unset, false}, - {http.StatusRequestTimeout, codes.Unset, false}, - {http.StatusConflict, codes.Unset, false}, - {http.StatusGone, codes.Unset, false}, - {http.StatusLengthRequired, codes.Unset, false}, - {http.StatusPreconditionFailed, codes.Unset, false}, - {http.StatusRequestEntityTooLarge, codes.Unset, false}, - {http.StatusRequestURITooLong, codes.Unset, false}, - {http.StatusUnsupportedMediaType, codes.Unset, false}, - {http.StatusRequestedRangeNotSatisfiable, codes.Unset, false}, - {http.StatusExpectationFailed, codes.Unset, false}, - {http.StatusTeapot, codes.Unset, false}, - {http.StatusMisdirectedRequest, codes.Unset, false}, - {http.StatusUnprocessableEntity, codes.Unset, false}, - {http.StatusLocked, codes.Unset, false}, - {http.StatusFailedDependency, codes.Unset, false}, - {http.StatusTooEarly, codes.Unset, false}, - {http.StatusUpgradeRequired, codes.Unset, false}, - {http.StatusPreconditionRequired, codes.Unset, false}, - {http.StatusTooManyRequests, codes.Unset, false}, - {http.StatusRequestHeaderFieldsTooLarge, codes.Unset, false}, - {http.StatusUnavailableForLegalReasons, codes.Unset, false}, - {499, codes.Unset, false}, - {http.StatusInternalServerError, codes.Error, false}, - {http.StatusNotImplemented, codes.Error, false}, - {http.StatusBadGateway, codes.Error, false}, - {http.StatusServiceUnavailable, codes.Error, false}, - {http.StatusGatewayTimeout, codes.Error, false}, - {http.StatusHTTPVersionNotSupported, codes.Error, false}, - {http.StatusVariantAlsoNegotiates, codes.Error, false}, - {http.StatusInsufficientStorage, codes.Error, false}, - {http.StatusLoopDetected, codes.Error, false}, - {http.StatusNotExtended, codes.Error, false}, - {http.StatusNetworkAuthenticationRequired, codes.Error, false}, - {600, codes.Error, true}, - } - - for _, test := range tests { - c, msg := HTTPServerStatus(test.code) - assert.Equal(t, test.stat, c) - if test.msg && msg == "" { - t.Errorf("expected non-empty message for %d", test.code) - } else if !test.msg && msg != "" { - t.Errorf("expected empty message for %d, got: %s", test.code, msg) - } - } -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/netconv.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/netconv.go deleted file mode 100644 index eda4a8696dd..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/netconv.go +++ /dev/null @@ -1,205 +0,0 @@ -// Code created by gotmpl. DO NOT MODIFY. -// source: internal/shared/semconvutil/netconv.go.tmpl - -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package semconvutil // import "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil" - -import ( - "net" - "strconv" - "strings" - - "go.opentelemetry.io/otel/attribute" - semconv "go.opentelemetry.io/otel/semconv/v1.20.0" -) - -// NetTransport returns a trace attribute describing the transport protocol of the -// passed network. See the net.Dial for information about acceptable network -// values. -func NetTransport(network string) attribute.KeyValue { - return nc.Transport(network) -} - -// netConv are the network semantic convention attributes defined for a version -// of the OpenTelemetry specification. -type netConv struct { - NetHostNameKey attribute.Key - NetHostPortKey attribute.Key - NetPeerNameKey attribute.Key - NetPeerPortKey attribute.Key - NetProtocolName attribute.Key - NetProtocolVersion attribute.Key - NetSockFamilyKey attribute.Key - NetSockPeerAddrKey attribute.Key - NetSockPeerPortKey attribute.Key - NetSockHostAddrKey attribute.Key - NetSockHostPortKey attribute.Key - NetTransportOther attribute.KeyValue - NetTransportTCP attribute.KeyValue - NetTransportUDP attribute.KeyValue - NetTransportInProc attribute.KeyValue -} - -var nc = &netConv{ - NetHostNameKey: semconv.NetHostNameKey, - NetHostPortKey: semconv.NetHostPortKey, - NetPeerNameKey: semconv.NetPeerNameKey, - NetPeerPortKey: semconv.NetPeerPortKey, - NetProtocolName: semconv.NetProtocolNameKey, - NetProtocolVersion: semconv.NetProtocolVersionKey, - NetSockFamilyKey: semconv.NetSockFamilyKey, - NetSockPeerAddrKey: semconv.NetSockPeerAddrKey, - NetSockPeerPortKey: semconv.NetSockPeerPortKey, - NetSockHostAddrKey: semconv.NetSockHostAddrKey, - NetSockHostPortKey: semconv.NetSockHostPortKey, - NetTransportOther: semconv.NetTransportOther, - NetTransportTCP: semconv.NetTransportTCP, - NetTransportUDP: semconv.NetTransportUDP, - NetTransportInProc: semconv.NetTransportInProc, -} - -func (c *netConv) Transport(network string) attribute.KeyValue { - switch network { - case "tcp", "tcp4", "tcp6": - return c.NetTransportTCP - case "udp", "udp4", "udp6": - return c.NetTransportUDP - case "unix", "unixgram", "unixpacket": - return c.NetTransportInProc - default: - // "ip:*", "ip4:*", and "ip6:*" all are considered other. - return c.NetTransportOther - } -} - -// Host returns attributes for a network host address. -func (c *netConv) Host(address string) []attribute.KeyValue { - h, p := splitHostPort(address) - var n int - if h != "" { - n++ - if p > 0 { - n++ - } - } - - if n == 0 { - return nil - } - - attrs := make([]attribute.KeyValue, 0, n) - attrs = append(attrs, c.HostName(h)) - if p > 0 { - attrs = append(attrs, c.HostPort(p)) - } - return attrs -} - -func (c *netConv) HostName(name string) attribute.KeyValue { - return c.NetHostNameKey.String(name) -} - -func (c *netConv) HostPort(port int) attribute.KeyValue { - return c.NetHostPortKey.Int(port) -} - -func family(network, address string) string { - switch network { - case "unix", "unixgram", "unixpacket": - return "unix" - default: - if ip := net.ParseIP(address); ip != nil { - if ip.To4() == nil { - return "inet6" - } - return "inet" - } - } - return "" -} - -// Peer returns attributes for a network peer address. -func (c *netConv) Peer(address string) []attribute.KeyValue { - h, p := splitHostPort(address) - var n int - if h != "" { - n++ - if p > 0 { - n++ - } - } - - if n == 0 { - return nil - } - - attrs := make([]attribute.KeyValue, 0, n) - attrs = append(attrs, c.PeerName(h)) - if p > 0 { - attrs = append(attrs, c.PeerPort(p)) - } - return attrs -} - -func (c *netConv) PeerName(name string) attribute.KeyValue { - return c.NetPeerNameKey.String(name) -} - -func (c *netConv) PeerPort(port int) attribute.KeyValue { - return c.NetPeerPortKey.Int(port) -} - -func (c *netConv) SockPeerAddr(addr string) attribute.KeyValue { - return c.NetSockPeerAddrKey.String(addr) -} - -func (c *netConv) SockPeerPort(port int) attribute.KeyValue { - return c.NetSockPeerPortKey.Int(port) -} - -// splitHostPort splits a network address hostport of the form "host", -// "host%zone", "[host]", "[host%zone], "host:port", "host%zone:port", -// "[host]:port", "[host%zone]:port", or ":port" into host or host%zone and -// port. -// -// An empty host is returned if it is not provided or unparsable. A negative -// port is returned if it is not provided or unparsable. -func splitHostPort(hostport string) (host string, port int) { - port = -1 - - if strings.HasPrefix(hostport, "[") { - addrEnd := strings.LastIndex(hostport, "]") - if addrEnd < 0 { - // Invalid hostport. - return - } - if i := strings.LastIndex(hostport[addrEnd:], ":"); i < 0 { - host = hostport[1:addrEnd] - return - } - } else { - if i := strings.LastIndex(hostport, ":"); i < 0 { - host = hostport - return - } - } - - host, pStr, err := net.SplitHostPort(hostport) - if err != nil { - return - } - - p, err := strconv.ParseUint(pStr, 10, 16) - if err != nil { - return - } - return host, int(p) // nolint: gosec // Bitsize checked to be 16 above. -} - -func netProtocol(proto string) (name string, version string) { - name, version, _ = strings.Cut(proto, "/") - name = strings.ToLower(name) - return name, version -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/netconv_test.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/netconv_test.go deleted file mode 100644 index 18be4b93d1f..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil/netconv_test.go +++ /dev/null @@ -1,200 +0,0 @@ -// Code created by gotmpl. DO NOT MODIFY. -// source: internal/shared/semconvutil/netconv_test.go.tmpl - -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package semconvutil - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "go.opentelemetry.io/otel/attribute" -) - -const ( - addr = "127.0.0.1" - port = 1834 -) - -func TestNetTransport(t *testing.T) { - transports := map[string]attribute.KeyValue{ - "tcp": attribute.String("net.transport", "ip_tcp"), - "tcp4": attribute.String("net.transport", "ip_tcp"), - "tcp6": attribute.String("net.transport", "ip_tcp"), - "udp": attribute.String("net.transport", "ip_udp"), - "udp4": attribute.String("net.transport", "ip_udp"), - "udp6": attribute.String("net.transport", "ip_udp"), - "unix": attribute.String("net.transport", "inproc"), - "unixgram": attribute.String("net.transport", "inproc"), - "unixpacket": attribute.String("net.transport", "inproc"), - "ip:1": attribute.String("net.transport", "other"), - "ip:icmp": attribute.String("net.transport", "other"), - "ip4:proto": attribute.String("net.transport", "other"), - "ip6:proto": attribute.String("net.transport", "other"), - } - - for network, want := range transports { - assert.Equal(t, want, NetTransport(network)) - } -} - -func TestNetHost(t *testing.T) { - testAddrs(t, []addrTest{ - {address: "", expected: nil}, - {address: "192.0.0.1", expected: []attribute.KeyValue{ - nc.HostName("192.0.0.1"), - }}, - {address: "192.0.0.1:9090", expected: []attribute.KeyValue{ - nc.HostName("192.0.0.1"), - nc.HostPort(9090), - }}, - }, nc.Host) -} - -func TestNetHostName(t *testing.T) { - expected := attribute.Key("net.host.name").String(addr) - assert.Equal(t, expected, nc.HostName(addr)) -} - -func TestNetHostPort(t *testing.T) { - expected := attribute.Key("net.host.port").Int(port) - assert.Equal(t, expected, nc.HostPort(port)) -} - -func TestNetPeer(t *testing.T) { - testAddrs(t, []addrTest{ - {address: "", expected: nil}, - {address: "example.com", expected: []attribute.KeyValue{ - nc.PeerName("example.com"), - }}, - {address: "/tmp/file", expected: []attribute.KeyValue{ - nc.PeerName("/tmp/file"), - }}, - {address: "192.0.0.1", expected: []attribute.KeyValue{ - nc.PeerName("192.0.0.1"), - }}, - {address: ":9090", expected: nil}, - {address: "192.0.0.1:9090", expected: []attribute.KeyValue{ - nc.PeerName("192.0.0.1"), - nc.PeerPort(9090), - }}, - }, nc.Peer) -} - -func TestNetPeerName(t *testing.T) { - expected := attribute.Key("net.peer.name").String(addr) - assert.Equal(t, expected, nc.PeerName(addr)) -} - -func TestNetPeerPort(t *testing.T) { - expected := attribute.Key("net.peer.port").Int(port) - assert.Equal(t, expected, nc.PeerPort(port)) -} - -func TestNetSockPeerName(t *testing.T) { - expected := attribute.Key("net.sock.peer.addr").String(addr) - assert.Equal(t, expected, nc.SockPeerAddr(addr)) -} - -func TestNetSockPeerPort(t *testing.T) { - expected := attribute.Key("net.sock.peer.port").Int(port) - assert.Equal(t, expected, nc.SockPeerPort(port)) -} - -func TestNetFamily(t *testing.T) { - tests := []struct { - network string - address string - expect string - }{ - {"", "", ""}, - {"unix", "", "unix"}, - {"unix", "gibberish", "unix"}, - {"unixgram", "", "unix"}, - {"unixgram", "gibberish", "unix"}, - {"unixpacket", "gibberish", "unix"}, - {"tcp", "123.0.2.8", "inet"}, - {"tcp", "gibberish", ""}, - {"", "123.0.2.8", "inet"}, - {"", "gibberish", ""}, - {"tcp", "fe80::1", "inet6"}, - {"", "fe80::1", "inet6"}, - } - - for _, test := range tests { - got := family(test.network, test.address) - assert.Equal(t, test.expect, got, test.network+"/"+test.address) - } -} - -func TestSplitHostPort(t *testing.T) { - tests := []struct { - hostport string - host string - port int - }{ - {"", "", -1}, - {":8080", "", 8080}, - {"127.0.0.1", "127.0.0.1", -1}, - {"www.example.com", "www.example.com", -1}, - {"127.0.0.1%25en0", "127.0.0.1%25en0", -1}, - {"[]", "", -1}, // Ensure this doesn't panic. - {"[fe80::1", "", -1}, - {"[fe80::1]", "fe80::1", -1}, - {"[fe80::1%25en0]", "fe80::1%25en0", -1}, - {"[fe80::1]:8080", "fe80::1", 8080}, - {"[fe80::1]::", "", -1}, // Too many colons. - {"127.0.0.1:", "127.0.0.1", -1}, - {"127.0.0.1:port", "127.0.0.1", -1}, - {"127.0.0.1:8080", "127.0.0.1", 8080}, - {"www.example.com:8080", "www.example.com", 8080}, - {"127.0.0.1%25en0:8080", "127.0.0.1%25en0", 8080}, - } - - for _, test := range tests { - h, p := splitHostPort(test.hostport) - assert.Equal(t, test.host, h, test.hostport) - assert.Equal(t, test.port, p, test.hostport) - } -} - -type addrTest struct { - address string - expected []attribute.KeyValue -} - -func testAddrs(t *testing.T, tests []addrTest, f func(string) []attribute.KeyValue) { - t.Helper() - - for _, test := range tests { - got := f(test.address) - assert.Equal(t, cap(test.expected), cap(got), "slice capacity") - assert.ElementsMatch(t, test.expected, got, test.address) - } -} - -func TestNetProtocol(t *testing.T) { - type testCase struct { - name, version string - } - tests := map[string]testCase{ - "HTTP/1.0": {name: "http", version: "1.0"}, - "HTTP/1.1": {name: "http", version: "1.1"}, - "HTTP/2": {name: "http", version: "2"}, - "HTTP/3": {name: "http", version: "3"}, - "SPDY": {name: "spdy"}, - "SPDY/2": {name: "spdy", version: "2"}, - "QUIC": {name: "quic"}, - "unknown/proto/2": {name: "unknown", version: "proto/2"}, - "other": {name: "other"}, - } - - for proto, want := range tests { - name, version := netProtocol(proto) - assert.Equal(t, want.name, name) - assert.Equal(t, want.version, version) - } -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/macaron.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/macaron.go deleted file mode 100644 index bda8143fe93..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/macaron.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package otelmacaron // import "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron" - -import ( - "fmt" - "net/http" - - "gopkg.in/macaron.v1" - - "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/internal/semconvutil" - "go.opentelemetry.io/otel/propagation" - semconv "go.opentelemetry.io/otel/semconv/v1.20.0" - oteltrace "go.opentelemetry.io/otel/trace" -) - -// ScopeName is the instrumentation scope name. -const ScopeName = "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron" - -// Middleware returns a macaron Handler to trace requests to the server. -func Middleware(service string, opts ...Option) macaron.Handler { - cfg := newConfig(opts) - tracer := cfg.TracerProvider.Tracer( - ScopeName, - oteltrace.WithInstrumentationVersion(Version()), - ) - return func(res http.ResponseWriter, req *http.Request, c *macaron.Context) { - savedCtx := c.Req.Request.Context() - defer func() { - c.Req.Request = c.Req.Request.WithContext(savedCtx) - }() - - ctx := cfg.Propagators.Extract(savedCtx, propagation.HeaderCarrier(c.Req.Header)) - opts := []oteltrace.SpanStartOption{ - oteltrace.WithAttributes(semconvutil.HTTPServerRequest(service, c.Req.Request)...), - oteltrace.WithSpanKind(oteltrace.SpanKindServer), - } - // TODO: span name should be router template not the actual request path, eg /user/:id vs /user/123 - spanName := c.Req.RequestURI - if spanName == "" { - spanName = fmt.Sprintf("HTTP %s route not found", c.Req.Method) - } - ctx, span := tracer.Start(ctx, spanName, opts...) - defer span.End() - - // pass the span through the request context - c.Req.Request = c.Req.Request.WithContext(ctx) - - // serve the request to the next middleware - c.Next() - - status := c.Resp.Status() - span.SetStatus(semconvutil.HTTPServerStatus(status)) - if status > 0 { - span.SetAttributes(semconv.HTTPStatusCode(status)) - } - } -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/macaron_test.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/macaron_test.go deleted file mode 100644 index 19ca93a6d5f..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/macaron_test.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package otelmacaron - -import ( - "context" - "net/http" - "net/http/httptest" - "testing" - - "github.com/stretchr/testify/assert" - "gopkg.in/macaron.v1" - - b3prop "go.opentelemetry.io/contrib/propagators/b3" - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/propagation" - oteltrace "go.opentelemetry.io/otel/trace" - "go.opentelemetry.io/otel/trace/noop" -) - -func TestGetSpanNotInstrumented(t *testing.T) { - m := macaron.Classic() - m.Get("/user/:id", func(ctx *macaron.Context) { - span := oteltrace.SpanFromContext(ctx.Req.Request.Context()) - ok := !span.SpanContext().IsValid() - assert.True(t, ok) - ctx.Resp.WriteHeader(http.StatusOK) - }) - - r := httptest.NewRequest("GET", "/user/123", nil) - w := httptest.NewRecorder() - - m.ServeHTTP(w, r) -} - -func TestPropagationWithGlobalPropagators(t *testing.T) { - tracer := noop.NewTracerProvider().Tracer("test-tracer") - otel.SetTextMapPropagator(propagation.TraceContext{}) - otel.SetTracerProvider(noop.NewTracerProvider()) - - r := httptest.NewRequest("GET", "/user/123", nil) - w := httptest.NewRecorder() - - ctx := context.Background() - sc := oteltrace.NewSpanContext(oteltrace.SpanContextConfig{ - TraceID: oteltrace.TraceID{0x01}, - SpanID: oteltrace.SpanID{0x01}, - }) - ctx = oteltrace.ContextWithRemoteSpanContext(ctx, sc) - ctx, _ = tracer.Start(ctx, "test") - otel.GetTextMapPropagator().Inject(ctx, propagation.HeaderCarrier(r.Header)) - - m := macaron.Classic() - m.Use(Middleware("foobar")) - m.Get("/user/:id", func(ctx *macaron.Context) { - span := oteltrace.SpanFromContext(ctx.Req.Request.Context()) - assert.Equal(t, sc.TraceID(), span.SpanContext().TraceID()) - assert.Equal(t, sc.SpanID(), span.SpanContext().SpanID()) - ctx.Resp.WriteHeader(http.StatusOK) - }) - - m.ServeHTTP(w, r) -} - -func TestPropagationWithCustomPropagators(t *testing.T) { - tp := noop.NewTracerProvider() - otel.SetTracerProvider(tp) - tracer := tp.Tracer("test-tracer") - b3 := b3prop.New() - - r := httptest.NewRequest("GET", "/user/123", nil) - w := httptest.NewRecorder() - - ctx := context.Background() - sc := oteltrace.NewSpanContext(oteltrace.SpanContextConfig{ - TraceID: oteltrace.TraceID{0x01}, - SpanID: oteltrace.SpanID{0x01}, - }) - ctx = oteltrace.ContextWithRemoteSpanContext(ctx, sc) - ctx, _ = tracer.Start(ctx, "test") - b3.Inject(ctx, propagation.HeaderCarrier(r.Header)) - - m := macaron.Classic() - m.Use(Middleware("foobar", WithTracerProvider(tp), WithPropagators(b3))) - m.Get("/user/:id", func(ctx *macaron.Context) { - span := oteltrace.SpanFromContext(ctx.Req.Request.Context()) - assert.Equal(t, sc.TraceID(), span.SpanContext().TraceID()) - assert.Equal(t, sc.SpanID(), span.SpanContext().SpanID()) - ctx.Resp.WriteHeader(http.StatusOK) - }) - - m.ServeHTTP(w, r) -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/doc.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/doc.go deleted file mode 100644 index 164dc13b34f..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -/* -Package test validates the otelmacaron instrumentation with the default SDK. - -This package is in a separate module from the instrumentation it tests to -isolate the dependency of the default SDK and not impose this as a transitive -dependency for users. - -Deprecated: otelmacaron has no Code Owner. -After August 21, 2024, it may no longer be supported and may stop -receiving new releases unless a new Code Owner is found. See -[this issue] if you would like to become the Code Owner of this module. - -[this issue]: https://github.com/open-telemetry/opentelemetry-go-contrib/issues/5552 -*/ -package test // import "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/test" diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/go.mod b/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/go.mod deleted file mode 100644 index 66d9a4406b8..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/go.mod +++ /dev/null @@ -1,33 +0,0 @@ -// Deprecated: otelmacaron has no Code Owner. -module go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/test - -go 1.22 - -require ( - github.com/stretchr/testify v1.9.0 - go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron v0.55.0 - go.opentelemetry.io/otel v1.30.0 - go.opentelemetry.io/otel/sdk v1.30.0 - go.opentelemetry.io/otel/trace v1.30.0 - gopkg.in/macaron.v1 v1.5.0 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-logr/logr v1.4.2 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-macaron/inject v0.0.0-20200308113650-138e5925c53b // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/unknwon/com v1.0.1 // indirect - go.opentelemetry.io/otel/metric v1.30.0 // indirect - golang.org/x/crypto v0.28.0 // indirect - golang.org/x/sys v0.26.0 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) - -replace ( - go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron => ../ - go.opentelemetry.io/contrib/propagators/b3 => ../../../../../propagators/b3 -) diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/go.sum b/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/go.sum deleted file mode 100644 index ed49b21ad2d..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/go.sum +++ /dev/null @@ -1,51 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-macaron/inject v0.0.0-20200308113650-138e5925c53b h1:/aWj44HoEycE4MDi2HZf4t+XI7hKwZRltZf4ih5tB2c= -github.com/go-macaron/inject v0.0.0-20200308113650-138e5925c53b/go.mod h1:VFI2o2q9kYsC4o7VP1HrEVosiZZTd+MVT3YZx4gqvJw= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c h1:7lF+Vz0LqiRidnzC1Oq86fpX1q/iEv2KJdrCtttYjT4= -github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w= -github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= -github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= -github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 h1:WN9BUFbdyOsSH/XohnWpXOlq9NBD5sGAB2FciQMUEe8= -github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs= -github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= -go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= -go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= -go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= -go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= -go.opentelemetry.io/otel/sdk v1.30.0 h1:cHdik6irO49R5IysVhdn8oaiR9m8XluDaJAs4DfOrYE= -go.opentelemetry.io/otel/sdk v1.30.0/go.mod h1:p14X4Ok8S+sygzblytT1nqG98QG2KYKv++HE0LY/mhg= -go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= -go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/macaron.v1 v1.5.0 h1:/dXJaeQagWLjVjCrKH8dgSSU7yG4qTv6rBKpqhYaCyc= -gopkg.in/macaron.v1 v1.5.0/go.mod h1:sAYUd2r8Q+jLnCN4/ZmdAYHzQn67agV5sAqKFQgrRrw= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/macaron_test.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/macaron_test.go deleted file mode 100644 index 825a9f1dc5d..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/macaron_test.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package test - -import ( - "net/http" - "net/http/httptest" - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "gopkg.in/macaron.v1" - - "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron" // nolint:staticcheck // deprecated. - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/codes" - "go.opentelemetry.io/otel/sdk/trace" - "go.opentelemetry.io/otel/sdk/trace/tracetest" - oteltrace "go.opentelemetry.io/otel/trace" -) - -func TestChildSpanFromGlobalTracer(t *testing.T) { - sr := tracetest.NewSpanRecorder() - tp := trace.NewTracerProvider(trace.WithSpanProcessor(sr)) - otel.SetTracerProvider(tp) - - m := macaron.Classic() - m.Use(otelmacaron.Middleware("foobar")) - m.Get("/user/:id", func(ctx *macaron.Context) { - ctx.Resp.WriteHeader(http.StatusOK) - }) - - r := httptest.NewRequest("GET", "/user/123", nil) - w := httptest.NewRecorder() - - m.ServeHTTP(w, r) - - assert.Len(t, sr.Ended(), 1) -} - -func TestChildSpanNames(t *testing.T) { - sr := tracetest.NewSpanRecorder() - tp := trace.NewTracerProvider(trace.WithSpanProcessor(sr)) - - m := macaron.Classic() - m.Use(otelmacaron.Middleware("foobar", otelmacaron.WithTracerProvider(tp))) - m.Get("/user/:id", func(ctx *macaron.Context) { - ctx.Resp.WriteHeader(http.StatusOK) - }) - m.Get("/book/:title", func(ctx *macaron.Context) { - _, err := ctx.Resp.Write(([]byte)("ok")) - if err != nil { - t.Error(err) - } - }) - - r := httptest.NewRequest("GET", "/user/123", nil) - w := httptest.NewRecorder() - m.ServeHTTP(w, r) - - r = httptest.NewRequest("GET", "/book/foo", nil) - w = httptest.NewRecorder() - m.ServeHTTP(w, r) - - spans := sr.Ended() - require.Len(t, spans, 2) - span := spans[0] - assert.Equal(t, "/user/123", span.Name()) // TODO: span name should show router template, eg /user/:id - assert.Equal(t, oteltrace.SpanKindServer, span.SpanKind()) - attrs := span.Attributes() - assert.Contains(t, attrs, attribute.String("net.host.name", "foobar")) - assert.Contains(t, attrs, attribute.Int("http.status_code", http.StatusOK)) - assert.Contains(t, attrs, attribute.String("http.method", "GET")) - - span = spans[1] - assert.Equal(t, "/book/foo", span.Name()) // TODO: span name should show router template, eg /book/:title - assert.Equal(t, oteltrace.SpanKindServer, span.SpanKind()) - attrs = span.Attributes() - assert.Contains(t, attrs, attribute.String("net.host.name", "foobar")) - assert.Contains(t, attrs, attribute.Int("http.status_code", http.StatusOK)) - assert.Contains(t, attrs, attribute.String("http.method", "GET")) -} - -func TestSpanStatus(t *testing.T) { - testCases := []struct { - httpStatusCode int - wantSpanStatus codes.Code - }{ - {http.StatusOK, codes.Unset}, - {http.StatusBadRequest, codes.Unset}, - {http.StatusInternalServerError, codes.Error}, - } - for _, tc := range testCases { - t.Run(strconv.Itoa(tc.httpStatusCode), func(t *testing.T) { - sr := tracetest.NewSpanRecorder() - provider := trace.NewTracerProvider() - provider.RegisterSpanProcessor(sr) - m := macaron.Classic() - m.Use(otelmacaron.Middleware("foobar", otelmacaron.WithTracerProvider(provider))) - m.Get("/", func(ctx *macaron.Context) { - ctx.Resp.WriteHeader(tc.httpStatusCode) - }) - - m.ServeHTTP(httptest.NewRecorder(), httptest.NewRequest("GET", "/", nil)) - - require.Len(t, sr.Ended(), 1, "should emit a span") - assert.Equal(t, tc.wantSpanStatus, sr.Ended()[0].Status().Code, "should only set Error status for HTTP statuses >= 500") - }) - } -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/version.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/version.go deleted file mode 100644 index 55a551c7c4c..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/test/version.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package test // import "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/test" - -// Version is the current release version of the macron instrumentation test module. -func Version() string { - return "0.55.0" - // This string is updated by the pre_release.sh script during release -} - -// SemVersion is the semantic version to be supplied to tracer/meter creation. -// -// Deprecated: Use [Version] instead. -func SemVersion() string { - return Version() -} diff --git a/instrumentation/gopkg.in/macaron.v1/otelmacaron/version.go b/instrumentation/gopkg.in/macaron.v1/otelmacaron/version.go deleted file mode 100644 index 156800b6313..00000000000 --- a/instrumentation/gopkg.in/macaron.v1/otelmacaron/version.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package otelmacaron // import "go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron" - -// Version is the current release version of the macron instrumentation. -func Version() string { - return "0.55.0" - // This string is updated by the pre_release.sh script during release -} - -// SemVersion is the semantic version to be supplied to tracer/meter creation. -// -// Deprecated: Use [Version] instead. -func SemVersion() string { - return Version() -} diff --git a/versions.yaml b/versions.yaml index f0f3ae0dff0..a2721b14fe4 100644 --- a/versions.yaml +++ b/versions.yaml @@ -24,9 +24,6 @@ module-sets: - go.opentelemetry.io/contrib/propagators/autoprop - go.opentelemetry.io/contrib/propagators/opencensus - go.opentelemetry.io/contrib/propagators/opencensus/examples - - go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron - - go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/example - - go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron/test - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/example - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp/test