From 9de053dfee18f8522b20a01fa4e1ab0b6d69e96f Mon Sep 17 00:00:00 2001 From: yeya24 Date: Wed, 14 Aug 2019 18:15:23 +0800 Subject: [PATCH] add dfget metrics Signed-off-by: yeya24 --- apis/swagger.yml | 73 ++++++++++++++++ apis/types/task_metrics_request.go | 129 +++++++++++++++++++++++++++++ cmd/supernode/app/root.go | 24 ++++-- dfget/core/api/supernode_api.go | 26 +++++- dfget/core/core.go | 48 +++++++++-- dfget/core/helper/test_helper.go | 22 +++-- docs/user_guide/metrics.md | 9 +- supernode/daemon/daemon.go | 4 +- supernode/server/metrics.go | 70 ++++++++++++++-- supernode/server/router.go | 1 + supernode/server/router_test.go | 3 +- supernode/server/server.go | 7 +- 12 files changed, 383 insertions(+), 33 deletions(-) create mode 100644 apis/types/task_metrics_request.go diff --git a/apis/swagger.yml b/apis/swagger.yml index f3024f778..625891613 100644 --- a/apis/swagger.yml +++ b/apis/swagger.yml @@ -584,6 +584,25 @@ paths: 500: $ref: "#/responses/500ErrorResponse" + /task/metrics: + post: + summary: "upload dfclient download metrics" + description: | + This endpoint is mainly for observability. Dfget is a short-live job + and we use this endpoint to upload dfget download related metrics. + parameters: + - name: "body" + in: "body" + description: "request body which contains dfget download related information" + schema: + $ref: "#/definitions/TaskMetricsRequest" + responses: + 200: + description: "no error" + schema: + $ref: "#/definitions/ResultInfo" + 500: + $ref: "#/responses/500ErrorResponse" definitions: Error: @@ -1198,6 +1217,60 @@ definitions: black/white list mechanism to guarantee security, or some other purposes like debugging. minLength: 1 + TaskMetricsRequest: + type: "object" + description: "" + properties: + IP: + type: "string" + description: "IP address which peer client carries" + format: "string" + port: + type: "integer" + description: | + when registering, dfget will setup one uploader process. + This one acts as a server for peer pulling tasks. + This port is which this server listens on. + format: "int32" + minimum: 15000 + maximum: 65000 + taskId: + type: "string" + description: "IP address which peer client carries" + format: "string" + cID: + type: "string" + description: | + CID means the client ID. It maps to the specific dfget process. + When user wishes to download an image/file, user would start a dfget process to do this. + This dfget is treated a client and carries a client ID. + Thus, multiple dfget processes on the same peer have different CIDs. + callSystem: + type: "string" + description: | + This attribute represents where the dfget requests come from. Dfget will pass + this field to supernode and supernode can do some checking and filtering via + black/white list mechanism to guarantee security, or some other purposes like debugging. + minLength: 1 + duration: + type: "number" + format: float64 + description: | + Duration for dfget task. + success: + type: "boolean" + description: "whether the download task success or not" + backsourceReason: + type: "string" + description: | + when registering, dfget will setup one uploader process. + This one acts as a server for peer pulling tasks. + This port is which this server listens on. + fileLength: + type: "integer" + format: "int64" + description: "The length of the file dfget requests to download in bytes." + ErrorResponse: type: "object" description: | diff --git a/apis/types/task_metrics_request.go b/apis/types/task_metrics_request.go new file mode 100644 index 000000000..bc26f54aa --- /dev/null +++ b/apis/types/task_metrics_request.go @@ -0,0 +1,129 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package types + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// TaskMetricsRequest task metrics request +// swagger:model TaskMetricsRequest +type TaskMetricsRequest struct { + + // IP address which peer client carries + IP string `json:"IP,omitempty"` + + // when registering, dfget will setup one uploader process. + // This one acts as a server for peer pulling tasks. + // This port is which this server listens on. + // + BacksourceReason string `json:"backsourceReason,omitempty"` + + // CID means the client ID. It maps to the specific dfget process. + // When user wishes to download an image/file, user would start a dfget process to do this. + // This dfget is treated a client and carries a client ID. + // Thus, multiple dfget processes on the same peer have different CIDs. + // + CID string `json:"cID,omitempty"` + + // This attribute represents where the dfget requests come from. Dfget will pass + // this field to supernode and supernode can do some checking and filtering via + // black/white list mechanism to guarantee security, or some other purposes like debugging. + // + // Min Length: 1 + CallSystem string `json:"callSystem,omitempty"` + + // Duration for dfget task. + // + Duration float64 `json:"duration,omitempty"` + + // The length of the file dfget requests to download in bytes. + FileLength int64 `json:"fileLength,omitempty"` + + // when registering, dfget will setup one uploader process. + // This one acts as a server for peer pulling tasks. + // This port is which this server listens on. + // + // Maximum: 65000 + // Minimum: 15000 + Port int32 `json:"port,omitempty"` + + // whether the download task success or not + Success bool `json:"success,omitempty"` + + // IP address which peer client carries + TaskID string `json:"taskId,omitempty"` +} + +// Validate validates this task metrics request +func (m *TaskMetricsRequest) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCallSystem(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePort(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TaskMetricsRequest) validateCallSystem(formats strfmt.Registry) error { + + if swag.IsZero(m.CallSystem) { // not required + return nil + } + + if err := validate.MinLength("callSystem", "body", string(m.CallSystem), 1); err != nil { + return err + } + + return nil +} + +func (m *TaskMetricsRequest) validatePort(formats strfmt.Registry) error { + + if swag.IsZero(m.Port) { // not required + return nil + } + + if err := validate.MinimumInt("port", "body", int64(m.Port), 15000, false); err != nil { + return err + } + + if err := validate.MaximumInt("port", "body", int64(m.Port), 65000, false); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TaskMetricsRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TaskMetricsRequest) UnmarshalBinary(b []byte) error { + var res TaskMetricsRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/cmd/supernode/app/root.go b/cmd/supernode/app/root.go index d90492240..2d910e149 100644 --- a/cmd/supernode/app/root.go +++ b/cmd/supernode/app/root.go @@ -127,8 +127,15 @@ func runSuperNode() error { if err := fileutils.CreateDirectory(options.HomeDir); err != nil { return fmt.Errorf("failed to create home dir %s: %v", options.HomeDir, err) } - // initialize log. - if err := initLog(); err != nil { + + // initialize supernode logger. + if err := initLog(logrus.StandardLogger(), "app.log"); err != nil { + return err + } + + // initialize dfget logger. + dfgetLogger := logrus.New() + if err := initLog(dfgetLogger, "dfget.log"); err != nil { return err } @@ -151,7 +158,7 @@ func runSuperNode() error { logrus.Info("start to run supernode") - d, err := daemon.New(cfg) + d, err := daemon.New(cfg, dfgetLogger) if err != nil { logrus.Errorf("failed to initialize daemon in supernode: %v", err) return err @@ -166,9 +173,9 @@ func runSuperNode() error { return d.Run() } -// initLog initializes log Level and log format of daemon. -func initLog() error { - logFilePath := path.Join(options.HomeDir, "logs", "app.log") +// initLog initializes log Level and log format +func initLog(logger *logrus.Logger, logPath string) error { + logFilePath := path.Join(options.HomeDir, "logs", logPath) opts := []dflog.Option{ dflog.WithLogFile(logFilePath), @@ -177,8 +184,11 @@ func initLog() error { } logrus.Debugf("use log file %s", logFilePath) + if err := dflog.Init(logger, opts...); err != nil { + return errors.Wrap(err, "init log") + } - return errors.Wrap(dflog.Init(logrus.StandardLogger(), opts...), "init log") + return nil } // initConfig load configuration from config file. diff --git a/dfget/core/api/supernode_api.go b/dfget/core/api/supernode_api.go index fdfe0ffa3..55dcd192f 100644 --- a/dfget/core/api/supernode_api.go +++ b/dfget/core/api/supernode_api.go @@ -21,6 +21,7 @@ import ( "fmt" "time" + api_types "github.com/dragonflyoss/Dragonfly/apis/types" "github.com/dragonflyoss/Dragonfly/dfget/types" "github.com/dragonflyoss/Dragonfly/pkg/constants" "github.com/dragonflyoss/Dragonfly/pkg/httputils" @@ -35,6 +36,7 @@ const ( peerReportPiecePath = "/peer/piece/suc" peerClientErrorPath = "/peer/piece/error" peerServiceDownPath = "/peer/service/down" + metricsReportPath = "/task/metrics" ) // NewSupernodeAPI creates a new instance of SupernodeAPI with default value. @@ -53,6 +55,7 @@ type SupernodeAPI interface { ReportPiece(node string, req *types.ReportPieceRequest) (resp *types.BaseResponse, e error) ServiceDown(node string, taskID string, cid string) (resp *types.BaseResponse, e error) ReportClientError(node string, req *types.ClientErrorRequest) (resp *types.BaseResponse, e error) + ReportMetrics(node string, req *api_types.TaskMetricsRequest) (resp *types.BaseResponse, e error) } type supernodeAPI struct { @@ -149,6 +152,26 @@ func (api *supernodeAPI) ReportClientError(node string, req *types.ClientErrorRe return } +func (api *supernodeAPI) ReportMetrics(node string, req *api_types.TaskMetricsRequest) (resp *types.BaseResponse, err error) { + var ( + code int + body []byte + ) + url := fmt.Sprintf("%s://%s%s", + api.Scheme, node, metricsReportPath) + if code, body, err = api.HTTPClient.PostJSON(url, req, api.Timeout); err != nil { + return nil, err + } + if !httputils.HTTPStatusOk(code) { + return nil, fmt.Errorf("%d:%s", code, body) + } + resp = new(types.BaseResponse) + if err = json.Unmarshal(body, resp); err != nil { + return nil, err + } + return resp, err +} + func (api *supernodeAPI) get(url string, resp interface{}) error { var ( code int @@ -164,6 +187,5 @@ func (api *supernodeAPI) get(url string, resp interface{}) error { if !httputils.HTTPStatusOk(code) { return fmt.Errorf("%d:%s", code, body) } - e = json.Unmarshal(body, resp) - return e + return json.Unmarshal(body, resp) } diff --git a/dfget/core/core.go b/dfget/core/core.go index 3640e496c..a8d82ba03 100644 --- a/dfget/core/core.go +++ b/dfget/core/core.go @@ -24,8 +24,10 @@ import ( "os" "path" "path/filepath" + "strconv" "time" + "github.com/dragonflyoss/Dragonfly/apis/types" "github.com/dragonflyoss/Dragonfly/dfget/config" "github.com/dragonflyoss/Dragonfly/dfget/core/api" "github.com/dragonflyoss/Dragonfly/dfget/core/downloader" @@ -179,11 +181,10 @@ func downloadFile(cfg *config.Config, supernodeAPI api.SupernodeAPI, if timeout == 0 && cfg.Timeout > 0 { timeout = time.Duration(cfg.Timeout) * time.Second } + success := true err := downloader.DoDownloadTimeout(getter, timeout) - success := "SUCCESS" if err != nil { - logrus.Error(err) - success = "FAIL" + success = false } else if cfg.RV.FileLength < 0 && fileutils.IsRegularFile(cfg.RV.RealTarget) { if info, err := os.Stat(cfg.RV.RealTarget); err == nil { cfg.RV.FileLength = info.Size() @@ -191,10 +192,21 @@ func downloadFile(cfg *config.Config, supernodeAPI api.SupernodeAPI, } reportFinishedTask(cfg, getter) - os.Remove(cfg.RV.TempTarget) - logrus.Infof("download %s cost:%.3fs length:%d reason:%d", - success, time.Since(cfg.StartTime).Seconds(), cfg.RV.FileLength, cfg.BackSourceReason) + + downloadTime := time.Since(cfg.StartTime).Seconds() + // upload metrics to supernode only if pattern is p2p or cdn and result is not nil + if cfg.Pattern != config.PatternSource && result != nil { + reportMetrics(cfg, supernodeAPI, downloadTime, result.TaskID, success) + } + + if success { + logrus.Infof("download SUCCESS from supernode %s cost:%.3fs length:%d", + cfg.Node, time.Since(cfg.StartTime).Seconds(), cfg.RV.FileLength) + } else { + logrus.Infof("download FAIL from supernode %s cost:%.3fs length:%d reason:%d", + cfg.Node, time.Since(cfg.StartTime).Seconds(), cfg.RV.FileLength, cfg.BackSourceReason) + } return err } @@ -269,3 +281,27 @@ func checkConnectSupernode(nodes []string) (localIP string) { } return "" } + +func reportMetrics(cfg *config.Config, supernodeAPI api.SupernodeAPI, downloadTime float64, taskID string, success bool) { + req := &types.TaskMetricsRequest{ + BacksourceReason: strconv.Itoa(cfg.BackSourceReason), + IP: cfg.RV.LocalIP, + CID: cfg.RV.Cid, + CallSystem: cfg.CallSystem, + Duration: downloadTime, + FileLength: cfg.RV.FileLength, + Port: int32(cfg.RV.PeerPort), + Success: success, + TaskID: taskID, + } + for _, node := range cfg.Node { + resp, err := supernodeAPI.ReportMetrics(node, req) + if err != nil { + logrus.Errorf("failed to report metrics to supernode %s: %v", node, err) + } + if resp.IsSuccess() { + return + } + } + return +} diff --git a/dfget/core/helper/test_helper.go b/dfget/core/helper/test_helper.go index 8d09395cc..5232d1a90 100644 --- a/dfget/core/helper/test_helper.go +++ b/dfget/core/helper/test_helper.go @@ -24,6 +24,7 @@ import ( "os" "path" + api_types "github.com/dragonflyoss/Dragonfly/apis/types" "github.com/dragonflyoss/Dragonfly/dfget/config" "github.com/dragonflyoss/Dragonfly/dfget/core/api" "github.com/dragonflyoss/Dragonfly/dfget/types" @@ -110,13 +111,17 @@ type ServiceDownFuncType func(ip string, taskID string, cid string) (*types.Base // ClientErrorFuncType function type of SupernodeAPI#ReportClientError type ClientErrorFuncType func(ip string, req *types.ClientErrorRequest) (*types.BaseResponse, error) +// ClientErrorFuncType function type of SupernodeAPI#ReportMetricsType +type ReportMetricsFuncType func(node string, req *api_types.TaskMetricsRequest) (*types.BaseResponse, error) + // MockSupernodeAPI mock SupernodeAPI type MockSupernodeAPI struct { - RegisterFunc RegisterFuncType - PullFunc PullFuncType - ReportFunc ReportFuncType - ServiceDownFunc ServiceDownFuncType - ClientErrorFunc ClientErrorFuncType + RegisterFunc RegisterFuncType + PullFunc PullFuncType + ReportFunc ReportFuncType + ServiceDownFunc ServiceDownFuncType + ClientErrorFunc ClientErrorFuncType + ReportMetricsFunc ReportMetricsFuncType } var _ api.SupernodeAPI = &MockSupernodeAPI{} @@ -165,6 +170,13 @@ func (m *MockSupernodeAPI) ReportClientError(ip string, req *types.ClientErrorRe return nil, nil } +func (m *MockSupernodeAPI) ReportMetrics(ip string, req *api_types.TaskMetricsRequest) (resp *types.BaseResponse, e error) { + if m.ClientErrorFunc != nil { + return m.ReportMetricsFunc(ip, req) + } + return nil, nil +} + // CreateRegisterFunc creates a mock register function func CreateRegisterFunc() RegisterFuncType { var newResponse = func(code int, msg string) *types.RegisterResponse { diff --git a/docs/user_guide/metrics.md b/docs/user_guide/metrics.md index 022673c55..0b0e05425 100644 --- a/docs/user_guide/metrics.md +++ b/docs/user_guide/metrics.md @@ -1,6 +1,6 @@ # Prometheus Metrics -This doc contains all the metrics that Dragonfly components currently support. Now we only support metrics for Dfdaemon and SuperNode. And we will support dfget metrics in the future. For Dfdaemon and SuperNode, the metrics path is fixed to /metrics. The following metrics are exported. +This doc contains all the metrics that Dragonfly components currently support. Now we support metrics for Dfdaemon, SuperNode and Dfget. For Dfdaemon and SuperNode, the metrics path is fixed to /metrics. The following metrics are exported. ## Supernode @@ -21,7 +21,7 @@ This doc contains all the metrics that Dragonfly components currently support. N - dragonfly_supernode_cdn_cache_hit_total{} - total times of hitting cdn cache. counter type. - dragonfly_supernode_cdn_download_total{} - total times of cdn downloading. counter type. - dragonfly_supernode_cdn_download_failed_total{} - total failure times of cdn downloading. counter type. -- dragonfly_supernode_pieces_downloaded_size_bytes{} - total size of pieces downloaded from supernode in bytes. counter type. +- dragonfly_supernode_pieces_downloaded_size_bytes_total{} - total size of pieces downloaded from supernode in bytes. counter type. ## Dfdaemon @@ -29,4 +29,7 @@ This doc contains all the metrics that Dragonfly components currently support. N ## Dfget -TODO \ No newline at end of file +- dragonfly_dfget_download_duration_seconds{callsystem, peer} - dfget download duration in seconds. +- dragonfly_dfget_download_size_bytes_total{callsystem, peer} - total size of files downloaded by dfget in bytes. counter type. +- dragonfly_dfget_download_total{callsystem, peer} - total times of dfget downloading. counter type. +- dragonfly_dfget_download_failed_total{callsystem, peer, reason} - total times of failed dfget downloading. counter type. diff --git a/supernode/daemon/daemon.go b/supernode/daemon/daemon.go index 13e2ca8a9..29b66712b 100644 --- a/supernode/daemon/daemon.go +++ b/supernode/daemon/daemon.go @@ -43,12 +43,12 @@ type Daemon struct { } // New creates a new Daemon. -func New(cfg *config.Config) (*Daemon, error) { +func New(cfg *config.Config, dfgetLogger *logrus.Logger) (*Daemon, error) { if err := plugins.Initialize(cfg); err != nil { return nil, err } - s, err := server.New(cfg, prometheus.DefaultRegisterer) + s, err := server.New(cfg, dfgetLogger, prometheus.DefaultRegisterer) if err != nil { return nil, err } diff --git a/supernode/server/metrics.go b/supernode/server/metrics.go index 73b0f0dc0..7a0cb490b 100644 --- a/supernode/server/metrics.go +++ b/supernode/server/metrics.go @@ -17,21 +17,36 @@ package server import ( + "context" + "encoding/json" "net/http" + "strconv" + "github.com/dragonflyoss/Dragonfly/apis/types" + "github.com/dragonflyoss/Dragonfly/pkg/errortypes" "github.com/dragonflyoss/Dragonfly/pkg/metricsutils" "github.com/dragonflyoss/Dragonfly/supernode/config" + "github.com/go-openapi/strfmt" + "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) // metrics defines some prometheus metrics for monitoring supernode type metrics struct { - requestCounter *prometheus.CounterVec - requestDuration *prometheus.HistogramVec - requestSize *prometheus.HistogramVec - responseSize *prometheus.HistogramVec + // server http related metrics + requestCounter *prometheus.CounterVec + requestDuration *prometheus.HistogramVec + requestSize *prometheus.HistogramVec + responseSize *prometheus.HistogramVec + + // dfget metrics + dfgetDownloadDuration *prometheus.HistogramVec + dfgetDownloadFileSize *prometheus.CounterVec + dfgetDownloadCount *prometheus.CounterVec + dfgetDownloadFailCount *prometheus.CounterVec + pieceDownloadedBytes *prometheus.CounterVec } @@ -52,8 +67,21 @@ func newMetrics(register prometheus.Registerer) *metrics { "Histogram of response size for HTTP requests.", []string{"handler"}, prometheus.ExponentialBuckets(100, 10, 8), register, ), - pieceDownloadedBytes: metricsutils.NewCounter(config.SubsystemSupernode, "pieces_downloaded_size_bytes", - "total bytes of pieces downloaded from supernode", []string{}, register, + pieceDownloadedBytes: metricsutils.NewCounter(config.SubsystemSupernode, "pieces_downloaded_size_bytes_total", + "total file size of pieces downloaded from supernode in bytes", []string{}, register, + ), + dfgetDownloadDuration: metricsutils.NewHistogram(config.SubsystemDfget, "download_duration_seconds", + "Histogram of duration for dfget download.", []string{"callsystem", "peer"}, + []float64{10, 30, 60, 120, 300, 600}, register, + ), + dfgetDownloadFileSize: metricsutils.NewCounter(config.SubsystemDfget, "download_size_bytes_total", + "Total file size downloaded by dfget in bytes", []string{"callsystem", "peer"}, register, + ), + dfgetDownloadCount: metricsutils.NewCounter(config.SubsystemDfget, "download_total", + "Total times of dfget download", []string{"callsystem", "peer"}, register, + ), + dfgetDownloadFailCount: metricsutils.NewCounter(config.SubsystemDfget, "download_failed_total", + "Total failure times of dfget download", []string{"callsystem", "peer", "reason"}, register, ), } } @@ -74,3 +102,33 @@ func (m *metrics) instrumentHandler(handlerName string, handler http.HandlerFunc ), ) } + +func (m *metrics) handleMetricsReport(ctx context.Context, rw http.ResponseWriter, req *http.Request) (err error) { + reader := req.Body + request := &types.TaskMetricsRequest{} + if err := json.NewDecoder(reader).Decode(request); err != nil { + return errors.Wrap(errortypes.ErrInvalidValue, err.Error()) + } + + if err := request.Validate(strfmt.NewFormats()); err != nil { + return errors.Wrap(errortypes.ErrInvalidValue, err.Error()) + } + status := "success" + if !request.Success { + status = "failed" + } + + dfgetLogger.Debugf("dfget peer %s download %s, taskid %s, callsystem %s, filelength %d, "+ + "backsource reason %s", request.IP+":"+strconv.Itoa(int(request.Port)), status, request.TaskID, + request.CallSystem, request.FileLength, request.BacksourceReason) + + m.dfgetDownloadCount.WithLabelValues(request.CallSystem, request.IP).Inc() + if request.Success { + m.dfgetDownloadDuration.WithLabelValues(request.CallSystem, request.IP).Observe(request.Duration) + m.dfgetDownloadFileSize.WithLabelValues(request.CallSystem, request.IP).Add(float64(request.FileLength)) + } else { + m.dfgetDownloadFailCount.WithLabelValues(request.CallSystem, request.IP, request.BacksourceReason).Inc() + } + + return EncodeResponse(rw, http.StatusOK, nil) +} diff --git a/supernode/server/router.go b/supernode/server/router.go index b4cc49428..675ec933b 100644 --- a/supernode/server/router.go +++ b/supernode/server/router.go @@ -57,6 +57,7 @@ func initRoute(s *Server) *mux.Router { // metrics {Method: http.MethodGet, Path: "/metrics", HandlerFunc: handleMetrics}, + {Method: http.MethodPost, Path: "/task/metrics", HandlerFunc: m.handleMetricsReport}, } // register API diff --git a/supernode/server/router_test.go b/supernode/server/router_test.go index 83711cdfb..893c3b128 100644 --- a/supernode/server/router_test.go +++ b/supernode/server/router_test.go @@ -36,6 +36,7 @@ import ( "github.com/gorilla/mux" "github.com/prometheus/client_golang/prometheus" prom_testutil "github.com/prometheus/client_golang/prometheus/testutil" + "github.com/sirupsen/logrus" ) func Test(t *testing.T) { @@ -68,7 +69,7 @@ func (rs *RouterTestSuite) SetUpSuite(c *check.C) { Plugins: nil, Storages: nil, } - s, err := New(testConf, prometheus.NewRegistry()) + s, err := New(testConf, logrus.StandardLogger(), prometheus.NewRegistry()) c.Check(err, check.IsNil) version.DFVersion = &types.DragonflyVersion{ Version: "test", diff --git a/supernode/server/server.go b/supernode/server/server.go index 8b812b286..855201dac 100644 --- a/supernode/server/server.go +++ b/supernode/server/server.go @@ -40,6 +40,8 @@ import ( "github.com/sirupsen/logrus" ) +var dfgetLogger *logrus.Logger + // Server is supernode server struct. type Server struct { Config *config.Config @@ -53,10 +55,13 @@ type Server struct { } // New creates a brand new server instance. -func New(cfg *config.Config, register prometheus.Registerer) (*Server, error) { +func New(cfg *config.Config, logger *logrus.Logger, register prometheus.Registerer) (*Server, error) { + var err error // register supernode build information version.NewBuildInfo("supernode", register) + dfgetLogger = logger + sm, err := store.NewManager(cfg) if err != nil { return nil, err