diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6271660..8cf3909 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -22,12 +22,3 @@ updates: - "rustatian" assignees: - "rustatian" - - - package-ecosystem: "docker" - directory: "/" - schedule: - interval: daily - reviewers: - - "rustatian" - assignees: - - "rustatian" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..c346785 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,24 @@ +# Reason for This PR + +`[Author TODO: add issue # or explain reasoning.]` + +## Description of Changes + +`[Author TODO: add description of changes.]` + +## License Acceptance + +By submitting this pull request, I confirm that my contribution is made under +the terms of the MIT license. + +## PR Checklist + +`[Author TODO: Meet these criteria.]` +`[Reviewer TODO: Verify that these criteria are met. Request changes if not]` + +- [ ] All commits in this PR are signed (`git commit -s`). +- [ ] The reason for this PR is clearly provided (issue no. or explanation). +- [ ] The description of changes is clear and encompassing. +- [ ] Any required documentation changes (code and docs) are included in this PR. +- [ ] Any user-facing changes are mentioned in `CHANGELOG.md`. +- [ ] All added/changed functionality is tested. diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 8aa5d4f..0cf1a2c 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -10,9 +10,14 @@ jobs: - name: Check out code uses: actions/checkout@v3 + - name: Set up Go 1.18 + uses: actions/setup-go@v3 # action page: + with: + go-version: 1.18 + - name: Run linter uses: golangci/golangci-lint-action@v3.1.0 # Action page: with: - version: v1.43 # without patch version + version: v1.45.1 # without patch version only-new-issues: false # show only new issues if it's a pull request args: --timeout=10m --build-tags=race diff --git a/.golangci.yml b/.golangci.yml index cde7339..888f347 100755 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,7 @@ # Documentation: run: + go: '1.17' timeout: 1m skip-dirs: - .github diff --git a/go.mod b/go.mod index 28068bb..5b62e1e 100644 --- a/go.mod +++ b/go.mod @@ -5,4 +5,11 @@ go 1.18 require ( github.com/roadrunner-server/api/v2 v2.14.0 github.com/roadrunner-server/errors v1.1.2 + github.com/roadrunner-server/sdk/v2 v2.13.3 + go.opentelemetry.io/otel/trace v1.6.3 +) + +require ( + github.com/roadrunner-server/tcplisten v1.1.2 // indirect + go.opentelemetry.io/otel v1.6.3 // indirect ) diff --git a/go.sum b/go.sum index 65541df..a78eb42 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,28 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +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/roadrunner-server/api/v2 v2.14.0 h1:U7CrMXv5h8qlO9vvqdvPDK0g+zMLwcERUAPcoLy6tYs= github.com/roadrunner-server/api/v2 v2.14.0/go.mod h1:COjb3T7DYHydaKIfino/N8gVa8op1jGAXFF+qKHMnk0= github.com/roadrunner-server/errors v1.1.2 h1:+LPw9Akgg+8LAGM4wASMWLAoBIbyP+mhNfR+FBS2Slw= github.com/roadrunner-server/errors v1.1.2/go.mod h1:jVSh32nFtRMzKItYUM9W2CTLLpXAM8HseL2lUENPYtU= +github.com/roadrunner-server/sdk/v2 v2.13.3 h1:3SjHlZK9fgF5XbBPoAxNZK38QrutTZhD5nviHjDdgV4= +github.com/roadrunner-server/sdk/v2 v2.13.3/go.mod h1:H5kq9qkpb07g+ndmwqscxg4E0+y/B07GTIfCSYH44Pk= +github.com/roadrunner-server/tcplisten v1.1.2 h1:GBjKlSEbA67UB2y83rFWsQKqMQGyalhTN9Q9HCIMBC0= +github.com/roadrunner-server/tcplisten v1.1.2/go.mod h1:wN2/X46Vo60sC9L5Bf/eC8kL+X3//7KIFmANEXZaLsg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.opentelemetry.io/otel v1.6.3 h1:FLOfo8f9JzFVFVyU+MSRJc2HdEAXQgm7pIv2uFKRSZE= +go.opentelemetry.io/otel v1.6.3/go.mod h1:7BgNga5fNlF/iZjG06hM3yofffp0ofKCDwSXx1GC4dI= +go.opentelemetry.io/otel/trace v1.6.3 h1:IqN4L+5b0mPNjdXIiZ90Ni4Bl5BRkDQywePLWemd9bc= +go.opentelemetry.io/otel/trace v1.6.3/go.mod h1:GNJQusJlUgZl9/TQBPKU/Y/ty+0iVB5fjhKeJGZPGFs= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/plugin.go b/plugin.go index 093e9b6..50ab0f1 100644 --- a/plugin.go +++ b/plugin.go @@ -7,6 +7,8 @@ import ( "github.com/roadrunner-server/api/v2/plugins/config" "github.com/roadrunner-server/errors" + "github.com/roadrunner-server/sdk/v2/utils" + "go.opentelemetry.io/otel/trace" ) // PluginName contains default service name. @@ -46,6 +48,13 @@ func (s *Plugin) Init(cfg config.Configurer) error { func (s *Plugin) Middleware(next http.Handler) http.Handler { // Define the http.HandlerFunc return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if val, ok := r.Context().Value(utils.OtelTracerNameKey).(string); ok { + tp := trace.SpanFromContext(r.Context()).TracerProvider() + ctx, span := tp.Tracer(val).Start(r.Context(), PluginName) + defer span.End() + r = r.WithContext(ctx) + } + if s.cfg.Request != nil { for k, v := range s.cfg.Request { r.Header.Add(k, v)