From 890a7deae6b5565b698929b09f13372dbdf940df Mon Sep 17 00:00:00 2001
From: ensiouel <ensiouel@gmail.com>
Date: Wed, 20 Dec 2023 16:28:48 +0300
Subject: [PATCH] =?UTF-8?q?refactor:=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?=
 =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=20=D0=BC=D0=B5=D1=82=D1=80=D0=B8=D0=BA?=
 =?UTF-8?q?=D0=B0=D0=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 assets/templates/middleware/metrics           |   9 +-
 images/middleware/metrics_middleware.go       |  14 +-
 .../middleware/metrics_middleware.go          |  42 +++---
 .../middleware/metrics_middleware.go          |  56 +++++---
 .../middleware/metrics_middleware.go          |  63 +++++----
 .../middleware/metrics_middleware.go          |  42 +++---
 pkg/items/middleware/metrics_middleware.go    | 133 ++++++++++--------
 pkg/locales/middleware/metrics_middleware.go  |  28 ++--
 pkg/members/middleware/metrics_middleware.go  |  49 ++++---
 pkg/metrics/request.go                        |  30 ++--
 .../middleware/metrics_middleware.go          |  21 +--
 pkg/roles/middleware/metrics_middleware.go    |  42 +++---
 pkg/spaces/middleware/metrics_middleware.go   |  77 +++++-----
 pkg/users/middleware/metrics_middleware.go    |  49 ++++---
 14 files changed, 382 insertions(+), 273 deletions(-)

diff --git a/assets/templates/middleware/metrics b/assets/templates/middleware/metrics
index 9dd4047d..2c1a9209 100644
--- a/assets/templates/middleware/metrics
+++ b/assets/templates/middleware/metrics
@@ -9,6 +9,7 @@ import (
 
 // {{ $decorator }} implements {{ .Interface.Type }} that is instrumented with metrics
 type {{ $decorator }} struct {
+    serviceName    string
     requestMetrics *metrics.RequestMetrics
     next {{ .Interface.Type }}
 }
@@ -17,6 +18,7 @@ type {{ $decorator }} struct {
 func {{ $funcName }} (requestMetrics *metrics.RequestMetrics) Middleware {
     return func(next {{ .Interface.Type }}) {{ .Interface.Type }} {
         return &{{ $decorator }}{
+            serviceName: strings.ToLower("{{ $.Interface.Name }}"),
             requestMetrics: requestMetrics,
             next: next,
         }
@@ -26,12 +28,13 @@ func {{ $funcName }} (requestMetrics *metrics.RequestMetrics) Middleware {
 {{ range $method := .Interface.Methods }}
     // {{ $method.Name }} implements {{ $.Interface.Type }}
     func (m {{ $decorator }}) {{ $method.Declaration }} {
-        timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("{{ $method.Name }}"))
+        labels := prometheus.Labels{"service": m.serviceName, "method": "{{ $method.Name }}"}
+        timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
         defer timer.ObserveDuration()
-        m.requestMetrics.Total.WithLabelValues("{{ $method.Name }}").Inc()
+        m.requestMetrics.Total.With(labels).Inc()
         {{ $method.ResultsNames }} = m.next.{{ $method.Call }}
         if err != nil {
-            m.requestMetrics.FailedTotal.WithLabelValues("{{ $method.Name }}").Inc()
+            m.requestMetrics.FailedTotal.With(labels).Inc()
             return
         }
         return
diff --git a/images/middleware/metrics_middleware.go b/images/middleware/metrics_middleware.go
index f583718d..ffff7929 100644
--- a/images/middleware/metrics_middleware.go
+++ b/images/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../assets/templates/middleware/metrics
+// template: ..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/images -i Images -t ../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/images -i Images -t ..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/images"
 	"git.perx.ru/perxis/perxis-go/pkg/files"
@@ -17,6 +18,7 @@ import (
 
 // metricsMiddleware implements images.Images that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           images.Images
 }
@@ -25,6 +27,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next images.Images) images.Images {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Images"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -33,12 +36,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Get implements images.Images
 func (m metricsMiddleware) Get(ctx context.Context, source *files.File, opts *images.GetOptions) (result *files.File, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	result, err = m.next.Get(ctx, source, opts)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/collaborators/middleware/metrics_middleware.go b/pkg/collaborators/middleware/metrics_middleware.go
index 0e4dcc98..69597fe4 100644
--- a/pkg/collaborators/middleware/metrics_middleware.go
+++ b/pkg/collaborators/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/collaborators -i Collaborators -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/collaborators -i Collaborators -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/collaborators"
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
@@ -16,6 +17,7 @@ import (
 
 // metricsMiddleware implements collaborators.Collaborators that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           collaborators.Collaborators
 }
@@ -24,6 +26,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next collaborators.Collaborators) collaborators.Collaborators {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Collaborators"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -32,12 +35,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Get implements collaborators.Collaborators
 func (m metricsMiddleware) Get(ctx context.Context, spaceId string, subject string) (role string, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	role, err = m.next.Get(ctx, spaceId, subject)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -45,12 +49,13 @@ func (m metricsMiddleware) Get(ctx context.Context, spaceId string, subject stri
 
 // ListCollaborators implements collaborators.Collaborators
 func (m metricsMiddleware) ListCollaborators(ctx context.Context, spaceId string) (collaborators []*collaborators.Collaborator, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("ListCollaborators"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "ListCollaborators"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("ListCollaborators").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	collaborators, err = m.next.ListCollaborators(ctx, spaceId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("ListCollaborators").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -58,12 +63,13 @@ func (m metricsMiddleware) ListCollaborators(ctx context.Context, spaceId string
 
 // ListSpaces implements collaborators.Collaborators
 func (m metricsMiddleware) ListSpaces(ctx context.Context, subject string) (spaces []*collaborators.Collaborator, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("ListSpaces"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "ListSpaces"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("ListSpaces").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	spaces, err = m.next.ListSpaces(ctx, subject)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("ListSpaces").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -71,12 +77,13 @@ func (m metricsMiddleware) ListSpaces(ctx context.Context, subject string) (spac
 
 // Remove implements collaborators.Collaborators
 func (m metricsMiddleware) Remove(ctx context.Context, spaceId string, subject string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Remove"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Remove"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Remove").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Remove(ctx, spaceId, subject)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Remove").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -84,12 +91,13 @@ func (m metricsMiddleware) Remove(ctx context.Context, spaceId string, subject s
 
 // Set implements collaborators.Collaborators
 func (m metricsMiddleware) Set(ctx context.Context, spaceId string, subject string, role string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Set"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Set"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Set").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Set(ctx, spaceId, subject, role)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Set").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/collections/middleware/metrics_middleware.go b/pkg/collections/middleware/metrics_middleware.go
index 012e1127..3ebdfbd1 100644
--- a/pkg/collections/middleware/metrics_middleware.go
+++ b/pkg/collections/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/collections -i Collections -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/collections -i Collections -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/collections"
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
@@ -17,6 +18,7 @@ import (
 
 // metricsMiddleware implements collections.Collections that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           collections.Collections
 }
@@ -25,6 +27,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next collections.Collections) collections.Collections {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Collections"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -33,12 +36,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Create implements collections.Collections
 func (m metricsMiddleware) Create(ctx context.Context, collection *collections.Collection) (created *collections.Collection, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Create"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Create"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Create").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	created, err = m.next.Create(ctx, collection)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Create").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -46,12 +50,13 @@ func (m metricsMiddleware) Create(ctx context.Context, collection *collections.C
 
 // Delete implements collections.Collections
 func (m metricsMiddleware) Delete(ctx context.Context, spaceId string, envId string, collectionId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Delete"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Delete"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Delete").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Delete(ctx, spaceId, envId, collectionId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Delete").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -59,12 +64,13 @@ func (m metricsMiddleware) Delete(ctx context.Context, spaceId string, envId str
 
 // Get implements collections.Collections
 func (m metricsMiddleware) Get(ctx context.Context, spaceId string, envId string, collectionId string, options ...*collections.GetOptions) (collection *collections.Collection, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	collection, err = m.next.Get(ctx, spaceId, envId, collectionId, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -72,12 +78,13 @@ func (m metricsMiddleware) Get(ctx context.Context, spaceId string, envId string
 
 // List implements collections.Collections
 func (m metricsMiddleware) List(ctx context.Context, spaceId string, envId string, filter *collections.Filter) (collections []*collections.Collection, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("List"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "List"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("List").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	collections, err = m.next.List(ctx, spaceId, envId, filter)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("List").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -85,12 +92,13 @@ func (m metricsMiddleware) List(ctx context.Context, spaceId string, envId strin
 
 // SetSchema implements collections.Collections
 func (m metricsMiddleware) SetSchema(ctx context.Context, spaceId string, envId string, collectionId string, schema *schema.Schema) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("SetSchema"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "SetSchema"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("SetSchema").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.SetSchema(ctx, spaceId, envId, collectionId, schema)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("SetSchema").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -98,12 +106,13 @@ func (m metricsMiddleware) SetSchema(ctx context.Context, spaceId string, envId
 
 // SetState implements collections.Collections
 func (m metricsMiddleware) SetState(ctx context.Context, spaceId string, envId string, collectionId string, state *collections.StateInfo) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("SetState"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "SetState"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("SetState").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.SetState(ctx, spaceId, envId, collectionId, state)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("SetState").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -111,12 +120,13 @@ func (m metricsMiddleware) SetState(ctx context.Context, spaceId string, envId s
 
 // Update implements collections.Collections
 func (m metricsMiddleware) Update(ctx context.Context, coll *collections.Collection) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Update"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Update"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Update").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Update(ctx, coll)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Update").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/environments/middleware/metrics_middleware.go b/pkg/environments/middleware/metrics_middleware.go
index 3f4723b6..5501ac3c 100644
--- a/pkg/environments/middleware/metrics_middleware.go
+++ b/pkg/environments/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/environments -i Environments -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/environments -i Environments -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/environments"
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
@@ -16,6 +17,7 @@ import (
 
 // metricsMiddleware implements environments.Environments that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           environments.Environments
 }
@@ -24,6 +26,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next environments.Environments) environments.Environments {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Environments"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -32,12 +35,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Create implements environments.Environments
 func (m metricsMiddleware) Create(ctx context.Context, env *environments.Environment) (created *environments.Environment, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Create"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Create"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Create").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	created, err = m.next.Create(ctx, env)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Create").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -45,12 +49,13 @@ func (m metricsMiddleware) Create(ctx context.Context, env *environments.Environ
 
 // Delete implements environments.Environments
 func (m metricsMiddleware) Delete(ctx context.Context, spaceId string, envId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Delete"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Delete"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Delete").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Delete(ctx, spaceId, envId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Delete").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -58,12 +63,13 @@ func (m metricsMiddleware) Delete(ctx context.Context, spaceId string, envId str
 
 // Get implements environments.Environments
 func (m metricsMiddleware) Get(ctx context.Context, spaceId string, envId string) (env *environments.Environment, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	env, err = m.next.Get(ctx, spaceId, envId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -71,12 +77,13 @@ func (m metricsMiddleware) Get(ctx context.Context, spaceId string, envId string
 
 // List implements environments.Environments
 func (m metricsMiddleware) List(ctx context.Context, spaceId string) (envs []*environments.Environment, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("List"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "List"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("List").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	envs, err = m.next.List(ctx, spaceId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("List").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -84,12 +91,13 @@ func (m metricsMiddleware) List(ctx context.Context, spaceId string) (envs []*en
 
 // Migrate implements environments.Environments
 func (m metricsMiddleware) Migrate(ctx context.Context, spaceId string, envId string, options ...*environments.MigrateOptions) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Migrate"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Migrate"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Migrate").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Migrate(ctx, spaceId, envId, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Migrate").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -97,12 +105,13 @@ func (m metricsMiddleware) Migrate(ctx context.Context, spaceId string, envId st
 
 // RemoveAlias implements environments.Environments
 func (m metricsMiddleware) RemoveAlias(ctx context.Context, spaceId string, envId string, alias string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("RemoveAlias"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "RemoveAlias"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("RemoveAlias").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.RemoveAlias(ctx, spaceId, envId, alias)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("RemoveAlias").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -110,12 +119,13 @@ func (m metricsMiddleware) RemoveAlias(ctx context.Context, spaceId string, envI
 
 // SetAlias implements environments.Environments
 func (m metricsMiddleware) SetAlias(ctx context.Context, spaceId string, envId string, alias string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("SetAlias"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "SetAlias"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("SetAlias").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.SetAlias(ctx, spaceId, envId, alias)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("SetAlias").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -123,12 +133,13 @@ func (m metricsMiddleware) SetAlias(ctx context.Context, spaceId string, envId s
 
 // Update implements environments.Environments
 func (m metricsMiddleware) Update(ctx context.Context, env *environments.Environment) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Update"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Update"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Update").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Update(ctx, env)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Update").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/invitations/middleware/metrics_middleware.go b/pkg/invitations/middleware/metrics_middleware.go
index ac82571e..9bc85e88 100644
--- a/pkg/invitations/middleware/metrics_middleware.go
+++ b/pkg/invitations/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/invitations -i Invitations -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/invitations -i Invitations -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/invitations"
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
@@ -17,6 +18,7 @@ import (
 
 // metricsMiddleware implements invitations.Invitations that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           invitations.Invitations
 }
@@ -25,6 +27,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next invitations.Invitations) invitations.Invitations {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Invitations"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -33,12 +36,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Accept implements invitations.Invitations
 func (m metricsMiddleware) Accept(ctx context.Context, invitationId string, userId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Accept"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Accept"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Accept").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Accept(ctx, invitationId, userId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Accept").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -46,12 +50,13 @@ func (m metricsMiddleware) Accept(ctx context.Context, invitationId string, user
 
 // Create implements invitations.Invitations
 func (m metricsMiddleware) Create(ctx context.Context, invitation *invitations.Invitation) (created *invitations.Invitation, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Create"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Create"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Create").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	created, err = m.next.Create(ctx, invitation)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Create").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -59,12 +64,13 @@ func (m metricsMiddleware) Create(ctx context.Context, invitation *invitations.I
 
 // Delete implements invitations.Invitations
 func (m metricsMiddleware) Delete(ctx context.Context, invitationId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Delete"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Delete"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Delete").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Delete(ctx, invitationId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Delete").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -72,12 +78,13 @@ func (m metricsMiddleware) Delete(ctx context.Context, invitationId string) (err
 
 // Find implements invitations.Invitations
 func (m metricsMiddleware) Find(ctx context.Context, filter *invitations.Filter, opts *options.FindOptions) (invitations []*invitations.Invitation, total int, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Find"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Find"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Find").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	invitations, total, err = m.next.Find(ctx, filter, opts)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Find").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -85,12 +92,13 @@ func (m metricsMiddleware) Find(ctx context.Context, filter *invitations.Filter,
 
 // Get implements invitations.Invitations
 func (m metricsMiddleware) Get(ctx context.Context, invitationId string) (invitation *invitations.Invitation, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	invitation, err = m.next.Get(ctx, invitationId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/items/middleware/metrics_middleware.go b/pkg/items/middleware/metrics_middleware.go
index a9f7b8f9..913a0df8 100644
--- a/pkg/items/middleware/metrics_middleware.go
+++ b/pkg/items/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/items -i Items -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/items -i Items -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/items"
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
@@ -17,6 +18,7 @@ import (
 
 // metricsMiddleware implements items.Items that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           items.Items
 }
@@ -25,6 +27,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next items.Items) items.Items {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Items"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -33,12 +36,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Aggregate implements items.Items
 func (m metricsMiddleware) Aggregate(ctx context.Context, spaceId string, envId string, collectionId string, filter *items.Filter, options ...*items.AggregateOptions) (result map[string]interface{}, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Aggregate"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Aggregate"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Aggregate").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	result, err = m.next.Aggregate(ctx, spaceId, envId, collectionId, filter, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Aggregate").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -46,12 +50,13 @@ func (m metricsMiddleware) Aggregate(ctx context.Context, spaceId string, envId
 
 // AggregatePublished implements items.Items
 func (m metricsMiddleware) AggregatePublished(ctx context.Context, spaceId string, envId string, collectionId string, filter *items.Filter, options ...*items.AggregatePublishedOptions) (result map[string]interface{}, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("AggregatePublished"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "AggregatePublished"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("AggregatePublished").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	result, err = m.next.AggregatePublished(ctx, spaceId, envId, collectionId, filter, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("AggregatePublished").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -59,12 +64,13 @@ func (m metricsMiddleware) AggregatePublished(ctx context.Context, spaceId strin
 
 // Archive implements items.Items
 func (m metricsMiddleware) Archive(ctx context.Context, item *items.Item, options ...*items.ArchiveOptions) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Archive"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Archive"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Archive").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Archive(ctx, item, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Archive").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -72,12 +78,13 @@ func (m metricsMiddleware) Archive(ctx context.Context, item *items.Item, option
 
 // Create implements items.Items
 func (m metricsMiddleware) Create(ctx context.Context, item *items.Item, opts ...*items.CreateOptions) (created *items.Item, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Create"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Create"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Create").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	created, err = m.next.Create(ctx, item, opts...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Create").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -85,12 +92,13 @@ func (m metricsMiddleware) Create(ctx context.Context, item *items.Item, opts ..
 
 // Delete implements items.Items
 func (m metricsMiddleware) Delete(ctx context.Context, item *items.Item, options ...*items.DeleteOptions) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Delete"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Delete"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Delete").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Delete(ctx, item, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Delete").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -98,12 +106,13 @@ func (m metricsMiddleware) Delete(ctx context.Context, item *items.Item, options
 
 // Find implements items.Items
 func (m metricsMiddleware) Find(ctx context.Context, spaceId string, envId string, collectionId string, filter *items.Filter, options ...*items.FindOptions) (items []*items.Item, total int, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Find"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Find"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Find").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	items, total, err = m.next.Find(ctx, spaceId, envId, collectionId, filter, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Find").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -111,12 +120,13 @@ func (m metricsMiddleware) Find(ctx context.Context, spaceId string, envId strin
 
 // FindArchived implements items.Items
 func (m metricsMiddleware) FindArchived(ctx context.Context, spaceId string, envId string, collectionId string, filter *items.Filter, options ...*items.FindArchivedOptions) (items []*items.Item, total int, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("FindArchived"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "FindArchived"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("FindArchived").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	items, total, err = m.next.FindArchived(ctx, spaceId, envId, collectionId, filter, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("FindArchived").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -124,12 +134,13 @@ func (m metricsMiddleware) FindArchived(ctx context.Context, spaceId string, env
 
 // FindPublished implements items.Items
 func (m metricsMiddleware) FindPublished(ctx context.Context, spaceId string, envId string, collectionId string, filter *items.Filter, options ...*items.FindPublishedOptions) (items []*items.Item, total int, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("FindPublished"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "FindPublished"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("FindPublished").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	items, total, err = m.next.FindPublished(ctx, spaceId, envId, collectionId, filter, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("FindPublished").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -137,12 +148,13 @@ func (m metricsMiddleware) FindPublished(ctx context.Context, spaceId string, en
 
 // Get implements items.Items
 func (m metricsMiddleware) Get(ctx context.Context, spaceId string, envId string, collectionId string, itemId string, options ...*items.GetOptions) (item *items.Item, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	item, err = m.next.Get(ctx, spaceId, envId, collectionId, itemId, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -150,12 +162,13 @@ func (m metricsMiddleware) Get(ctx context.Context, spaceId string, envId string
 
 // GetPublished implements items.Items
 func (m metricsMiddleware) GetPublished(ctx context.Context, spaceId string, envId string, collectionId string, itemId string, options ...*items.GetPublishedOptions) (item *items.Item, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("GetPublished"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "GetPublished"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("GetPublished").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	item, err = m.next.GetPublished(ctx, spaceId, envId, collectionId, itemId, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("GetPublished").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -163,12 +176,13 @@ func (m metricsMiddleware) GetPublished(ctx context.Context, spaceId string, env
 
 // GetRevision implements items.Items
 func (m metricsMiddleware) GetRevision(ctx context.Context, spaceId string, envId string, collectionId string, itemId string, revisionId string, options ...*items.GetRevisionOptions) (item *items.Item, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("GetRevision"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "GetRevision"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("GetRevision").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	item, err = m.next.GetRevision(ctx, spaceId, envId, collectionId, itemId, revisionId, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("GetRevision").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -176,12 +190,13 @@ func (m metricsMiddleware) GetRevision(ctx context.Context, spaceId string, envI
 
 // Introspect implements items.Items
 func (m metricsMiddleware) Introspect(ctx context.Context, item *items.Item, opts ...*items.IntrospectOptions) (itm *items.Item, sch *schema.Schema, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Introspect"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Introspect"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Introspect").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	itm, sch, err = m.next.Introspect(ctx, item, opts...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Introspect").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -189,12 +204,13 @@ func (m metricsMiddleware) Introspect(ctx context.Context, item *items.Item, opt
 
 // ListRevisions implements items.Items
 func (m metricsMiddleware) ListRevisions(ctx context.Context, spaceId string, envId string, collectionId string, itemId string, options ...*items.ListRevisionsOptions) (items []*items.Item, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("ListRevisions"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "ListRevisions"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("ListRevisions").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	items, err = m.next.ListRevisions(ctx, spaceId, envId, collectionId, itemId, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("ListRevisions").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -202,12 +218,13 @@ func (m metricsMiddleware) ListRevisions(ctx context.Context, spaceId string, en
 
 // Publish implements items.Items
 func (m metricsMiddleware) Publish(ctx context.Context, item *items.Item, options ...*items.PublishOptions) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Publish"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Publish"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Publish").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Publish(ctx, item, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Publish").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -215,12 +232,13 @@ func (m metricsMiddleware) Publish(ctx context.Context, item *items.Item, option
 
 // Unarchive implements items.Items
 func (m metricsMiddleware) Unarchive(ctx context.Context, item *items.Item, options ...*items.UnarchiveOptions) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Unarchive"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Unarchive"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Unarchive").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Unarchive(ctx, item, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Unarchive").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -228,12 +246,13 @@ func (m metricsMiddleware) Unarchive(ctx context.Context, item *items.Item, opti
 
 // Undelete implements items.Items
 func (m metricsMiddleware) Undelete(ctx context.Context, item *items.Item, options ...*items.UndeleteOptions) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Undelete"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Undelete"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Undelete").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Undelete(ctx, item, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Undelete").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -241,12 +260,13 @@ func (m metricsMiddleware) Undelete(ctx context.Context, item *items.Item, optio
 
 // Unpublish implements items.Items
 func (m metricsMiddleware) Unpublish(ctx context.Context, item *items.Item, options ...*items.UnpublishOptions) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Unpublish"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Unpublish"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Unpublish").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Unpublish(ctx, item, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Unpublish").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -254,12 +274,13 @@ func (m metricsMiddleware) Unpublish(ctx context.Context, item *items.Item, opti
 
 // Update implements items.Items
 func (m metricsMiddleware) Update(ctx context.Context, item *items.Item, options ...*items.UpdateOptions) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Update"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Update"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Update").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Update(ctx, item, options...)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Update").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/locales/middleware/metrics_middleware.go b/pkg/locales/middleware/metrics_middleware.go
index a8296a4c..3868740a 100644
--- a/pkg/locales/middleware/metrics_middleware.go
+++ b/pkg/locales/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/locales -i Locales -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/locales -i Locales -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/locales"
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
@@ -16,6 +17,7 @@ import (
 
 // metricsMiddleware implements locales.Locales that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           locales.Locales
 }
@@ -24,6 +26,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next locales.Locales) locales.Locales {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Locales"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -32,12 +35,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Create implements locales.Locales
 func (m metricsMiddleware) Create(ctx context.Context, locale *locales.Locale) (created *locales.Locale, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Create"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Create"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Create").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	created, err = m.next.Create(ctx, locale)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Create").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -45,12 +49,13 @@ func (m metricsMiddleware) Create(ctx context.Context, locale *locales.Locale) (
 
 // Delete implements locales.Locales
 func (m metricsMiddleware) Delete(ctx context.Context, spaceId string, localeId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Delete"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Delete"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Delete").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Delete(ctx, spaceId, localeId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Delete").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -58,12 +63,13 @@ func (m metricsMiddleware) Delete(ctx context.Context, spaceId string, localeId
 
 // List implements locales.Locales
 func (m metricsMiddleware) List(ctx context.Context, spaceId string) (locales []*locales.Locale, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("List"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "List"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("List").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	locales, err = m.next.List(ctx, spaceId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("List").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/members/middleware/metrics_middleware.go b/pkg/members/middleware/metrics_middleware.go
index 8e947287..6ece219d 100644
--- a/pkg/members/middleware/metrics_middleware.go
+++ b/pkg/members/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/members -i Members -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/members -i Members -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/members"
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
@@ -16,6 +17,7 @@ import (
 
 // metricsMiddleware implements members.Members that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           members.Members
 }
@@ -24,6 +26,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next members.Members) members.Members {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Members"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -32,12 +35,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Get implements members.Members
 func (m metricsMiddleware) Get(ctx context.Context, orgId string, userId string) (role members.Role, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	role, err = m.next.Get(ctx, orgId, userId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -45,12 +49,13 @@ func (m metricsMiddleware) Get(ctx context.Context, orgId string, userId string)
 
 // ListMembers implements members.Members
 func (m metricsMiddleware) ListMembers(ctx context.Context, orgId string) (members []*members.Member, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("ListMembers"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "ListMembers"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("ListMembers").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	members, err = m.next.ListMembers(ctx, orgId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("ListMembers").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -58,12 +63,13 @@ func (m metricsMiddleware) ListMembers(ctx context.Context, orgId string) (membe
 
 // ListOrganizations implements members.Members
 func (m metricsMiddleware) ListOrganizations(ctx context.Context, userId string) (organizations []*members.Member, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("ListOrganizations"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "ListOrganizations"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("ListOrganizations").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	organizations, err = m.next.ListOrganizations(ctx, userId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("ListOrganizations").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -71,12 +77,13 @@ func (m metricsMiddleware) ListOrganizations(ctx context.Context, userId string)
 
 // Remove implements members.Members
 func (m metricsMiddleware) Remove(ctx context.Context, orgId string, userId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Remove"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Remove"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Remove").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Remove(ctx, orgId, userId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Remove").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -84,12 +91,13 @@ func (m metricsMiddleware) Remove(ctx context.Context, orgId string, userId stri
 
 // RemoveAll implements members.Members
 func (m metricsMiddleware) RemoveAll(ctx context.Context, orgId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("RemoveAll"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "RemoveAll"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("RemoveAll").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.RemoveAll(ctx, orgId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("RemoveAll").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -97,12 +105,13 @@ func (m metricsMiddleware) RemoveAll(ctx context.Context, orgId string) (err err
 
 // Set implements members.Members
 func (m metricsMiddleware) Set(ctx context.Context, orgId string, userId string, role members.Role) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Set"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Set"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Set").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Set(ctx, orgId, userId, role)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Set").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/metrics/request.go b/pkg/metrics/request.go
index 4c5ff719..d172aba3 100644
--- a/pkg/metrics/request.go
+++ b/pkg/metrics/request.go
@@ -11,37 +11,31 @@ type RequestMetrics struct {
 }
 
 // NewRequestMetrics возвращает метрики для подсчета количества удачных/неудачных запросов, а так же длительности ответов.
-//
-// subsystem указывает подсистему, к которой принадлежат метрики.
-// Значение должно быть уникальным, совпадение разрешено только при совпадении ключей labels. Пустое значение допустимо.
-//
-// labels - список меток, где каждый элемент метки соответствует парам ключ-значение. Отсутствие допустимо.
-// Значения меток должны быть уникальными в рамках одной subsystem.
-//
 // Метрики записываются в prometheus.DefaultRegisterer
-func NewRequestMetrics(subsystem string, durationBuckets []float64, labels ...string) *RequestMetrics {
-	if len(durationBuckets) == 0 {
-		durationBuckets = prometheus.DefBuckets
+func NewRequestMetrics(subsystem string) *RequestMetrics {
+	requestLabelNames := []string{
+		"service",
+		"method",
 	}
 	metrics := &RequestMetrics{
 		Total: prometheus.NewCounterVec(prometheus.CounterOpts{
 			Subsystem: subsystem,
-			Name:      "service_requests_total",
+			Name:      "requests_total",
 			Help:      "Количество запросов.",
-		}, []string{"method"}),
+		}, requestLabelNames),
 		FailedTotal: prometheus.NewCounterVec(prometheus.CounterOpts{
 			Subsystem: subsystem,
-			Name:      "service_requests_failed_total",
+			Name:      "requests_failed_total",
 			Help:      "Количество запросов, вернувших ошибку.",
-		}, []string{"method"}),
+		}, requestLabelNames),
 		DurationSeconds: prometheus.NewHistogramVec(prometheus.HistogramOpts{
 			Subsystem: subsystem,
-			Name:      "service_request_duration_seconds",
+			Name:      "request_duration_seconds",
 			Help:      "Длительность обработки запроса.",
-			Buckets:   durationBuckets,
-		}, []string{"method"}),
+			Buckets:   prometheus.DefBuckets,
+		}, requestLabelNames),
 	}
-	prometheus.WrapRegistererWith(GetLabelsFromKV(labels), prometheus.DefaultRegisterer).MustRegister(
+	prometheus.MustRegister(
 		metrics.Total,
 		metrics.FailedTotal,
 		metrics.DurationSeconds,
diff --git a/pkg/references/middleware/metrics_middleware.go b/pkg/references/middleware/metrics_middleware.go
index 520dd768..224b2ecd 100644
--- a/pkg/references/middleware/metrics_middleware.go
+++ b/pkg/references/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/references -i References -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/items"
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
@@ -17,6 +18,7 @@ import (
 
 // metricsMiddleware implements references.References that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           references.References
 }
@@ -25,6 +27,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next references.References) references.References {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("References"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -33,12 +36,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Get implements references.References
 func (m metricsMiddleware) Get(ctx context.Context, spaceId string, envId string, references []*references.Reference) (items []*items.Item, notfound []*references.Reference, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	items, notfound, err = m.next.Get(ctx, spaceId, envId, references)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -46,12 +50,13 @@ func (m metricsMiddleware) Get(ctx context.Context, spaceId string, envId string
 
 // Publish implements references.References
 func (m metricsMiddleware) Publish(ctx context.Context, spaceId string, envId string, references []*references.Reference, recursive bool, force bool) (published []*references.Reference, notfound []*references.Reference, unpublished []*references.Reference, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Publish"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Publish"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Publish").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	published, notfound, unpublished, err = m.next.Publish(ctx, spaceId, envId, references, recursive, force)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Publish").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/roles/middleware/metrics_middleware.go b/pkg/roles/middleware/metrics_middleware.go
index 75e242ef..204df624 100644
--- a/pkg/roles/middleware/metrics_middleware.go
+++ b/pkg/roles/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/roles -i Roles -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/roles -i Roles -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
 	"git.perx.ru/perxis/perxis-go/pkg/roles"
@@ -16,6 +17,7 @@ import (
 
 // metricsMiddleware implements roles.Roles that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           roles.Roles
 }
@@ -24,6 +26,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next roles.Roles) roles.Roles {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Roles"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -32,12 +35,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Create implements roles.Roles
 func (m metricsMiddleware) Create(ctx context.Context, role *roles.Role) (created *roles.Role, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Create"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Create"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Create").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	created, err = m.next.Create(ctx, role)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Create").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -45,12 +49,13 @@ func (m metricsMiddleware) Create(ctx context.Context, role *roles.Role) (create
 
 // Delete implements roles.Roles
 func (m metricsMiddleware) Delete(ctx context.Context, spaceId string, roleId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Delete"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Delete"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Delete").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Delete(ctx, spaceId, roleId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Delete").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -58,12 +63,13 @@ func (m metricsMiddleware) Delete(ctx context.Context, spaceId string, roleId st
 
 // Get implements roles.Roles
 func (m metricsMiddleware) Get(ctx context.Context, spaceId string, roleId string) (role *roles.Role, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	role, err = m.next.Get(ctx, spaceId, roleId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -71,12 +77,13 @@ func (m metricsMiddleware) Get(ctx context.Context, spaceId string, roleId strin
 
 // List implements roles.Roles
 func (m metricsMiddleware) List(ctx context.Context, spaceId string) (roles []*roles.Role, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("List"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "List"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("List").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	roles, err = m.next.List(ctx, spaceId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("List").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -84,12 +91,13 @@ func (m metricsMiddleware) List(ctx context.Context, spaceId string) (roles []*r
 
 // Update implements roles.Roles
 func (m metricsMiddleware) Update(ctx context.Context, role *roles.Role) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Update"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Update"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Update").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Update(ctx, role)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Update").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/spaces/middleware/metrics_middleware.go b/pkg/spaces/middleware/metrics_middleware.go
index df81e592..6424331a 100644
--- a/pkg/spaces/middleware/metrics_middleware.go
+++ b/pkg/spaces/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/spaces -i Spaces -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/spaces -i Spaces -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
 	"git.perx.ru/perxis/perxis-go/pkg/spaces"
@@ -16,6 +17,7 @@ import (
 
 // metricsMiddleware implements spaces.Spaces that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           spaces.Spaces
 }
@@ -24,6 +26,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next spaces.Spaces) spaces.Spaces {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Spaces"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -32,12 +35,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // AbortTransfer implements spaces.Spaces
 func (m metricsMiddleware) AbortTransfer(ctx context.Context, spaceID string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("AbortTransfer"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "AbortTransfer"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("AbortTransfer").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.AbortTransfer(ctx, spaceID)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("AbortTransfer").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -45,12 +49,13 @@ func (m metricsMiddleware) AbortTransfer(ctx context.Context, spaceID string) (e
 
 // Create implements spaces.Spaces
 func (m metricsMiddleware) Create(ctx context.Context, space *spaces.Space) (created *spaces.Space, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Create"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Create"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Create").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	created, err = m.next.Create(ctx, space)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Create").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -58,12 +63,13 @@ func (m metricsMiddleware) Create(ctx context.Context, space *spaces.Space) (cre
 
 // Delete implements spaces.Spaces
 func (m metricsMiddleware) Delete(ctx context.Context, spaceId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Delete"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Delete"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Delete").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Delete(ctx, spaceId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Delete").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -71,12 +77,13 @@ func (m metricsMiddleware) Delete(ctx context.Context, spaceId string) (err erro
 
 // Get implements spaces.Spaces
 func (m metricsMiddleware) Get(ctx context.Context, spaceId string) (space *spaces.Space, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	space, err = m.next.Get(ctx, spaceId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -84,12 +91,13 @@ func (m metricsMiddleware) Get(ctx context.Context, spaceId string) (space *spac
 
 // List implements spaces.Spaces
 func (m metricsMiddleware) List(ctx context.Context, orgId string) (spaces []*spaces.Space, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("List"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "List"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("List").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	spaces, err = m.next.List(ctx, orgId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("List").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -97,12 +105,13 @@ func (m metricsMiddleware) List(ctx context.Context, orgId string) (spaces []*sp
 
 // ListTransfers implements spaces.Spaces
 func (m metricsMiddleware) ListTransfers(ctx context.Context, orgID string) (spaces []*spaces.Space, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("ListTransfers"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "ListTransfers"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("ListTransfers").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	spaces, err = m.next.ListTransfers(ctx, orgID)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("ListTransfers").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -110,12 +119,13 @@ func (m metricsMiddleware) ListTransfers(ctx context.Context, orgID string) (spa
 
 // Move implements spaces.Spaces
 func (m metricsMiddleware) Move(ctx context.Context, spaceID string, orgID string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Move"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Move"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Move").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Move(ctx, spaceID, orgID)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Move").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -123,12 +133,13 @@ func (m metricsMiddleware) Move(ctx context.Context, spaceID string, orgID strin
 
 // Transfer implements spaces.Spaces
 func (m metricsMiddleware) Transfer(ctx context.Context, spaceID string, transferToOrg string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Transfer"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Transfer"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Transfer").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Transfer(ctx, spaceID, transferToOrg)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Transfer").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -136,12 +147,13 @@ func (m metricsMiddleware) Transfer(ctx context.Context, spaceID string, transfe
 
 // Update implements spaces.Spaces
 func (m metricsMiddleware) Update(ctx context.Context, space *spaces.Space) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Update"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Update"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Update").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Update(ctx, space)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Update").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -149,12 +161,13 @@ func (m metricsMiddleware) Update(ctx context.Context, space *spaces.Space) (err
 
 // UpdateConfig implements spaces.Spaces
 func (m metricsMiddleware) UpdateConfig(ctx context.Context, spaceId string, config *spaces.Config) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("UpdateConfig"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "UpdateConfig"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("UpdateConfig").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.UpdateConfig(ctx, spaceId, config)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("UpdateConfig").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
diff --git a/pkg/users/middleware/metrics_middleware.go b/pkg/users/middleware/metrics_middleware.go
index f1aa52ff..860a3da8 100644
--- a/pkg/users/middleware/metrics_middleware.go
+++ b/pkg/users/middleware/metrics_middleware.go
@@ -1,13 +1,14 @@
 // Code generated by gowrap. DO NOT EDIT.
-// template: ../../../assets/templates/middleware/metrics
+// template: ..\..\..\assets\templates\middleware\metrics
 // gowrap: http://github.com/hexdigest/gowrap
 
 package middleware
 
-//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/users -i Users -t ../../../assets/templates/middleware/metrics -o metrics_middleware.go -l ""
+//go:generate gowrap gen -p git.perx.ru/perxis/perxis-go/pkg/users -i Users -t ..\..\..\assets\templates\middleware\metrics -o metrics_middleware.go -l ""
 
 import (
 	"context"
+	"strings"
 
 	"git.perx.ru/perxis/perxis-go/pkg/metrics"
 	"git.perx.ru/perxis/perxis-go/pkg/options"
@@ -17,6 +18,7 @@ import (
 
 // metricsMiddleware implements users.Users that is instrumented with metrics
 type metricsMiddleware struct {
+	serviceName    string
 	requestMetrics *metrics.RequestMetrics
 	next           users.Users
 }
@@ -25,6 +27,7 @@ type metricsMiddleware struct {
 func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 	return func(next users.Users) users.Users {
 		return &metricsMiddleware{
+			serviceName:    strings.ToLower("Users"),
 			requestMetrics: requestMetrics,
 			next:           next,
 		}
@@ -33,12 +36,13 @@ func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware {
 
 // Create implements users.Users
 func (m metricsMiddleware) Create(ctx context.Context, create *users.User) (user *users.User, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Create"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Create"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Create").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	user, err = m.next.Create(ctx, create)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Create").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -46,12 +50,13 @@ func (m metricsMiddleware) Create(ctx context.Context, create *users.User) (user
 
 // Delete implements users.Users
 func (m metricsMiddleware) Delete(ctx context.Context, userId string) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Delete"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Delete"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Delete").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Delete(ctx, userId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Delete").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -59,12 +64,13 @@ func (m metricsMiddleware) Delete(ctx context.Context, userId string) (err error
 
 // Find implements users.Users
 func (m metricsMiddleware) Find(ctx context.Context, filter *users.Filter, options *options.FindOptions) (users []*users.User, total int, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Find"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Find"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Find").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	users, total, err = m.next.Find(ctx, filter, options)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Find").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -72,12 +78,13 @@ func (m metricsMiddleware) Find(ctx context.Context, filter *users.Filter, optio
 
 // Get implements users.Users
 func (m metricsMiddleware) Get(ctx context.Context, userId string) (user *users.User, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Get"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Get"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Get").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	user, err = m.next.Get(ctx, userId)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Get").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -85,12 +92,13 @@ func (m metricsMiddleware) Get(ctx context.Context, userId string) (user *users.
 
 // GetByIdentity implements users.Users
 func (m metricsMiddleware) GetByIdentity(ctx context.Context, identity string) (user *users.User, err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("GetByIdentity"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "GetByIdentity"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("GetByIdentity").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	user, err = m.next.GetByIdentity(ctx, identity)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("GetByIdentity").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
@@ -98,12 +106,13 @@ func (m metricsMiddleware) GetByIdentity(ctx context.Context, identity string) (
 
 // Update implements users.Users
 func (m metricsMiddleware) Update(ctx context.Context, update *users.User) (err error) {
-	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.WithLabelValues("Update"))
+	labels := prometheus.Labels{"service": m.serviceName, "method": "Update"}
+	timer := prometheus.NewTimer(m.requestMetrics.DurationSeconds.With(labels))
 	defer timer.ObserveDuration()
-	m.requestMetrics.Total.WithLabelValues("Update").Inc()
+	m.requestMetrics.Total.With(labels).Inc()
 	err = m.next.Update(ctx, update)
 	if err != nil {
-		m.requestMetrics.FailedTotal.WithLabelValues("Update").Inc()
+		m.requestMetrics.FailedTotal.With(labels).Inc()
 		return
 	}
 	return
-- 
GitLab