Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v3.5.7 #175

Merged
merged 22 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 48 additions & 28 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,61 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

# - name: Run Snyk to check for vulnerabilities
# uses: snyk/actions/golang@master
# continue-on-error: true
# env:
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
# with:
# args: --sarif-file-output=snyk.sarif

# - name: Upload result to GitHub Code Scanning
# uses: github/codeql-action/upload-sarif@v1
# with:
# sarif_file: snyk.sarif

# - name: Run golangci-lint
# uses: golangci/golangci-lint-action@v3.1.0
- name: "Go: Setup Cache Paths"
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"

- name: "Checkout"
uses: actions/checkout@v3

- name: Get Tag Version
- name: "Get Tag Version"
id: get_version
run: |
export TRUNCATED_GITHUB_SHA=$(echo ${{ github.sha }} | cut -c1-7);
echo "VERSION=${GITHUB_REF/refs\/tags\//}+${TRUNCATED_GITHUB_SHA}" >> $GITHUB_ENV
echo "GIT_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV

- name: Build and Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@3.04

# https://github.com/actions/cache/blob/main/examples.md#go---modules
- name: "Go: Cache: Builds"
uses: actions/cache@v3
with:
path: |
${{ steps.go-cache-paths.outputs.go-build }}
${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: "Docker: Login to GitHub Container Registry"
uses: docker/login-action@v2
with:
name: penguin-statistics/backend-next
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
tags: "latest,${{ env.GIT_TAG }}"
buildargs: VERSION

- name: Create Sentry release
- name: "Docker: Metadata"
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/penguin-statistics/backend-next
tags: |
type=semver,pattern=v{{version}}
type=ref,event=branch
type=ref,event=pr
flavor: |
latest=auto

- name: "Docker: Build and Push Image"
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ env.VERSION }}

- name: "Sentry: Create Release"
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
Expand All @@ -59,7 +78,8 @@ jobs:
environment: prod
version: ${{ env.VERSION }}

- uses: "marvinpinto/action-automatic-releases@latest"
- name: "GitHub: Create Repository Release"
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ require (
github.com/go-playground/validator/v10 v10.11.0
github.com/go-redis/redis/v8 v8.11.5
github.com/go-redsync/redsync/v4 v4.5.1
github.com/goccy/go-json v0.9.10
github.com/goccy/go-json v0.9.11
github.com/gofiber/contrib/fibersentry v0.0.0-20220816060400-efb0c66d02e1
github.com/gofiber/contrib/otelfiber v0.0.0-20220817055430-40b5c4d0af9c
github.com/gofiber/contrib/otelfiber v0.0.0-20220819142806-50936a03a090
github.com/gofiber/fiber/v2 v2.36.0
github.com/gofiber/helmet/v2 v2.2.15
github.com/gofiber/swagger v0.1.0
Expand All @@ -43,6 +43,9 @@ require (
github.com/zeebo/xxh3 v1.0.2
go.opentelemetry.io/otel v1.9.0
go.opentelemetry.io/otel/exporters/jaeger v1.9.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.9.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.9.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.9.0
go.opentelemetry.io/otel/sdk v1.9.0
go.uber.org/fx v1.18.1
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
Expand All @@ -67,11 +70,7 @@ require (
github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a // indirect
go.opentelemetry.io/contrib v1.9.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.9.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.9.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.9.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.9.0 // indirect
go.opentelemetry.io/proto/otlp v0.18.0 // indirect
go.uber.org/goleak v1.1.12 // indirect
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.1 // indirect
Expand Down Expand Up @@ -112,7 +111,7 @@ require (
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.opentelemetry.io/otel/metric v0.31.0 // indirect
go.opentelemetry.io/otel/trace v1.9.0 // indirect
go.opentelemetry.io/otel/trace v1.9.0
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/dig v1.15.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
Expand Down
13 changes: 5 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,16 @@ github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg78
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/goccy/go-json v0.9.10 h1:hCeNmprSNLB8B8vQKWl6DpuH0t60oEs+TAk9a7CScKc=
github.com/goccy/go-json v0.9.10/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofiber/adaptor/v2 v2.1.23/go.mod h1:hnYEQBPF2x1JaBHygutJJF5d0+J2eYnKKsUMCSsfxKk=
github.com/gofiber/adaptor/v2 v2.1.25 h1:K2Ef2a7mUsCfL/oJdzbjyMXchGYuUUwIVXrYVm+P+xs=
github.com/gofiber/adaptor/v2 v2.1.25/go.mod h1:gOxtwMVqUStB5goAYtKd+hSvGupdd+aRIafZHPLNaUk=
github.com/gofiber/contrib/fibersentry v0.0.0-20220816060400-efb0c66d02e1 h1:ePYdP30HcrNTMxTvmAeAISuUMvsrjlBXfOt3MdIQslI=
github.com/gofiber/contrib/fibersentry v0.0.0-20220816060400-efb0c66d02e1/go.mod h1:jCdXE0d8ROiQqIEtJrC6qRlRqQ83GoQ6928p/3NuCqI=
github.com/gofiber/contrib/otelfiber v0.0.0-20220817055430-40b5c4d0af9c h1:mSCgteIa2Yjt3ef5VXs++z2kWEkhmbZ72MxcVqgp2aU=
github.com/gofiber/contrib/otelfiber v0.0.0-20220817055430-40b5c4d0af9c/go.mod h1:3n+2GOKwuYIHKcgB18zeFAww5fR815xBYsp9aExcrCI=
github.com/gofiber/contrib/otelfiber v0.0.0-20220819142806-50936a03a090 h1:X2L/JA0CZ+PbynxDYhw8kS/IEdfr+oBeN+FHKkYZ++s=
github.com/gofiber/contrib/otelfiber v0.0.0-20220819142806-50936a03a090/go.mod h1:3n+2GOKwuYIHKcgB18zeFAww5fR815xBYsp9aExcrCI=
github.com/gofiber/fiber/v2 v2.24.0/go.mod h1:MR1usVH3JHYRyQwMe2eZXRSZHRX38fkV+A7CPB+DlDQ=
github.com/gofiber/fiber/v2 v2.32.0/go.mod h1:CMy5ZLiXkn6qwthrl03YMyW1NLfj0rhxz2LKl4t7ZTY=
github.com/gofiber/fiber/v2 v2.33.0/go.mod h1:CMy5ZLiXkn6qwthrl03YMyW1NLfj0rhxz2LKl4t7ZTY=
Expand All @@ -212,6 +212,7 @@ github.com/gofiber/utils v0.1.2/go.mod h1:pacRFtghAE3UoknMOUiXh2Io/nLWSUHtQCi/3Q
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -569,7 +570,6 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
Expand Down Expand Up @@ -616,7 +616,6 @@ go.uber.org/dig v1.15.0/go.mod h1:pKHs0wMynzL6brANhB2hLMro+zalv1osARTviTcqHLM=
go.uber.org/fx v1.18.1 h1:I7VWkdv4iKcbpH7KVSi9Fe1LGmpJv+pbBIb9NidPb+E=
go.uber.org/fx v1.18.1/go.mod h1:g0V1KMQ66zIRk8bLu3Ea5Jt2w/cHlOIp4wdRsgh0JaY=
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
Expand Down Expand Up @@ -674,7 +673,6 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand Down Expand Up @@ -875,7 +873,6 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
Expand Down
13 changes: 11 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type Config struct {
DevOpsAddress string `split_words:"true"`

// LogJsonStdout is whether to log JSON logs (instead of pretty-print logs) to stdout for the ease of log collection.
LogJsonStdout bool `default:"true"`
LogJsonStdout bool `default:"false"`

// TrustedProxies is a list of trusted proxies that are trusted to report a real IP via the X-Forwarded-For header.
TrustedProxies []string `required:"true" split_words:"true" default:"::1,127.0.0.1,10.0.0.0/8"`

// DevMode to indicate development mode. When true, the program would spin up utilities for debugging and
Expand All @@ -32,6 +33,14 @@ type Config struct {
// TracingEnabled to indicate whether to enable OpenTelemetry tracing.
TracingEnabled bool `split_words:"true"`

// TracingExporters to indicate which exporters to use for tracing.
// Valid values are: jaeger, otlp, stdout (for debug).
TracingExporters []string `split_words:"true" default:"jaeger"`

// TracingSampleRate to indicate the sampling rate for tracing.
// Valid values are: 0.0 (disabled), 1.0 (all traces), or a value between 0.0 and 1.0 (sampling rate).
TracingSampleRate float64 `split_words:"true" default:"1.0"`

// infrastructure components connection instructions

// PostgresDSN is the data source name for the PostgreSQL database. See
Expand All @@ -40,7 +49,7 @@ type Config struct {

PostgresMaxOpenConns int `split_words:"true" default:"10"`
PostgresMaxIdleConns int `split_words:"true" default:"2"`
PostgresConnMaxLifetime time.Duration `split_words:"true" default:"5m"`
PostgresConnMaxLifeTime time.Duration `split_words:"true" default:"5m"`
PostgresConnMaxIdleTime time.Duration `split_words:"true" default:"5m"`

BunDebugVerbose bool `split_words:"true"`
Expand Down
7 changes: 4 additions & 3 deletions internal/controller/v2/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
modelv2 "github.com/penguin-statistics/backend-next/internal/model/v2"
"github.com/penguin-statistics/backend-next/internal/pkg/crypto"
"github.com/penguin-statistics/backend-next/internal/pkg/fiberstore"
"github.com/penguin-statistics/backend-next/internal/pkg/flog"
"github.com/penguin-statistics/backend-next/internal/pkg/middlewares"
"github.com/penguin-statistics/backend-next/internal/pkg/pgerr"
"github.com/penguin-statistics/backend-next/internal/server/svr"
Expand Down Expand Up @@ -110,7 +111,7 @@ func (c *Report) RecognitionReport(ctx *fiber.Ctx) error {
segments := strings.SplitN(encrypted, ":", 2)

if err := rekuest.Validate.Var(segments, "len=2"); err != nil {
log.Warn().
flog.WarnFrom(ctx).
Err(err).
Msg("failed to decrypt recognition request")
return pgerr.ErrInvalidReq
Expand All @@ -121,15 +122,15 @@ func (c *Report) RecognitionReport(ctx *fiber.Ctx) error {

decrypted, err := c.Crypto.Decrypt(privateKey, body)
if err != nil {
log.Warn().
flog.WarnFrom(ctx).
Err(err).
Msg("failed to decrypt recognition request")
return pgerr.ErrInvalidReq
}

var request types.BatchReportRequest
if err = json.Unmarshal(decrypted, &request); err != nil {
log.Warn().
flog.WarnFrom(ctx).
Err(err).
Msg("failed to unmarshal recognition request")
return pgerr.ErrInvalidReq
Expand Down
4 changes: 3 additions & 1 deletion internal/infra/psql.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func Postgres(conf *config.Config) (*bun.DB, error) {
db := bun.NewDB(pgdb, pgdialect.New())
if conf.DevMode {
db.AddQueryHook(bundebug.NewQueryHook(bundebug.WithEnabled(true), bundebug.WithVerbose(conf.BunDebugVerbose)))
}
if conf.TracingEnabled {
db.AddQueryHook(bunotel.NewQueryHook(bunotel.WithDBName("penguin-postgres")))
}

Expand All @@ -34,7 +36,7 @@ func Postgres(conf *config.Config) (*bun.DB, error) {

pgdb.SetMaxOpenConns(conf.PostgresMaxOpenConns)
pgdb.SetMaxIdleConns(conf.PostgresMaxIdleConns)
pgdb.SetConnMaxLifetime(conf.PostgresConnMaxLifetime)
pgdb.SetConnMaxLifetime(conf.PostgresConnMaxLifeTime)
pgdb.SetConnMaxIdleTime(conf.PostgresConnMaxIdleTime)

return db, nil
Expand Down
26 changes: 17 additions & 9 deletions internal/pkg/middlewares/idempotency.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,37 @@ func Idempotency(config *IdempotencyConfig) fiber.Handler {
// Don't execute middleware if the idempotent key is missing
key := c.Get(config.KeyHeader)
if key == "" {
log.Trace().Msg("IdempotencyMiddleware: idempotency key is missing. Skipping middleware.")
if l := log.Trace(); l.Enabled() {
l.Msg("IdempotencyMiddleware: idempotency key is missing. Skipping middleware.")
}
return c.Next()
}

if err := rekuest.Validate.Var(key, "max=128,alphanum"); err != nil {
log.Trace().Err(err).Msg("IdempotencyMiddleware: idempotency key is invalid. Returning error.")
if l := log.Trace(); l.Enabled() {
l.Err(err).Msg("IdempotencyMiddleware: idempotency key is invalid. Returning error.")
}
return pgerr.ErrInvalidReq.Msg("invalid idempotency key: idempotency key can only be at most %d characters, consist of only alphanumeric characters", constant.IdempotencyKeyLengthLimit)
}

// Idempotency key not empty. Check if it is in the storage
response, err := config.Storage.Get(key)
if err == nil && response != nil {
// Idempotency key found in storage. Return the response
log.Debug().
Str("key", key).
Msg("IdempotencyMiddleware: idempotency key found in storage. Returning saved response.")
if l := log.Debug(); l.Enabled() {
l.Str("key", key).
Msg("IdempotencyMiddleware: idempotency key found in storage. Returning saved response.")
}
return unmarshalResponseToFiberResponse(c, config, response)
}

// Execute the request handler
err = c.Next()
if err != nil {
// If the request handler returned an error, return it and skip idempotency
log.Trace().Msg("IdempotencyMiddleware: request handler returned an error. Skipping saving the idempotency response.")
if l := log.Trace(); l.Enabled() {
l.Msg("IdempotencyMiddleware: request handler returned an error. Skipping saving the idempotency response.")
}
return err
}

Expand All @@ -98,9 +105,10 @@ func Idempotency(config *IdempotencyConfig) fiber.Handler {
// Add idempotency header
c.Set(constant.IdempotencyHeader, "saved")

log.Debug().
Str("key", key).
Msg("IdempotencyMiddleware: Idempotency Key given and no response was saved. Executed request handler and saved returned response in storage.")
if l := log.Debug(); l.Enabled() {
l.Str("key", key).
Msg("IdempotencyMiddleware: Idempotency Key given and no response was saved. Executed request handler and saved returned response in storage.")
}

return nil
}
Expand Down