Skip to content

Commit

Permalink
feat!: [SDK] Remove old metrics collection and REST /metrics endpoint (
Browse files Browse the repository at this point in the history
…#1287)

* feat!: [SDK] Remove old metrics collection and REST /metrics endpoint

BREAKING CHANGE: /metrics endpoint no longer available for any service

Closes: #1281
Signed-off-by: Valina Li <valina.li@intel.com>
  • Loading branch information
vli11 authored Feb 6, 2023
1 parent d782540 commit 34fb173
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 438 deletions.
3 changes: 0 additions & 3 deletions app-service-template/Attribution.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
The following open source projects are referenced by app-service-configurable:

bertimus9/systemstat (MIT) https://bitbucket.org/bertimus9/systemstat
https://bitbucket.org/bertimus9/systemstat/src/master/LICENSE

armon/go-metrics (MIT) https://github.com/armon/go-metrics
https://github.com/armon/go-metrics/blob/master/LICENSE

Expand Down
1 change: 0 additions & 1 deletion app-service-template/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ require (
)

require (
bitbucket.org/bertimus9/systemstat v0.5.0 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/armon/go-metrics v0.3.10 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
Expand Down
2 changes: 0 additions & 2 deletions app-service-template/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
bitbucket.org/bertimus9/systemstat v0.5.0 h1:n0aLnh2Jo4nBUBym9cE5PJDG8GT6g+4VuS2Ya2jYYpA=
bitbucket.org/bertimus9/systemstat v0.5.0/go.mod h1:EkUWPp8lKFPMXP8vnbpT5JDI0W/sTiLZAvN8ONWErHY=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE=
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/edgexfoundry/app-functions-sdk-go/v3
go 1.18

require (
bitbucket.org/bertimus9/systemstat v0.5.0
github.com/diegoholiveira/jsonlogic/v3 v3.2.6
github.com/eclipse/paho.mqtt.golang v1.4.2
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.11
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
bitbucket.org/bertimus9/systemstat v0.5.0 h1:n0aLnh2Jo4nBUBym9cE5PJDG8GT6g+4VuS2Ya2jYYpA=
bitbucket.org/bertimus9/systemstat v0.5.0/go.mod h1:EkUWPp8lKFPMXP8vnbpT5JDI0W/sTiLZAvN8ONWErHY=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE=
Expand Down
2 changes: 0 additions & 2 deletions internal/app/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ type contextGroup struct {
func (svc *Service) AddRoute(route string, handler func(nethttp.ResponseWriter, *nethttp.Request), methods ...string) error {
if route == commonConstants.ApiPingRoute ||
route == commonConstants.ApiConfigRoute ||
route == commonConstants.ApiMetricsRoute ||
route == commonConstants.ApiVersionRoute ||
route == internal.ApiTriggerRoute {
return errors.New("route is reserved")
Expand Down Expand Up @@ -507,7 +506,6 @@ func (svc *Service) Initialize() error {
[]bootstrapInterfaces.BootstrapHandler{
bootstrapHandlers.MessagingBootstrapHandler,
bootstrapHandlers.NewClientsBootstrap().BootstrapHandler,
handlers.NewTelemetry().BootstrapHandler,
handlers.NewVersionValidator(svc.commandLine.skipVersionCheck, internal.SDKVersion).BootstrapHandler,
bootstrapHandlers.NewServiceMetrics(svc.serviceKey).BootstrapHandler,
},
Expand Down
51 changes: 0 additions & 51 deletions internal/bootstrap/handlers/telemetry.go

This file was deleted.

19 changes: 0 additions & 19 deletions internal/controller/rest/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/edgexfoundry/app-functions-sdk-go/v3/internal"
"github.com/edgexfoundry/app-functions-sdk-go/v3/internal/bootstrap/container"
sdkCommon "github.com/edgexfoundry/app-functions-sdk-go/v3/internal/common"
"github.com/edgexfoundry/app-functions-sdk-go/v3/internal/telemetry"
"github.com/edgexfoundry/app-functions-sdk-go/v3/pkg/interfaces"

bootstrapInterfaces "github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/interfaces"
Expand Down Expand Up @@ -102,24 +101,6 @@ func (c *Controller) Config(writer http.ResponseWriter, request *http.Request) {
c.sendResponse(writer, request, common.ApiVersionRoute, response, http.StatusOK)
}

// Metrics handles the request to the /metrics endpoint, memory and cpu utilization stats
// It returns a response as specified by the V2 API swagger in openapi/v2
func (c *Controller) Metrics(writer http.ResponseWriter, request *http.Request) {
t := telemetry.NewSystemUsage()
metrics := commonDtos.Metrics{
MemAlloc: t.Memory.Alloc,
MemFrees: t.Memory.Frees,
MemLiveObjects: t.Memory.LiveObjects,
MemMallocs: t.Memory.Mallocs,
MemSys: t.Memory.Sys,
MemTotalAlloc: t.Memory.TotalAlloc,
CpuBusyAvg: uint8(t.CpuBusyAvg),
}

response := commonDtos.NewMetricsResponse(metrics, c.serviceName)
c.sendResponse(writer, request, common.ApiMetricsRoute, response, http.StatusOK)
}

// AddSecret handles the request to add App Service exclusive secret to the Secret Store
// It returns a response as specified by the V2 API swagger in openapi/v2
func (c *Controller) AddSecret(writer http.ResponseWriter, request *http.Request) {
Expand Down
35 changes: 0 additions & 35 deletions internal/controller/rest/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"errors"
"io"
"math"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -107,40 +106,6 @@ func TestVersionRequest(t *testing.T) {
assert.Equal(t, serviceName, actual.ServiceName)
}

func TestMetricsRequest(t *testing.T) {
serviceName := uuid.NewString()

target := NewController(nil, dic, serviceName)

recorder := doRequest(t, http.MethodGet, common.ApiMetricsRoute, target.Metrics, nil)

actual := commonDtos.MetricsResponse{
Metrics: commonDtos.Metrics{
MemAlloc: math.MaxUint64,
MemFrees: math.MaxUint64,
MemLiveObjects: math.MaxUint64,
MemMallocs: math.MaxUint64,
MemSys: math.MaxUint64,
MemTotalAlloc: math.MaxUint64,
CpuBusyAvg: 0,
},
}
err := json.Unmarshal(recorder.Body.Bytes(), &actual)
require.NoError(t, err)

assert.Equal(t, common.ApiVersion, actual.ApiVersion)
assert.Equal(t, serviceName, actual.ServiceName)

// Since when -race flag is use some values may come back as 0 we need to use the max value to detect change
assert.NotEqual(t, uint64(math.MaxUint64), actual.Metrics.MemAlloc)
assert.NotEqual(t, uint64(math.MaxUint64), actual.Metrics.MemFrees)
assert.NotEqual(t, uint64(math.MaxUint64), actual.Metrics.MemLiveObjects)
assert.NotEqual(t, uint64(math.MaxUint64), actual.Metrics.MemMallocs)
assert.NotEqual(t, uint64(math.MaxUint64), actual.Metrics.MemSys)
assert.NotEqual(t, uint64(math.MaxUint64), actual.Metrics.MemTotalAlloc)
assert.NotEqual(t, 0, actual.Metrics.CpuBusyAvg)
}

func TestConfigRequest(t *testing.T) {
serviceName := uuid.NewString()

Expand Down
54 changes: 0 additions & 54 deletions internal/telemetry/linux_cpu.go

This file was deleted.

92 changes: 0 additions & 92 deletions internal/telemetry/telemetry.go

This file was deleted.

40 changes: 0 additions & 40 deletions internal/telemetry/unimplemented_cpu.go

This file was deleted.

Loading

0 comments on commit 34fb173

Please sign in to comment.