Skip to content

Commit

Permalink
feat!: [Core Contracts] Remove old common Metrics DTO and route constant
Browse files Browse the repository at this point in the history
BREAKING CHANGE: /metrics endpoint no longer available for any service

Closes: #787
Signed-off-by: Valina Li <[email protected]>
  • Loading branch information
vli11 committed Feb 2, 2023
1 parent a1a1c93 commit 3eccfbd
Show file tree
Hide file tree
Showing 16 changed files with 6 additions and 225 deletions.
9 changes: 0 additions & 9 deletions clients/http/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ func (cc *commonClient) Configuration(ctx context.Context) (dtoCommon.ConfigResp
return cr, nil
}

func (cc *commonClient) Metrics(ctx context.Context) (dtoCommon.MetricsResponse, errors.EdgeX) {
mr := dtoCommon.MetricsResponse{}
err := utils.GetRequest(ctx, &mr, cc.baseUrl, common.ApiMetricsRoute, nil)
if err != nil {
return mr, errors.NewCommonEdgeXWrapper(err)
}
return mr, nil
}

func (cc *commonClient) Ping(ctx context.Context) (dtoCommon.PingResponse, errors.EdgeX) {
pr := dtoCommon.PingResponse{}
err := utils.GetRequest(ctx, &pr, cc.baseUrl, common.ApiPingRoute, nil)
Expand Down
14 changes: 2 additions & 12 deletions clients/http/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ package http
import (
"context"
"encoding/json"
"github.com/stretchr/testify/require"
"net/http"
"net/http/httptest"
"testing"

"github.com/stretchr/testify/require"

"github.com/edgexfoundry/go-mod-core-contracts/v3/common"
dtoCommon "github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/common"
)
Expand All @@ -32,17 +33,6 @@ func TestGetConfig(t *testing.T) {
require.Equal(t, expected, response)
}

func TestGetMetrics(t *testing.T) {
expected := dtoCommon.MetricsResponse{}
ts := newTestServer(http.MethodGet, common.ApiMetricsRoute, dtoCommon.MetricsResponse{})
defer ts.Close()

gc := NewCommonClient(ts.URL)
response, err := gc.Metrics(context.Background())
require.NoError(t, err)
require.Equal(t, expected, response)
}

func TestPing(t *testing.T) {
expected := dtoCommon.PingResponse{}
ts := newTestServer(http.MethodGet, common.ApiPingRoute, dtoCommon.PingResponse{})
Expand Down
9 changes: 0 additions & 9 deletions clients/http/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,3 @@ func (g *generalClient) FetchConfiguration(ctx context.Context) (res dtoCommon.C

return res, nil
}

func (g *generalClient) FetchMetrics(ctx context.Context) (res dtoCommon.MetricsResponse, err errors.EdgeX) {
err = utils.GetRequest(ctx, &res, g.baseUrl, common.ApiMetricsRoute, nil)
if err != nil {
return res, errors.NewCommonEdgeXWrapper(err)
}

return res, nil
}
10 changes: 0 additions & 10 deletions clients/http/general_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,3 @@ func Test_generalClient_FetchConfiguration(t *testing.T) {
require.NoError(t, err)
require.IsType(t, dtoCommon.ConfigResponse{}, res)
}

func Test_generalClient_FetchMetrics(t *testing.T) {
ts := newTestServer(http.MethodGet, common.ApiMetricsRoute, dtoCommon.MetricsResponse{})
defer ts.Close()

client := NewGeneralClient(ts.URL)
res, err := client.FetchMetrics(context.Background())
require.NoError(t, err)
require.IsType(t, dtoCommon.MetricsResponse{}, res)
}
11 changes: 0 additions & 11 deletions clients/http/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ func (smc *SystemManagementClient) GetHealth(ctx context.Context, services []str
return
}

func (smc *SystemManagementClient) GetMetrics(ctx context.Context, services []string) (res []dtoCommon.BaseWithMetricsResponse, err errors.EdgeX) {
requestParams := url.Values{}
requestParams.Set(common.Services, strings.Join(services, common.CommaSeparator))
err = utils.GetRequest(ctx, &res, smc.baseUrl, common.ApiMultiMetricsRoute, requestParams)
if err != nil {
return res, errors.NewCommonEdgeXWrapper(err)
}

return
}

func (smc *SystemManagementClient) GetConfig(ctx context.Context, services []string) (res []dtoCommon.BaseWithConfigResponse, err errors.EdgeX) {
requestParams := url.Values{}
requestParams.Set(common.Services, strings.Join(services, common.CommaSeparator))
Expand Down
10 changes: 0 additions & 10 deletions clients/http/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ func TestSystemManagementClient_GetHealth(t *testing.T) {
require.IsType(t, []dtoCommon.BaseWithServiceNameResponse{}, res)
}

func TestSystemManagementClient_GetMetrics(t *testing.T) {
ts := newTestServer(http.MethodGet, common.ApiMultiMetricsRoute, []dtoCommon.BaseWithMetricsResponse{})
defer ts.Close()

client := NewSystemManagementClient(ts.URL)
res, err := client.GetMetrics(context.Background(), []string{"core-data"})
require.NoError(t, err)
require.IsType(t, []dtoCommon.BaseWithMetricsResponse{}, res)
}

func TestSystemManagementClient_GetConfig(t *testing.T) {
ts := newTestServer(http.MethodGet, common.ApiMultiConfigRoute, []dtoCommon.BaseWithConfigResponse{})
defer ts.Close()
Expand Down
2 changes: 0 additions & 2 deletions clients/interfaces/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
type CommonClient interface {
// Configuration obtains configuration information from the target service.
Configuration(ctx context.Context) (common.ConfigResponse, errors.EdgeX)
// Metrics obtains metrics information from the target service.
Metrics(ctx context.Context) (common.MetricsResponse, errors.EdgeX)
// Ping tests whether the service is working
Ping(ctx context.Context) (common.PingResponse, errors.EdgeX)
// Version obtains version information from the target service.
Expand Down
2 changes: 0 additions & 2 deletions clients/interfaces/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ import (
type GeneralClient interface {
// FetchConfiguration obtains configuration information from the target service.
FetchConfiguration(ctx context.Context) (common.ConfigResponse, errors.EdgeX)
// FetchMetrics obtains metrics information from the target service.
FetchMetrics(ctx context.Context) (common.MetricsResponse, errors.EdgeX)
}
23 changes: 0 additions & 23 deletions clients/interfaces/mocks/CommonClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions clients/interfaces/mocks/GeneralClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions clients/interfaces/mocks/SystemManagementClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions clients/interfaces/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
type SystemManagementClient interface {
// GetHealth obtain health information of services via registry by their name
GetHealth(ctx context.Context, services []string) ([]common.BaseWithServiceNameResponse, errors.EdgeX)
// GetMetrics obtain metrics information from services by their name
GetMetrics(ctx context.Context, services []string) ([]common.BaseWithMetricsResponse, errors.EdgeX)
// GetConfig obtain configuration from services by their name
GetConfig(ctx context.Context, services []string) ([]common.BaseWithConfigResponse, errors.EdgeX)
// DoOperation issue a start, stop, restart action to the targeted services
Expand Down
10 changes: 4 additions & 6 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ const (
ApiTransmissionByNotificationIdRoute = ApiTransmissionRoute + "/" + Notification + "/" + Id + "/{" + Id + "}"

ApiConfigRoute = ApiBase + "/config"
ApiMetricsRoute = ApiBase + "/metrics"
ApiPingRoute = ApiBase + "/ping"
ApiVersionRoute = ApiBase + "/version"
ApiSecretRoute = ApiBase + "/secret"
Expand All @@ -125,11 +124,10 @@ const (
ApiIntervalActionByNameRoute = ApiIntervalActionRoute + "/" + Name + "/{" + Name + "}"
ApiIntervalActionByTargetRoute = ApiIntervalActionRoute + "/" + Target + "/{" + Target + "}"

ApiSystemRoute = ApiBase + "/system"
ApiOperationRoute = ApiSystemRoute + "/operation"
ApiHealthRoute = ApiSystemRoute + "/health"
ApiMultiMetricsRoute = ApiSystemRoute + "/metrics"
ApiMultiConfigRoute = ApiSystemRoute + "/config"
ApiSystemRoute = ApiBase + "/system"
ApiOperationRoute = ApiSystemRoute + "/operation"
ApiHealthRoute = ApiSystemRoute + "/health"
ApiMultiConfigRoute = ApiSystemRoute + "/config"
)

// Constants related to defined url path names and parameters in the v2 service APIs
Expand Down
9 changes: 0 additions & 9 deletions dtos/common/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ type BaseWithServiceNameResponse struct {
ServiceName string `json:"serviceName"`
}

// BaseWithMetricsResponse defines the base content for response DTOs (data transfer objects).
// This object and its properties correspond to the BaseWithMetricsResponse object in the APIv2 specification:
// https://app.swaggerhub.com/apis-docs/EdgeXFoundry1/system-agent/2.1.0#/BaseWithMetricsResponse
type BaseWithMetricsResponse struct {
BaseResponse `json:",inline"`
ServiceName string `json:"serviceName"`
Metrics interface{} `json:"metrics"`
}

// BaseWithConfigResponse defines the base content for response DTOs (data transfer objects).
// This object and its properties correspond to the BaseWithConfigResponse object in the APIv2 specification:
// https://app.swaggerhub.com/apis-docs/EdgeXFoundry1/system-agent/2.1.0#/BaseWithConfigResponse
Expand Down
35 changes: 0 additions & 35 deletions dtos/common/metrics.go

This file was deleted.

37 changes: 0 additions & 37 deletions dtos/common/metrics_test.go

This file was deleted.

0 comments on commit 3eccfbd

Please sign in to comment.