Repository: yorkie-team/yorkie
Pull request #166 (2021-03-28 07:09:47)

Add more metrics related to PushPull API
<!--  Thanks for sending a pull request! -->

**What this PR does / why we need it**:

Add more metrics related to PushPull API.

This PR continues #159.

**Which issue(s) this PR fixes**:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

**Special notes for your reviewer**:

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->
```release-note

```

**Additional documentation**:

<!--
This section can be blank if this pull request does not require a release note.

Please use the following format for linking documentation:
- [Usage]: <link>
- [Other doc]: <link>
-->
```docs

```

**Checklist**:
- [x] Added relevant tests or not required
- [ ] Didn't break anything


codecov[bot]: # [Codecov](https://codecov.io/gh/yorkie-team/yorkie/pull/166?src=pr&el=h1) Report
> Merging [#166](https://codecov.io/gh/yorkie-team/yorkie/pull/166?src=pr&el=desc) (51b8225) into [main](https://codecov.io/gh/yorkie-team/yorkie/commit/321b58e9cfae454cc190237bf027691cc49390be?el=desc) (321b58e) will **increase** coverage by `0.10%`.
> The diff coverage is `47.61%`.

[![Impacted file tree graph](https://codecov.io/gh/yorkie-team/yorkie/pull/166/graphs/tree.svg?width=650&height=150&src=pr&token=P6COB1ZNIC)](https://codecov.io/gh/yorkie-team/yorkie/pull/166?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##             main     #166      +/-   ##
==========================================
+ Coverage   59.67%   59.77%   +0.10%     
==========================================
  Files          37       37              
  Lines        3293     3304      +11     
==========================================
+ Hits         1965     1975      +10     
- Misses       1143     1144       +1     
  Partials      185      185              
```


| [Impacted Files](https://codecov.io/gh/yorkie-team/yorkie/pull/166?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [yorkie/backend/db/db.go](https://codecov.io/gh/yorkie-team/yorkie/pull/166/diff?src=pr&el=tree#diff-eW9ya2llL2JhY2tlbmQvZGIvZGIuZ28=) | `66.66% <ø> (ø)` | |
| [yorkie/yorkie.go](https://codecov.io/gh/yorkie-team/yorkie/pull/166/diff?src=pr&el=tree#diff-eW9ya2llL3lvcmtpZS5nbw==) | `0.00% <0.00%> (ø)` | |
| [yorkie/metrics/server.go](https://codecov.io/gh/yorkie-team/yorkie/pull/166/diff?src=pr&el=tree#diff-eW9ya2llL21ldHJpY3Mvc2VydmVyLmdv) | `47.82% <40.00%> (+11.82%)` | :arrow_up: |
| [yorkie/rpc/server.go](https://codecov.io/gh/yorkie-team/yorkie/pull/166/diff?src=pr&el=tree#diff-eW9ya2llL3JwYy9zZXJ2ZXIuZ28=) | `54.76% <100.00%> (+1.26%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/yorkie-team/yorkie/pull/166?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/yorkie-team/yorkie/pull/166?src=pr&el=footer). Last update [321b58e...51b8225](https://codecov.io/gh/yorkie-team/yorkie/pull/166?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

hackerwins: @dc7303 I did some code cleanup.

- Move metrics.Server to prometheus package to avoid dependency violation
- Add Metrics Reference to Backend
- And remove Metrics reference from db.Client, rpc.Server, metric.Server
- Fix typo: rename Pushpull to PushPull
- Add missing copyright statement
- Move type casts into prometheus

Patch:
diff --git a/go.mod b/go.mod
index 587f71ed..98a41b51 100644
--- a/go.mod
+++ b/go.mod
@@ -10,6 +10,7 @@ require (
 	github.com/google/uuid v1.0.0
 	github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4
 	github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
+	github.com/magiconair/properties v1.8.1
 	github.com/moby/locker v1.0.1
 	github.com/prometheus/client_golang v1.0.0
 	github.com/rs/xid v1.2.1
diff --git a/yorkie/backend/backend.go b/yorkie/backend/backend.go
index c6fbf3fa..68481b4c 100644
--- a/yorkie/backend/backend.go
+++ b/yorkie/backend/backend.go
@@ -25,6 +25,8 @@ import (
 	"github.com/yorkie-team/yorkie/yorkie/backend/sync"
 	"github.com/yorkie-team/yorkie/yorkie/backend/sync/etcd"
 	"github.com/yorkie-team/yorkie/yorkie/backend/sync/memory"
+	"github.com/yorkie-team/yorkie/yorkie/metrics"
+	"github.com/yorkie-team/yorkie/yorkie/metrics/prometheus"
 )
 
 // Config is the configuration for creating a Backend instance.
@@ -45,6 +47,7 @@ type Backend struct {
 	DB        db.DB
 	LockerMap sync.LockerMap
 	PubSub    sync.PubSub
+	Metrics   metrics.Metrics
 
 	// closing is closed by backend close.
 	closing chan struct{}
@@ -63,6 +66,8 @@ func New(
 	mongoConf *mongo.Config,
 	etcdConf *etcd.Config,
 ) (*Backend, error) {
+	met := prometheus.NewMetrics()
+
 	mongoClient, err := mongo.Dial(mongoConf)
 	if err != nil {
 		return nil, err
@@ -88,6 +93,7 @@ func New(
 		DB:        mongoClient,
 		LockerMap: lockerMap,
 		PubSub:    pubSub,
+		Metrics:   met,
 		closing:   make(chan struct{}),
 	}, nil
 }
diff --git a/yorkie/config.go b/yorkie/config.go
index dc789cb5..670157cf 100644
--- a/yorkie/config.go
+++ b/yorkie/config.go
@@ -27,7 +27,7 @@ import (
 	"github.com/yorkie-team/yorkie/yorkie/backend"
 	"github.com/yorkie-team/yorkie/yorkie/backend/db/mongo"
 	"github.com/yorkie-team/yorkie/yorkie/backend/sync/etcd"
-	"github.com/yorkie-team/yorkie/yorkie/metrics"
+	"github.com/yorkie-team/yorkie/yorkie/metrics/prometheus"
 	"github.com/yorkie-team/yorkie/yorkie/rpc"
 )
 
@@ -47,11 +47,11 @@ const (
 
 // Config is the configuration for creating a Yorkie instance.
 type Config struct {
-	RPC     *rpc.Config     `json:"RPC"`
-	Metrics *metrics.Config `json:"Metrics"`
-	Mongo   *mongo.Config   `json:"Mongo"`
-	ETCD    *etcd.Config    `json:"ETCD"`
-	Backend *backend.Config `json:"Backend"`
+	RPC     *rpc.Config        `json:"RPC"`
+	Metrics *prometheus.Config `json:"Metrics"`
+	Mongo   *mongo.Config      `json:"Mongo"`
+	ETCD    *etcd.Config       `json:"ETCD"`
+	Backend *backend.Config    `json:"Backend"`
 }
 
 // RPCAddr returns the RPC address.
@@ -93,7 +93,7 @@ func newConfig(port int, metricsPort int, dbName string) *Config {
 		RPC: &rpc.Config{
 			Port: port,
 		},
-		Metrics: &metrics.Config{
+		Metrics: &prometheus.Config{
 			Port: metricsPort,
 		},
 		Backend: &backend.Config{
diff --git a/yorkie/metrics/metrics.go b/yorkie/metrics/metrics.go
new file mode 100644
index 00000000..4ae113ac
--- /dev/null
+++ b/yorkie/metrics/metrics.go
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2021 The Yorkie Authors. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package metrics
+
+// Metrics manages the metric information that Yorkie is trying to measure.
+type Metrics interface {
+	// ObservePushPullResponseSeconds adds response time metrics for PushPull API.
+	ObservePushPullResponseSeconds(seconds float64)
+
+	// AddPushPullReceivedChanges adds the number of changes metric
+	// included in the request pack of the PushPull API.
+	AddPushPullReceivedChanges(count int)
+
+	// AddPushPullSentChanges adds the number of changes metric
+	// included in the response pack of the PushPull API.
+	AddPushPullSentChanges(count int)
+
+	// ObservePushPullSnapshotDurationSeconds adds the time
+	// spent metric when taking snapshots.
+	ObservePushPullSnapshotDurationSeconds(seconds float64)
+
+	// SetPushPullSnapshotBytes sets the snapshot byte size.
+	SetPushPullSnapshotBytes(bytes int)
+}
diff --git a/yorkie/metrics/prometheus/metrics.go b/yorkie/metrics/prometheus/metrics.go
new file mode 100644
index 00000000..c5c6f294
--- /dev/null
+++ b/yorkie/metrics/prometheus/metrics.go
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2021 The Yorkie Authors. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package prometheus
+
+import (
+	"github.com/prometheus/client_golang/prometheus"
+	"github.com/prometheus/client_golang/prometheus/promauto"
+
+	"github.com/yorkie-team/yorkie/pkg/version"
+)
+
+const (
+	namespace = "yorkie"
+)
+
+// Metrics manages the metric information that Yorkie is trying to measure.
+type Metrics struct {
+	agentVersion *prometheus.GaugeVec
+
+	pushPullResponseSeconds prometheus.Histogram
+	pushPullReceivedChanges prometheus.Counter
+	pushPullSentChanges     prometheus.Counter
+
+	pushPullSnapshotDurationSeconds prometheus.Histogram
+	pushPullSnapshotBytes           prometheus.Gauge
+}
+
+// NewMetrics creates a new instance of Metrics.
+func NewMetrics() *Metrics {
+	metrics := &Metrics{
+		agentVersion: promauto.NewGaugeVec(prometheus.GaugeOpts{
+			Namespace: "yorkie",
+			Subsystem: "agent",
+			Name:      "version",
+			Help:      "Which version is running. 1 for 'agent_version' label with current version.",
+		}, []string{"agent_version"}),
+		pushPullResponseSeconds: promauto.NewHistogram(prometheus.HistogramOpts{
+			Namespace: namespace,
+			Subsystem: "rpcserver",
+			Name:      "pushpull_response_seconds",
+			Help:      "Response time of PushPull API.",
+		}),
+		pushPullReceivedChanges: promauto.NewCounter(prometheus.CounterOpts{
+			Namespace: namespace,
+			Subsystem: "rpcserver",
+			Name:      "pushpull_received_changes",
+			Help:      "The number of changes included in a request pack in PushPull API.",
+		}),
+		pushPullSentChanges: promauto.NewCounter(prometheus.CounterOpts{
+			Namespace: namespace,
+			Subsystem: "rpcserver",
+			Name:      "pushpull_sent_changes",
+			Help:      "The number of changes included in a response pack in PushPull API.",
+		}),
+		pushPullSnapshotDurationSeconds: promauto.NewHistogram(prometheus.HistogramOpts{
+			Namespace: namespace,
+			Subsystem: "db",
+			Name:      "pushpull_snapshot_duration_seconds",
+			Help:      "The creation time of snapshot in PushPull API.",
+		}),
+		pushPullSnapshotBytes: promauto.NewGauge(prometheus.GaugeOpts{
+			Namespace: namespace,
+			Subsystem: "db",
+			Name:      "pushpull_snapshot_bytes",
+			Help:      "The number of bytes of Snapshot.",
+		}),
+	}
+
+	metrics.agentVersion.With(prometheus.Labels{
+		"agent_version": version.Version,
+	}).Set(1)
+
+	return metrics
+}
+
+// ObservePushPullResponseSeconds adds response time metrics for PushPull API.
+func (m *Metrics) ObservePushPullResponseSeconds(seconds float64) {
+	m.pushPullResponseSeconds.Observe(seconds)
+}
+
+// AddPushPullReceivedChanges adds the number of changes metric
+// included in the request pack of the PushPull API.
+func (m *Metrics) AddPushPullReceivedChanges(count int) {
+	m.pushPullReceivedChanges.Add(float64(count))
+}
+
+// AddPushPullSentChanges adds the number of changes metric
+// included in the response pack of the PushPull API.
+func (m *Metrics) AddPushPullSentChanges(count int) {
+	m.pushPullSentChanges.Add(float64(count))
+}
+
+// ObservePushPullSnapshotDurationSeconds adds the time
+// spent metric when taking snapshots.
+func (m *Metrics) ObservePushPullSnapshotDurationSeconds(seconds float64) {
+	m.pushPullSnapshotDurationSeconds.Observe(seconds)
+}
+
+// SetPushPullSnapshotBytes sets the snapshot byte size.
+func (m *Metrics) SetPushPullSnapshotBytes(bytes int) {
+	m.pushPullSnapshotBytes.Set(float64(bytes))
+}
diff --git a/yorkie/metrics/server.go b/yorkie/metrics/prometheus/server.go
similarity index 63%
rename from yorkie/metrics/server.go
rename to yorkie/metrics/prometheus/server.go
index 4528626c..ab589415 100644
--- a/yorkie/metrics/server.go
+++ b/yorkie/metrics/prometheus/server.go
@@ -1,15 +1,29 @@
-package metrics
+/*
+ * Copyright 2021 The Yorkie Authors. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package prometheus
 
 import (
 	"context"
 	"fmt"
 	"net/http"
 
-	"github.com/prometheus/client_golang/prometheus"
 	"github.com/prometheus/client_golang/prometheus/promhttp"
 
 	"github.com/yorkie-team/yorkie/pkg/log"
-	"github.com/yorkie-team/yorkie/pkg/version"
 )
 
 // Config is the configuration for creating a Server instance.
@@ -47,26 +61,8 @@ func (s *Server) listenAndServe() error {
 	return nil
 }
 
-var (
-	currentVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
-		Namespace: "yorkie",
-		Subsystem: "server",
-		Name:      "version",
-		Help:      "Which version is running. 1 for 'server_version' label with current version.",
-	}, []string{"server_version"})
-)
-
-func recordMetrics() {
-	prometheus.MustRegister(currentVersion)
-
-	currentVersion.With(prometheus.Labels{
-		"server_version": version.Version,
-	}).Set(1)
-}
-
 // Start registers application-specific metrics and starts the HTTP server.
 func (s *Server) Start() error {
-	recordMetrics()
 	return s.listenAndServe()
 }
 
@@ -76,9 +72,10 @@ func (s *Server) Shutdown(graceful bool) {
 		if err := s.metricsServer.Shutdown(context.Background()); err != nil {
 			log.Logger.Error("HTTP server Shutdown: %v", err)
 		}
-	} else {
-		if err := s.metricsServer.Close(); err != nil {
-			log.Logger.Error("HTTP server Close: %v", err)
-		}
+		return
+	}
+
+	if err := s.metricsServer.Close(); err != nil {
+		log.Logger.Error("HTTP server Close: %v", err)
 	}
 }
diff --git a/yorkie/packs/pack_service.go b/yorkie/packs/pack_service.go
index 4447f905..1aa73a12 100644
--- a/yorkie/packs/pack_service.go
+++ b/yorkie/packs/pack_service.go
@@ -223,6 +223,9 @@ func pullPack(
 	if err != nil {
 		return nil, err
 	}
+
+	be.Metrics.SetPushPullSnapshotBytes(len(snapshot))
+
 	return change.NewPack(docKey, pulledCP, nil, snapshot), err
 }
 
@@ -417,5 +420,6 @@ func storeSnapshot(
 		doc.Checkpoint().ServerSeq,
 		gotime.Since(start),
 	)
+	be.Metrics.ObservePushPullSnapshotDurationSeconds(gotime.Since(start).Seconds())
 	return nil
 }
diff --git a/yorkie/rpc/server.go b/yorkie/rpc/server.go
index 60f5ccbd..9dd24952 100644
--- a/yorkie/rpc/server.go
+++ b/yorkie/rpc/server.go
@@ -21,6 +21,7 @@ import (
 	"errors"
 	"fmt"
 	"net"
+	gotime "time"
 
 	grpcmiddleware "github.com/grpc-ecosystem/go-grpc-middleware"
 	grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
@@ -286,12 +287,15 @@ func (s *Server) PushPull(
 	ctx context.Context,
 	req *api.PushPullRequest,
 ) (*api.PushPullResponse, error) {
+	start := gotime.Now()
 	pack, err := converter.FromChangePack(req.ChangePack)
 	if err != nil {
 		return nil, toStatusError(err)
 	}
 
 	if pack.HasChanges() {
+		s.backend.Metrics.AddPushPullReceivedChanges(len(pack.Changes))
+
 		locker, err := s.backend.LockerMap.NewLocker(
 			ctx,
 			sync.NewKey(fmt.Sprintf("pushpull-%s", pack.DocumentKey.BSONKey())),
@@ -335,6 +339,9 @@ func (s *Server) PushPull(
 		return nil, toStatusError(err)
 	}
 
+	s.backend.Metrics.AddPushPullSentChanges(len(pbChangePack.Changes))
+	s.backend.Metrics.ObservePushPullResponseSeconds(gotime.Since(start).Seconds())
+
 	return &api.PushPullResponse{
 		ChangePack: pbChangePack,
 	}, nil
diff --git a/yorkie/yorkie.go b/yorkie/yorkie.go
index 3bb88748..150f424e 100644
--- a/yorkie/yorkie.go
+++ b/yorkie/yorkie.go
@@ -21,7 +21,7 @@ import (
 
 	"github.com/yorkie-team/yorkie/pkg/log"
 	"github.com/yorkie-team/yorkie/yorkie/backend"
-	"github.com/yorkie-team/yorkie/yorkie/metrics"
+	"github.com/yorkie-team/yorkie/yorkie/metrics/prometheus"
 	"github.com/yorkie-team/yorkie/yorkie/rpc"
 )
 
@@ -34,7 +34,7 @@ type Yorkie struct {
 	conf          *Config
 	backend       *backend.Backend
 	rpcServer     *rpc.Server
-	metricsServer *metrics.Server
+	metricsServer *prometheus.Server
 
 	shutdown   bool
 	shutdownCh chan struct{}
@@ -42,17 +42,21 @@ type Yorkie struct {
 
 // New creates a new instance of Yorkie.
 func New(conf *Config) (*Yorkie, error) {
-	be, err := backend.New(conf.Backend, conf.Mongo, conf.ETCD)
+	metricsServer, err := prometheus.NewServer(conf.Metrics)
 	if err != nil {
 		return nil, err
 	}
 
-	rpcServer, err := rpc.NewServer(conf.RPC, be)
+	be, err := backend.New(
+		conf.Backend,
+		conf.Mongo,
+		conf.ETCD,
+	)
 	if err != nil {
 		return nil, err
 	}
 
-	metricsServer, err := metrics.NewServer(conf.Metrics)
+	rpcServer, err := rpc.NewServer(conf.RPC, be)
 	if err != nil {
 		return nil, err
 	}


Test patch:
diff --git a/test/helper/helper.go b/test/helper/helper.go
index 1036c162..24d87b5a 100644
--- a/test/helper/helper.go
+++ b/test/helper/helper.go
@@ -29,7 +29,7 @@ import (
 	"github.com/yorkie-team/yorkie/yorkie/backend"
 	"github.com/yorkie-team/yorkie/yorkie/backend/db/mongo"
 	"github.com/yorkie-team/yorkie/yorkie/backend/sync/etcd"
-	"github.com/yorkie-team/yorkie/yorkie/metrics"
+	"github.com/yorkie-team/yorkie/yorkie/metrics/prometheus"
 	"github.com/yorkie-team/yorkie/yorkie/rpc"
 )
 
@@ -113,7 +113,7 @@ func TestYorkie() *yorkie.Yorkie {
 		RPC: &rpc.Config{
 			Port: RPCPort,
 		},
-		Metrics: &metrics.Config{
+		Metrics: &prometheus.Config{
 			Port: MetricsPort,
 		},
 		Backend: &backend.Config{
diff --git a/yorkie/metrics/prometheus/server_test.go b/yorkie/metrics/prometheus/server_test.go
new file mode 100644
index 00000000..bc1f5ff3
--- /dev/null
+++ b/yorkie/metrics/prometheus/server_test.go
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2021 The Yorkie Authors. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package prometheus_test
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+
+	"github.com/yorkie-team/yorkie/test/helper"
+	"github.com/yorkie-team/yorkie/yorkie/metrics/prometheus"
+)
+
+const (
+	// to avoid conflict with metrics port used for client test
+	testMetricsPort = helper.MetricsPort + 100
+)
+
+func TestMetricsServer(t *testing.T) {
+	t.Run("new server test", func(t *testing.T) {
+		server, err := prometheus.NewServer(&prometheus.Config{
+			Port: testMetricsPort,
+		})
+		assert.NoError(t, err)
+		assert.NotNil(t, server)
+		server.Shutdown(true)
+	})
+
+	t.Run("new server without config test", func(t *testing.T) {
+		server, err := prometheus.NewServer(nil)
+		assert.NoError(t, err)
+		assert.Nil(t, server)
+	})
+}
diff --git a/yorkie/metrics/server_test.go b/yorkie/metrics/server_test.go
deleted file mode 100644
index 3cc68a54..00000000
--- a/yorkie/metrics/server_test.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package metrics_test
-
-import (
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-
-	"github.com/yorkie-team/yorkie/test/helper"
-	"github.com/yorkie-team/yorkie/yorkie/metrics"
-)
-
-const (
-	// to avoid conflict with metrics port used for client test
-	testMetricsPort = helper.MetricsPort + 100
-)
-
-func TestMetricsServer(t *testing.T) {
-	t.Run("new server test", func(t *testing.T) {
-		server, err := metrics.NewServer(&metrics.Config{
-			Port: testMetricsPort,
-		})
-		assert.NoError(t, err)
-		assert.NotNil(t, server)
-		server.Shutdown(true)
-	})
-
-	t.Run("new server without config test", func(t *testing.T) {
-		server, err := metrics.NewServer(nil)
-		assert.NoError(t, err)
-		assert.Nil(t, server)
-	})
-}