Skip to content

Commit

Permalink
NR-171145: remove otel http (#1745)
Browse files Browse the repository at this point in the history
* NR-171145: remove Prometheus auto instrumentation

* NR-171145: update dependencies files

* NR-171145: bump dependencies

* NR-171145: fix tests

* NR-171145: fix licenses file
  • Loading branch information
rogercoll committed Oct 19, 2023
1 parent 4d395a8 commit d515e30
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 1,281 deletions.
46 changes: 7 additions & 39 deletions THIRD_PARTY_NOTICES.md
Expand Up @@ -62,47 +62,47 @@ Distributed under the following license(s):



## [github.com/coreos/go-systemd/v22](https://github.com/coreos/go-systemd)
## [github.com/containerd/typeurl/v2](https://github.com/containerd/typeurl)

Distributed under the following license(s):

* Apache-2.0



## [github.com/docker/docker](https://github.com/docker/docker)
## [github.com/coreos/go-systemd/v22](https://github.com/coreos/go-systemd)

Distributed under the following license(s):

* Apache-2.0



## [github.com/evanphx/json-patch](https://github.com/evanphx/json-patch)
## [github.com/docker/docker](https://github.com/docker/docker)

Distributed under the following license(s):

* BSD-3-Clause
* Apache-2.0



## [github.com/fortytw2/leaktest](https://github.com/fortytw2/leaktest)
## [github.com/evanphx/json-patch](https://github.com/evanphx/json-patch)

Distributed under the following license(s):

* BSD-3-Clause



## [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify)
## [github.com/fortytw2/leaktest](https://github.com/fortytw2/leaktest)

Distributed under the following license(s):

* BSD-3-Clause



## [github.com/gogo/protobuf](https://github.com/gogo/protobuf)
## [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify)

Distributed under the following license(s):

Expand Down Expand Up @@ -214,14 +214,6 @@ Distributed under the following license(s):



## [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang)

Distributed under the following license(s):

* Apache-2.0



## [github.com/prometheus/procfs](https://github.com/prometheus/procfs)

Distributed under the following license(s):
Expand Down Expand Up @@ -262,30 +254,6 @@ Distributed under the following license(s):



## [go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp](https://go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp)

Distributed under the following license(s):

* Apache-2.0



## [go.opentelemetry.io/otel](https://go.opentelemetry.io/otel)

Distributed under the following license(s):

* Apache-2.0



## [go.opentelemetry.io/otel/exporters/metric/prometheus](https://go.opentelemetry.io/otel/exporters/metric/prometheus)

Distributed under the following license(s):

* Apache-2.0



## [go.uber.org/multierr](https://go.uber.org/multierr)

Distributed under the following license(s):
Expand Down
47 changes: 1 addition & 46 deletions cmd/newrelic-infra/newrelic-infra.go
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/newrelic/infrastructure-agent/internal/agent/status"
"github.com/newrelic/infrastructure-agent/internal/feature_flags"
"github.com/newrelic/infrastructure-agent/internal/httpapi"
"github.com/newrelic/infrastructure-agent/internal/instrumentation"
"github.com/newrelic/infrastructure-agent/internal/integrations/v4/files"
"github.com/newrelic/infrastructure-agent/internal/integrations/v4/integration"
"github.com/newrelic/infrastructure-agent/internal/integrations/v4/v3legacy"
Expand Down Expand Up @@ -357,12 +356,6 @@ func initializeAgentAndRun(c *config.Config, logFwCfg config.LogForward) error {
fatal(err, "Can't complete platform specific initialization.")
}

instruments, err := initInstrumentation(agt.GetContext().Context(), c.AgentMetricsEndpoint)
if err != nil {
return fmt.Errorf("cannot initialize prometheus exporter: %v", err)
}
wlog.Instrument(instruments.Measure)

metricsSenderConfig := dm.NewConfig(c.DMIngestURL(), c.Fedramp, c.License, time.Duration(c.DMSubmissionPeriod)*time.Second, c.MaxMetricBatchEntitiesCount, c.MaxMetricBatchEntitiesQueue)
dmSender, err := dm.NewDMSender(metricsSenderConfig, transport, agt.Context.IdContext().AgentIdentity)
if err != nil {
Expand All @@ -374,7 +367,7 @@ func initializeAgentAndRun(c *config.Config, logFwCfg config.LogForward) error {
// queues config entries requests
configEntryQ := make(chan configrequest.Entry, 100)

dmEmitter := dm.NewEmitter(agt.GetContext(), dmSender, registerClient, instruments.Measure, ffManager)
dmEmitter := dm.NewEmitter(agt.GetContext(), dmSender, registerClient, ffManager)

// track stoppable integrations
tracker := track.NewTracker(dmEmitter)
Expand Down Expand Up @@ -520,44 +513,6 @@ func initializeAgentAndRun(c *config.Config, logFwCfg config.LogForward) error {
return agt.Run()
}

// initInstrumentation will spawn a server and expose agent metrics through prometheus exporter.
// By default is disabled and it only will be enabled if host:port are provided.
// Using instrumentation.SetupPrometheusIntegrationConfig it will create prometheus
// integration configuration (and delete it on agent shutdown process).
func initInstrumentation(ctx context2.Context, agentMetricsEndpoint string) (instrumentation.Instrumenter, error) {
if agentMetricsEndpoint == "" {
return instrumentation.NewNoop(), nil
}

instruments, err := instrumentation.New()
if err != nil {
return nil, err
}

aslog.WithField("addr", agentMetricsEndpoint).Info("Starting Opentelemetry server")
srv := &http.Server{
Handler: instruments.GetHandler(),
Addr: agentMetricsEndpoint,
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}

go srv.ListenAndServe()
go func() {
<-ctx.Done()
aslog.Debug("Stopping Opentelemetry server")
srv.Close()
}()

// Setup prometheus integration
err = instrumentation.SetupPrometheusIntegrationConfig(ctx, agentMetricsEndpoint)
if err != nil {
return nil, err
}

return instruments, nil
}

// newInstancesLookup creates an instance lookup that:
// - looks in the v3 legacy definitions repository for defined commands
// - looks in the definition folders (and bin/ subfolders) for executable names
Expand Down
96 changes: 50 additions & 46 deletions go.mod
Expand Up @@ -3,100 +3,104 @@ module github.com/newrelic/infrastructure-agent
go 1.20

require (
github.com/Microsoft/go-winio v0.5.2
github.com/Microsoft/go-winio v0.6.1
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6
github.com/antihax/optional v1.0.0
github.com/aws/aws-sdk-go v1.44.69
github.com/beevik/ntp v0.3.0
github.com/containerd/containerd v1.5.18
github.com/coreos/go-systemd/v22 v22.3.2
github.com/containerd/containerd v1.7.7
github.com/containerd/typeurl/v2 v2.1.1
github.com/coreos/go-systemd/v22 v22.5.0
github.com/docker/docker v24.0.1+incompatible
github.com/evanphx/json-patch v4.9.0+incompatible
github.com/fortytw2/leaktest v1.3.1-0.20190606143808-d73c753520d9
github.com/fsnotify/fsnotify v1.4.9
github.com/gogo/protobuf v1.3.2
github.com/fsnotify/fsnotify v1.6.0
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/julienschmidt/httprouter v1.3.0
github.com/kardianos/service v1.2.1
github.com/kelseyhightower/envconfig v1.4.0
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b
github.com/newrelic/go-agent/v3 v3.20.4
github.com/newrelic/go-agent/v3 v3.26.0
github.com/newrelic/infra-identity-client-go v1.0.2
github.com/newrelic/newrelic-telemetry-sdk-go v0.8.1
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.2
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
github.com/opencontainers/runtime-spec v1.1.0-rc.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.2
github.com/prometheus/procfs v0.7.3
github.com/prometheus/procfs v0.8.0
github.com/shirou/gopsutil/v3 v3.21.11
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/tevino/abool v1.2.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.13.0
go.opentelemetry.io/otel v0.13.0
go.opentelemetry.io/otel/exporters/metric/prometheus v0.13.0
go.uber.org/multierr v1.8.0
golang.org/x/net v0.8.0
golang.org/x/sys v0.6.0
golang.org/x/net v0.13.0
golang.org/x/sys v0.10.0
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f
gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.1-0.20181123051433-bcbf6e613274+incompatible
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/DataDog/sketches-go v0.0.1 // indirect
github.com/Microsoft/hcsshim v0.9.8 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect
github.com/Microsoft/hcsshim v0.11.1 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/containerd/continuity v0.4.2 // indirect
github.com/containerd/fifo v1.1.0 // indirect
github.com/containerd/ttrpc v1.2.1 // indirect
github.com/containerd/typeurl v1.0.2 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/ttrpc v1.2.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/godbus/dbus/v5 v5.0.6 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.11.13 // indirect
github.com/klauspost/compress v1.16.3 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/sys/mountinfo v0.5.0 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/signal v0.7.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/opencontainers/runc v1.1.6 // indirect
github.com/opencontainers/selinux v1.11.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/tklauser/go-sysconf v0.3.9 // indirect
github.com/tklauser/numcpus v0.3.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.49.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opencensus.io v0.22.4 // indirect
go.opentelemetry.io/otel/sdk v0.13.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/text v0.8.0 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 // indirect
google.golang.org/grpc v1.49.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
)

replace (
Expand Down

0 comments on commit d515e30

Please sign in to comment.