Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add pipeline IDs as tags to the metrics collected for each pipeline #1102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app-service-template/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/diegoholiveira/jsonlogic v1.0.1-0.20200220175622-ab7989be08b9 // indirect
github.com/eclipse/paho.mqtt.golang v1.3.5 // indirect
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.18 // indirect
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.19 // indirect
github.com/edgexfoundry/go-mod-configuration/v2 v2.2.0-dev.3 // indirect
github.com/edgexfoundry/go-mod-messaging/v2 v2.2.0-dev.12 // indirect
github.com/edgexfoundry/go-mod-registry/v2 v2.2.0-dev.3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions app-service-template/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/diegoholiveira/jsonlogic v1.0.1-0.20200220175622-ab7989be08b9 h1:NAHC
github.com/diegoholiveira/jsonlogic v1.0.1-0.20200220175622-ab7989be08b9/go.mod h1:9STzWAIpeXT1gYFvw0JM+BkyMmPKYv/ztBNgXX4hAOw=
github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y=
github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.18 h1:6QR9vgrk9cunfWPe2sYMrWBIgSgcCSagQ9IE3ZropLE=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.18/go.mod h1:6Q+rUmzAizdpU3sqnzMzSHmX7Z69qN69xxl0up/mQQA=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.19 h1:WdrAEuZIvgyHZhhHpLhlTaamcpj5Vi9W/ApJKGc+8ak=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.19/go.mod h1:6Q+rUmzAizdpU3sqnzMzSHmX7Z69qN69xxl0up/mQQA=
github.com/edgexfoundry/go-mod-configuration/v2 v2.2.0-dev.3 h1:dTTExUFHza9eJmTABr8G4KOE8JKBMzZCVC3wARiwIg4=
github.com/edgexfoundry/go-mod-configuration/v2 v2.2.0-dev.3/go.mod h1:YP17JhMnXTitowXE13QJwFaKo0oc03iyoKLjWAYl4FE=
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.2.0-dev.26 h1:YebVI3gAJwFTMXKzB2erUonBC8eNrr+qLUGdtXFMjKs=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
bitbucket.org/bertimus9/systemstat v0.0.0-20180207000608-0eeff89b0690
github.com/diegoholiveira/jsonlogic v1.0.1-0.20200220175622-ab7989be08b9
github.com/eclipse/paho.mqtt.golang v1.3.5
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.18
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.19
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.2.0-dev.26
github.com/edgexfoundry/go-mod-messaging/v2 v2.2.0-dev.12
github.com/edgexfoundry/go-mod-registry/v2 v2.2.0-dev.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ github.com/diegoholiveira/jsonlogic v1.0.1-0.20200220175622-ab7989be08b9 h1:NAHC
github.com/diegoholiveira/jsonlogic v1.0.1-0.20200220175622-ab7989be08b9/go.mod h1:9STzWAIpeXT1gYFvw0JM+BkyMmPKYv/ztBNgXX4hAOw=
github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y=
github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.18 h1:6QR9vgrk9cunfWPe2sYMrWBIgSgcCSagQ9IE3ZropLE=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.18/go.mod h1:6Q+rUmzAizdpU3sqnzMzSHmX7Z69qN69xxl0up/mQQA=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.19 h1:WdrAEuZIvgyHZhhHpLhlTaamcpj5Vi9W/ApJKGc+8ak=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0-dev.19/go.mod h1:6Q+rUmzAizdpU3sqnzMzSHmX7Z69qN69xxl0up/mQQA=
github.com/edgexfoundry/go-mod-configuration/v2 v2.2.0-dev.3 h1:dTTExUFHza9eJmTABr8G4KOE8JKBMzZCVC3wARiwIg4=
github.com/edgexfoundry/go-mod-configuration/v2 v2.2.0-dev.3/go.mod h1:YP17JhMnXTitowXE13QJwFaKo0oc03iyoKLjWAYl4FE=
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.2.0-dev.26 h1:YebVI3gAJwFTMXKzB2erUonBC8eNrr+qLUGdtXFMjKs=
Expand Down
2 changes: 1 addition & 1 deletion internal/app/triggerfactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (svc *Service) RegisterCustomTriggerFactory(name string,
if err := svc.MetricsManager().Register(internal.MessagesReceivedName, messageProcessor.messagesReceived, nil); err != nil {
svc.lc.Warnf("%s metric failed to register and will not be reported: %s", internal.MessagesReceivedName, err.Error())
} else {
svc.lc.Infof("%s metric has been registered and will be reported", internal.MessagesReceivedName)
svc.lc.Infof("%s metric has been registered and will be reported (if enabled)", internal.MessagesReceivedName)
}

cfg := interfaces.TriggerConfig{
Expand Down
14 changes: 8 additions & 6 deletions internal/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ import (
"strings"
"sync"

bootstrapContainer "github.com/edgexfoundry/go-mod-bootstrap/v2/bootstrap/container"
gometrics "github.com/rcrowley/go-metrics"

bootstrapContainer "github.com/edgexfoundry/go-mod-bootstrap/v2/bootstrap/container"

"github.com/edgexfoundry/app-functions-sdk-go/v2/internal"
"github.com/edgexfoundry/app-functions-sdk-go/v2/internal/appfunction"
"github.com/edgexfoundry/app-functions-sdk-go/v2/pkg/interfaces"

"github.com/edgexfoundry/go-mod-bootstrap/v2/di"
"github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger"
"github.com/edgexfoundry/go-mod-core-contracts/v2/common"
"github.com/edgexfoundry/go-mod-core-contracts/v2/dtos"
Expand All @@ -44,6 +44,8 @@ import (
"github.com/edgexfoundry/go-mod-core-contracts/v2/models"
"github.com/edgexfoundry/go-mod-messaging/v2/pkg/types"

"github.com/edgexfoundry/go-mod-bootstrap/v2/di"

"github.com/fxamacker/cbor/v2"
)

Expand Down Expand Up @@ -148,19 +150,19 @@ func (gr *GolangRuntime) addFunctionsPipeline(id string, topics []string, transf
lc := bootstrapContainer.LoggingClientFrom(gr.dic.Get)
metricManager := bootstrapContainer.MetricsManagerFrom(gr.dic.Get)
name := strings.Replace(internal.PipelineMessagesProcessedName, internal.PipelineIdTxt, pipeline.Id, 1)
err := metricManager.Register(name, pipeline.MessagesProcessed, nil)
err := metricManager.Register(name, pipeline.MessagesProcessed, map[string]string{"pipeline": pipeline.Id})
if err != nil {
lc.Warnf("Unable to register %s metric. Metric will not be reported : %s", name, err.Error())
} else {
lc.Infof("%s metric has been registered and will be reported", name)
lc.Infof("%s metric has been registered and will be reported (if enabled)", name)
}

name = strings.Replace(internal.PipelineMessageProcessingTimeName, internal.PipelineIdTxt, pipeline.Id, 1)
err = metricManager.Register(name, pipeline.MessageProcessingTime, nil)
err = metricManager.Register(name, pipeline.MessageProcessingTime, map[string]string{"pipeline": pipeline.Id})
if err != nil {
lc.Warnf("Unable to register %s metric. Metric will not be reported : %s", name, err.Error())
} else {
lc.Infof("%s metric has been registered and will be reported", name)
lc.Infof("%s metric has been registered and will be reported (if enabled)", name)
}

return &pipeline
Expand Down