-
Notifications
You must be signed in to change notification settings - Fork 1
chore: Add optional prometheus metrics #144
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -62,6 +62,8 @@ import ( | |||||
| "github.com/sygmaprotocol/sygma-core/relayer/message" | ||||||
| "github.com/sygmaprotocol/sygma-core/store" | ||||||
| "github.com/sygmaprotocol/sygma-core/store/lvldb" | ||||||
| promexporter "go.opentelemetry.io/otel/exporters/prometheus" | ||||||
| sdkmetric "go.opentelemetry.io/otel/sdk/metric" | ||||||
| ) | ||||||
|
|
||||||
| var Version string | ||||||
|
|
@@ -112,7 +114,14 @@ func Run() error { | |||||
| ctx, cancel := context.WithCancel(context.Background()) | ||||||
| defer cancel() | ||||||
|
|
||||||
| mp, err := observability.InitMetricProvider(context.Background(), configuration.RelayerConfig.OpenTelemetryCollectorURL) | ||||||
| var meterOpts []sdkmetric.Option | ||||||
| if configuration.RelayerConfig.PrometheusEnabled { | ||||||
| promExporter, err := promexporter.New() | ||||||
| panicOnError(err) | ||||||
| meterOpts = append(meterOpts, sdkmetric.WithReader(promExporter)) | ||||||
| } | ||||||
|
|
||||||
| mp, err := observability.InitMetricProvider(context.Background(), configuration.RelayerConfig.OpenTelemetryCollectorURL, meterOpts...) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| panicOnError(err) | ||||||
| defer func() { | ||||||
| if err := mp.Shutdown(context.Background()); err != nil { | ||||||
|
|
@@ -430,7 +439,8 @@ func Run() error { | |||||
| signingHandler, | ||||||
| unlockHandler, | ||||||
| statusHandler, | ||||||
| confirmationsHandler) | ||||||
| confirmationsHandler, | ||||||
| configuration.RelayerConfig.PrometheusEnabled) | ||||||
|
|
||||||
| sig := <-sysErr | ||||||
| log.Info().Msgf("terminating got ` [%v] signal", sig) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ type RelayerConfig struct { | |
| CoinmarketcapConfig CoinmarketcapConfig | ||
| SolverConfig SolverConfig | ||
| ApiAddr string | ||
| PrometheusEnabled bool | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is an OpentelemetryCollectorURL variable which we are not using. |
||
| } | ||
|
|
||
| type CoinmarketcapConfig struct { | ||
|
|
@@ -72,6 +73,7 @@ type RawRelayerConfig struct { | |
| CoinmarketcapConfig CoinmarketcapConfig `mapstructure:"CoinmarketcapConfig" json:"coinmarketcapConfig"` | ||
| SolverConfig SolverConfig `mapstructure:"SolverConfig" json:"solverConfig"` | ||
| ApiAddr string `mapstructure:"apiAddr" default:"0.0.0.0:3000"` | ||
| PrometheusEnabled bool `mapstructure:"PrometheusEnabled" json:"prometheusEnabled" default:"false"` | ||
| } | ||
|
|
||
| type RawMpcRelayerConfig struct { | ||
|
|
@@ -147,6 +149,7 @@ func NewRelayerConfig(rawConfig RawRelayerConfig) (RelayerConfig, error) { | |
| config.Id = rawConfig.Id | ||
| config.ApiAddr = rawConfig.ApiAddr | ||
| config.SolverConfig = rawConfig.SolverConfig | ||
| config.PrometheusEnabled = rawConfig.PrometheusEnabled | ||
| return config, nil | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we even need the option.
There is really no reason to turn it off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean to turn off prometheus endpoint?