From 5662db2ec86c8538a71b3927bdb324b43ff29cb4 Mon Sep 17 00:00:00 2001 From: ensiouel <ensiouel@gmail.com> Date: Sun, 17 Dec 2023 18:00:45 +0300 Subject: [PATCH] =?UTF-8?q?fix=20gen:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=83=D1=8E=20=D0=BC=D0=B5=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/templates/middleware/metrics | 2 +- pkg/items/middleware/metrics_middleware.go | 38 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/assets/templates/middleware/metrics b/assets/templates/middleware/metrics index f55ffd51..7497a9db 100644 --- a/assets/templates/middleware/metrics +++ b/assets/templates/middleware/metrics @@ -31,7 +31,7 @@ func {{ $funcName }} (requestMetrics *metrics.RequestMetrics) Middleware { timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("{{ $.Interface.Name }}", "{{ $method.Name }}").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("{{ $.Interface.Name }}", "{{ $method.Name }}").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("{{ $.Interface.Name }}", "{{ $method.Name }}", "???").Inc() } }() {{ $method.Pass "m.next." }} diff --git a/pkg/items/middleware/metrics_middleware.go b/pkg/items/middleware/metrics_middleware.go index e9eef317..91f61c04 100644 --- a/pkg/items/middleware/metrics_middleware.go +++ b/pkg/items/middleware/metrics_middleware.go @@ -21,7 +21,7 @@ type metricsMiddleware struct { next items.Items } -// MetricsMiddleware instruments an implementation of the items.Items with metrics +// MetricsMiddleware instruments an implementation of the metricsMiddleware with metrics func MetricsMiddleware(requestMetrics *metrics.RequestMetrics) Middleware { return func(next items.Items) items.Items { return &metricsMiddleware{ @@ -38,7 +38,7 @@ func (m metricsMiddleware) Aggregate(ctx context.Context, spaceId string, envId timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Aggregate").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Aggregate").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Aggregate", "???").Inc() } }() return m.next.Aggregate(ctx, spaceId, envId, collectionId, filter, options...) @@ -51,7 +51,7 @@ func (m metricsMiddleware) AggregatePublished(ctx context.Context, spaceId strin timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "AggregatePublished").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "AggregatePublished").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "AggregatePublished", "???").Inc() } }() return m.next.AggregatePublished(ctx, spaceId, envId, collectionId, filter, options...) @@ -64,7 +64,7 @@ func (m metricsMiddleware) Archive(ctx context.Context, item *items.Item, option timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Archive").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Archive").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Archive", "???").Inc() } }() return m.next.Archive(ctx, item, options...) @@ -77,7 +77,7 @@ func (m metricsMiddleware) Create(ctx context.Context, item *items.Item, opts .. timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Create").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Create").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Create", "???").Inc() } }() return m.next.Create(ctx, item, opts...) @@ -90,7 +90,7 @@ func (m metricsMiddleware) Delete(ctx context.Context, item *items.Item, options timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Delete").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Delete").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Delete", "???").Inc() } }() return m.next.Delete(ctx, item, options...) @@ -103,7 +103,7 @@ func (m metricsMiddleware) Find(ctx context.Context, spaceId string, envId strin timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Find").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Find").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Find", "???").Inc() } }() return m.next.Find(ctx, spaceId, envId, collectionId, filter, options...) @@ -116,7 +116,7 @@ func (m metricsMiddleware) FindArchived(ctx context.Context, spaceId string, env timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "FindArchived").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "FindArchived").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "FindArchived", "???").Inc() } }() return m.next.FindArchived(ctx, spaceId, envId, collectionId, filter, options...) @@ -129,7 +129,7 @@ func (m metricsMiddleware) FindPublished(ctx context.Context, spaceId string, en timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "FindPublished").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "FindPublished").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "FindPublished", "???").Inc() } }() return m.next.FindPublished(ctx, spaceId, envId, collectionId, filter, options...) @@ -142,7 +142,7 @@ func (m metricsMiddleware) Get(ctx context.Context, spaceId string, envId string timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Get").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Get").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Get", "???").Inc() } }() return m.next.Get(ctx, spaceId, envId, collectionId, itemId, options...) @@ -155,7 +155,7 @@ func (m metricsMiddleware) GetPublished(ctx context.Context, spaceId string, env timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "GetPublished").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "GetPublished").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "GetPublished", "???").Inc() } }() return m.next.GetPublished(ctx, spaceId, envId, collectionId, itemId, options...) @@ -168,7 +168,7 @@ func (m metricsMiddleware) GetRevision(ctx context.Context, spaceId string, envI timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "GetRevision").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "GetRevision").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "GetRevision", "???").Inc() } }() return m.next.GetRevision(ctx, spaceId, envId, collectionId, itemId, revisionId, options...) @@ -181,7 +181,7 @@ func (m metricsMiddleware) Introspect(ctx context.Context, item *items.Item, opt timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Introspect").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Introspect").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Introspect", "???").Inc() } }() return m.next.Introspect(ctx, item, opts...) @@ -194,7 +194,7 @@ func (m metricsMiddleware) ListRevisions(ctx context.Context, spaceId string, en timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "ListRevisions").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "ListRevisions").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "ListRevisions", "???").Inc() } }() return m.next.ListRevisions(ctx, spaceId, envId, collectionId, itemId, options...) @@ -207,7 +207,7 @@ func (m metricsMiddleware) Publish(ctx context.Context, item *items.Item, option timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Publish").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Publish").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Publish", "???").Inc() } }() return m.next.Publish(ctx, item, options...) @@ -220,7 +220,7 @@ func (m metricsMiddleware) Unarchive(ctx context.Context, item *items.Item, opti timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Unarchive").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Unarchive").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Unarchive", "???").Inc() } }() return m.next.Unarchive(ctx, item, options...) @@ -233,7 +233,7 @@ func (m metricsMiddleware) Undelete(ctx context.Context, item *items.Item, optio timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Undelete").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Undelete").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Undelete", "???").Inc() } }() return m.next.Undelete(ctx, item, options...) @@ -246,7 +246,7 @@ func (m metricsMiddleware) Unpublish(ctx context.Context, item *items.Item, opti timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Unpublish").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Unpublish").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Unpublish", "???").Inc() } }() return m.next.Unpublish(ctx, item, options...) @@ -259,7 +259,7 @@ func (m metricsMiddleware) Update(ctx context.Context, item *items.Item, options timer.ObserveDuration() m.requestMetrics.Total.WithLabelValues("Items", "Update").Inc() if err != nil { - m.requestMetrics.FailedTotal.WithLabelValues("Items", "Update").Inc() + m.requestMetrics.FailedTotal.WithLabelValues("Items", "Update", "???").Inc() } }() return m.next.Update(ctx, item, options...) -- GitLab