-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sp services add metrics (#211)
* feat: sp service adds metrics * fix: add metrics config * refactor: refactor metrics service * fix: update go.mod * fix: fix config toml template * chore: coding adjustments * fix: golang ci lint error --------- Co-authored-by: DylanYong <dylan.y@nodereal.io> Co-authored-by: joeylichang <joeycli0919@gmail.com>
- Loading branch information
1 parent
f693c65
commit 6fcfe19
Showing
24 changed files
with
729 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,107 @@ | ||
package utils | ||
|
||
import ( | ||
"github.com/bnb-chain/greenfield-storage-provider/config" | ||
"github.com/urfave/cli/v2" | ||
|
||
"github.com/bnb-chain/greenfield-storage-provider/model" | ||
) | ||
|
||
const ( | ||
ConfigCategory = "SP CONFIG" | ||
LoggingCategory = "LOGGING AND DEBUGGING" | ||
MetricsCategory = "METRICS AND STATS" | ||
DatabaseCategory = "DATABASE" | ||
) | ||
|
||
var ( | ||
ConfigFileFlag = &cli.StringFlag{ | ||
Name: "config", | ||
Aliases: []string{"c"}, | ||
Usage: "Config file path for uploading to db", | ||
Value: "./config.toml", | ||
Name: "config", | ||
Category: ConfigCategory, | ||
Aliases: []string{"c"}, | ||
Usage: "Config file path for uploading to db", | ||
Value: "./config.toml", | ||
} | ||
ConfigRemoteFlag = &cli.BoolFlag{ | ||
Name: "config.remote", | ||
Name: "config.remote", | ||
Category: ConfigCategory, | ||
Usage: "Flag load config from remote db,if 'config.remote' be set, the db.user, " + | ||
"db.password and db.address flags are needed, otherwise use the default value", | ||
} | ||
ServerFlag = &cli.StringFlag{ | ||
Name: "server", | ||
Aliases: []string{"service", "s"}, | ||
Usage: "Services to be started list, eg -server gateway,uploader,receiver... ", | ||
Name: "server", | ||
Category: ConfigCategory, | ||
Aliases: []string{"service", "svc"}, | ||
Usage: "Services to be started list, e.g. -server gateway, uploader, receiver...", | ||
} | ||
|
||
// database flags | ||
DBUserFlag = &cli.StringFlag{ | ||
Name: "db.user", | ||
Usage: "DB user name", | ||
EnvVars: []string{model.SpDBUser}, | ||
Name: "db.user", | ||
Category: DatabaseCategory, | ||
Usage: "DB user name", | ||
EnvVars: []string{model.SpDBUser}, | ||
} | ||
DBPasswordFlag = &cli.StringFlag{ | ||
Name: "db.password", | ||
Usage: "DB user password", | ||
EnvVars: []string{model.SpDBPasswd}, | ||
Name: "db.password", | ||
Category: DatabaseCategory, | ||
Usage: "DB user password", | ||
EnvVars: []string{model.SpDBPasswd}, | ||
} | ||
DBAddressFlag = &cli.StringFlag{ | ||
Name: "db.address", | ||
Usage: "DB listen address", | ||
EnvVars: []string{model.SpDBAddress}, | ||
Value: "localhost:3306", | ||
Name: "db.address", | ||
Category: DatabaseCategory, | ||
Usage: "DB listen address", | ||
EnvVars: []string{model.SpDBAddress}, | ||
Value: config.DefaultSQLDBConfig.Address, | ||
} | ||
DBDataBaseFlag = &cli.StringFlag{ | ||
Name: "db.database", | ||
Usage: "DB database name", | ||
EnvVars: []string{model.SpDBDataBase}, | ||
Value: "localhost:3306", | ||
DBDatabaseFlag = &cli.StringFlag{ | ||
Name: "db.database", | ||
Category: DatabaseCategory, | ||
Usage: "DB database name", | ||
EnvVars: []string{model.SpDBDataBase}, | ||
Value: config.DefaultSQLDBConfig.Database, | ||
} | ||
|
||
// log flags | ||
LogLevelFlag = &cli.StringFlag{ | ||
Name: "log.level", | ||
Usage: "log level", | ||
Value: "info", | ||
Name: "log.level", | ||
Category: LoggingCategory, | ||
Usage: "log level", | ||
Value: "info", | ||
} | ||
LogPathFlag = &cli.StringFlag{ | ||
Name: "log.path", | ||
Usage: "log output file path", | ||
Value: "./gnfd-sp.log", | ||
Name: "log.path", | ||
Category: LoggingCategory, | ||
Usage: "log output file path", | ||
Value: config.DefaultLogConfig.Path, | ||
} | ||
LogStdOutputFlag = &cli.BoolFlag{ | ||
Name: "log.std", | ||
Usage: "log output standard io", | ||
Name: "log.std", | ||
Category: LoggingCategory, | ||
Usage: "log output standard io", | ||
} | ||
|
||
// Metrics flags | ||
MetricsEnabledFlag = &cli.BoolFlag{ | ||
Name: "metrics", | ||
Category: MetricsCategory, | ||
Usage: "Enable metrics collection and reporting", | ||
Value: config.DefaultMetricsConfig.Enabled, | ||
} | ||
MetricsHTTPFlag = &cli.StringFlag{ | ||
Name: "metrics.addr", | ||
Category: MetricsCategory, | ||
Usage: "Enable stand-alone metrics HTTP server listening address", | ||
Value: config.DefaultMetricsConfig.HTTPAddress, | ||
} | ||
) | ||
|
||
// MergeFlags merges the given flag slices. | ||
func MergeFlags(groups ...[]cli.Flag) []cli.Flag { | ||
var ret []cli.Flag | ||
for _, group := range groups { | ||
ret = append(ret, group...) | ||
} | ||
return ret | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.