Skip to content

Commit

Permalink
Upgrade integrations SDK (NR-302384) (#163)
Browse files Browse the repository at this point in the history
* use storer from sdk

* upgrade infra-sdk to a compatible v3 version

* add entry to changelog

* goimports

* go mod tidy

* go upgrade to 1.23.2

* remove old build comment

* add entry to changelog for go 1.22.3
  • Loading branch information
kang-makes authored Oct 8, 2024
1 parent de1eec1 commit f5f3cd5
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 61 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Unreleased section should follow [Release Toolkit](https://github.com/newrelic/r

## Unreleased

### dependency

- Upgrade go to 1.23.2

### enhancements

- Upgrade integrations SDK so the interval is variable and allows intervals up to 5 minutes

## v3.4.10 - 2024-09-18

### ⛓️ Dependencies
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23.1-bookworm
FROM golang:1.23.2-bookworm

ARG GH_VERSION='1.9.2'

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/newrelic/nri-nginx

go 1.23.1
go 1.23.2

require (
github.com/jeremywohl/flatten v1.0.1
github.com/newrelic/infra-integrations-sdk v3.8.2+incompatible
github.com/newrelic/infra-integrations-sdk/v3 v3.9.1
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.9.0
github.com/xeipuuv/gojsonschema v1.2.0
Expand Down
20 changes: 2 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ 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/jeremywohl/flatten v1.0.1 h1:LrsxmB3hfwJuE+ptGOijix1PIfOoKLJ3Uee/mzbgtrs=
github.com/jeremywohl/flatten v1.0.1/go.mod h1:4AmD/VxjWcI5SRB0n6szE2A6s2fsNHDLO0nAlMHgfLQ=
github.com/newrelic/infra-integrations-sdk v3.7.3+incompatible h1:+o/MxTzFsC3BRVKpkw1pXer9Nja2mxWNbV9GfH7iKBc=
github.com/newrelic/infra-integrations-sdk v3.7.3+incompatible/go.mod h1:tMUHRMq6mJS0YyBnbWrTXAnREnQqC1AGO6Lu45u5xAM=
github.com/newrelic/infra-integrations-sdk v3.8.0+incompatible h1:QvwHLsgHyGw4ZULOSnnWQnVPE744K1eda+2XLp2eHtg=
github.com/newrelic/infra-integrations-sdk v3.8.0+incompatible/go.mod h1:tMUHRMq6mJS0YyBnbWrTXAnREnQqC1AGO6Lu45u5xAM=
github.com/newrelic/infra-integrations-sdk v3.8.2+incompatible h1:Ktcm1aPAl7CW3o+FXAIKJ+jygWVXDXaUIWFyf2CXQTk=
github.com/newrelic/infra-integrations-sdk v3.8.2+incompatible/go.mod h1:tMUHRMq6mJS0YyBnbWrTXAnREnQqC1AGO6Lu45u5xAM=
github.com/newrelic/infra-integrations-sdk/v3 v3.9.1 h1:dCtVLsYNHWTQ5aAlAaHroomOUlqxlGTrdi6XTlvBDfI=
github.com/newrelic/infra-integrations-sdk/v3 v3.9.1/go.mod h1:yPeidhcq9Cla0QDquGXH0KqvS2k9xtetFOD7aLA0Z8M=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
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/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
Expand All @@ -25,16 +19,6 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM=
golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8=
golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
golang.org/x/tools v0.11.1 h1:ojD5zOW8+7dOGzdnNgersm8aPfcDjhMp12UfG93NIMc=
golang.org/x/tools v0.11.1/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE=
golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
2 changes: 1 addition & 1 deletion src/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"strings"

"github.com/newrelic/infra-integrations-sdk/data/inventory"
"github.com/newrelic/infra-integrations-sdk/v3/data/inventory"
"github.com/pkg/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion src/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"testing"

"github.com/newrelic/infra-integrations-sdk/data/inventory"
"github.com/newrelic/infra-integrations-sdk/v3/data/inventory"
"github.com/stretchr/testify/require"
)

Expand Down
4 changes: 2 additions & 2 deletions src/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"time"

"github.com/jeremywohl/flatten"
"github.com/newrelic/infra-integrations-sdk/data/metric"
"github.com/newrelic/infra-integrations-sdk/log"
"github.com/newrelic/infra-integrations-sdk/v3/data/metric"
"github.com/newrelic/infra-integrations-sdk/v3/log"
"github.com/pkg/errors"
)

Expand Down
11 changes: 6 additions & 5 deletions src/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ package main
import (
"bufio"
"fmt"
"github.com/newrelic/infra-integrations-sdk/data/attribute"
"github.com/newrelic/infra-integrations-sdk/integration"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/tools/go/ssa/interp/testdata/src/errors"
"io"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"

"github.com/newrelic/infra-integrations-sdk/v3/data/attribute"
"github.com/newrelic/infra-integrations-sdk/v3/integration"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/tools/go/ssa/interp/testdata/src/errors"
)

var testNginxStandardStatus = `Active connections: 291
Expand Down
28 changes: 6 additions & 22 deletions src/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"os"
"runtime"

sdk_args "github.com/newrelic/infra-integrations-sdk/args"
"github.com/newrelic/infra-integrations-sdk/data/attribute"
"github.com/newrelic/infra-integrations-sdk/data/metric"
"github.com/newrelic/infra-integrations-sdk/integration"
"github.com/newrelic/infra-integrations-sdk/log"
"github.com/newrelic/infra-integrations-sdk/persist"
sdk_args "github.com/newrelic/infra-integrations-sdk/v3/args"
"github.com/newrelic/infra-integrations-sdk/v3/data/attribute"
"github.com/newrelic/infra-integrations-sdk/v3/data/metric"
"github.com/newrelic/infra-integrations-sdk/v3/integration"
"github.com/newrelic/infra-integrations-sdk/v3/log"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -52,7 +51,7 @@ var (
)

func main() {
i, err := createIntegration()
i, err := integration.New(integrationName, integrationVersion, integration.Args(&args))
fatalIfErr(err)

if args.ShowVersion {
Expand Down Expand Up @@ -112,21 +111,6 @@ func metricSet(e *integration.Entity, eventType string, remote bool) *metric.Set
)
}

func createIntegration() (*integration.Integration, error) {
cachePath := os.Getenv("NRIA_CACHE_PATH")
if cachePath == "" {
return integration.New(integrationName, integrationVersion, integration.Args(&args))
}

l := log.NewStdErr(args.Verbose)
s, err := persist.NewFileStore(cachePath, l, persist.DefaultTTL)
if err != nil {
return nil, err
}

return integration.New(integrationName, integrationVersion, integration.Args(&args), integration.Storer(s), integration.Logger(l))
}

// parseStatusURL will extract the hostname and the port from the nginx status URL.
func parseStatusURL(statusURL string) (hostname, port string, err error) {
u, err := url.Parse(statusURL)
Expand Down
5 changes: 3 additions & 2 deletions src/nginx_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
"github.com/newrelic/infra-integrations-sdk/integration"
"github.com/stretchr/testify/assert"
"strings"
"testing"

"github.com/newrelic/infra-integrations-sdk/v3/integration"
"github.com/stretchr/testify/assert"
)

func TestEntityLocal(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23.1-bookworm as builder
FROM golang:1.23.2-bookworm as builder
ARG CGO_ENABLED=0
WORKDIR /go/src/github.com/newrelic/nri-nginx
COPY . .
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package helpers

import (
"bytes"
"github.com/newrelic/infra-integrations-sdk/log"
"os/exec"
"strings"

"github.com/newrelic/infra-integrations-sdk/v3/log"
)

// ExecInContainer executes the given command inside the specified container. It returns three values:
Expand Down
11 changes: 6 additions & 5 deletions tests/integration/nginx_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// +build integration
//go:build integration

package integration

import (
"flag"
"fmt"
"github.com/newrelic/infra-integrations-sdk/log"
"github.com/newrelic/nri-nginx/tests/integration/helpers"
"github.com/newrelic/nri-nginx/tests/integration/jsonschema"
"github.com/stretchr/testify/assert"
"os"
"path/filepath"
"regexp"
"strings"
"testing"

"github.com/newrelic/infra-integrations-sdk/v3/log"
"github.com/newrelic/nri-nginx/tests/integration/helpers"
"github.com/newrelic/nri-nginx/tests/integration/jsonschema"
"github.com/stretchr/testify/assert"
)

var (
Expand Down

0 comments on commit f5f3cd5

Please sign in to comment.