Skip to content
Closed
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
5 changes: 5 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/rs/zerolog/log"
"github.com/sprintertech/sprinter-signing/api/handlers"
"github.com/sprintertech/sprinter-signing/health"
Expand All @@ -18,12 +19,16 @@ func Serve(
unlockHandler *handlers.UnlockHandler,
statusHandler *handlers.StatusHandler,
confirmationsHandler *handlers.ConfirmationsHandler,
prometheusEnabled bool,
) {
r := mux.NewRouter()
r.HandleFunc("/v1/chains/{chainId:[0-9]+}/unlocks", unlockHandler.HandleUnlock).Methods("POST")
r.HandleFunc("/v1/chains/{chainId:[0-9]+}/signatures", signingHandler.HandleSigning).Methods("POST")
r.HandleFunc("/v1/chains/{chainId:[0-9]+}/signatures/{depositId}", statusHandler.HandleRequest).Methods("GET")
r.HandleFunc("/v1/chains/{chainId:[0-9]+}/confirmations", confirmationsHandler.HandleRequest).Methods("GET")
if prometheusEnabled {
r.Handle("/metrics", promhttp.Handler()).Methods("GET")
}
r.HandleFunc("/health", health.HealthHandler()).Methods("GET")

server := &http.Server{
Expand Down
14 changes: 12 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Copy link
Collaborator

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.

Copy link
Author

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?

promExporter, err := promexporter.New()
panicOnError(err)
meterOpts = append(meterOpts, sdkmetric.WithReader(promExporter))
}

mp, err := observability.InitMetricProvider(context.Background(), configuration.RelayerConfig.OpenTelemetryCollectorURL, meterOpts...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mp, err := observability.InitMetricProvider(context.Background(), configuration.RelayerConfig.OpenTelemetryCollectorURL, meterOpts...)
mp, err := observability.InitMetricProvider(ctx, configuration.RelayerConfig.OpenTelemetryCollectorURL, meterOpts...)

panicOnError(err)
defer func() {
if err := mp.Shutdown(context.Background()); err != nil {
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions config/relayer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type RelayerConfig struct {
CoinmarketcapConfig CoinmarketcapConfig
SolverConfig SolverConfig
ApiAddr string
PrometheusEnabled bool
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an OpentelemetryCollectorURL variable which we are not using.
This doesn't make sense from the standpoint that it will still try to push to the collector, but printout logs that it fails (that is what currently happens).

}

type CoinmarketcapConfig struct {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/stretchr/testify v1.10.0
github.com/sygmaprotocol/sygma-core v0.0.0-20250304150334-bd39ac4f7b82
go.opentelemetry.io/otel v1.16.0
go.opentelemetry.io/otel/exporters/prometheus v0.39.0
go.opentelemetry.io/otel/metric v1.16.0
go.uber.org/mock v0.5.2
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67
Expand Down Expand Up @@ -190,7 +191,7 @@ require (
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.61.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
Expand All @@ -209,7 +210,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.39.0 // indirect
go.opentelemetry.io/otel/sdk v1.16.0 // indirect
go.opentelemetry.io/otel/sdk/metric v0.39.0 // indirect
go.opentelemetry.io/otel/sdk/metric v0.39.0
go.opentelemetry.io/otel/trace v1.16.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,8 @@ go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 h1:f6BwB2OACc3FCbYVzn
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0/go.mod h1:UqL5mZ3qs6XYhDnZaW1Ps4upD+PX6LipH40AoeuIlwU=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.39.0 h1:IZXpCEtI7BbX01DRQEWTGDkvjMB6hEhiEZXS+eg2YqY=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.39.0/go.mod h1:xY111jIZtWb+pUUgT4UiiSonAaY2cD2Ts5zvuKLki3o=
go.opentelemetry.io/otel/exporters/prometheus v0.39.0 h1:whAaiHxOatgtKd+w0dOi//1KUxj3KoPINZdtDaDj3IA=
go.opentelemetry.io/otel/exporters/prometheus v0.39.0/go.mod h1:4jo5Q4CROlCpSPsXLhymi+LYrDXd2ObU5wbKayfZs7Y=
go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo=
go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4=
go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE=
Expand Down
Loading