From ed04435d80f6d8147d947f0eebfed1a43b609424 Mon Sep 17 00:00:00 2001 From: rodrigodh Date: Mon, 13 Jul 2026 18:51:37 -0300 Subject: [PATCH 1/2] feat(core)!: migrate to Fiber v3, cut /v2 major Bump gofiber/fiber v2.52.13 -> v3.4.0 (v2 dropped) and cut the /v2 module major. fiber.Ctx is now an interface passed by value: all *fiber.Ctx signatures across middleware/ and tracing/ drop the pointer. c.UserContext()/SetUserContext() -> c.Context()/SetContext(); app.Add now takes []string. No behavior change intended. BREAKING CHANGE: module path is now github.com/LerianStudio/lib-observability/v2 and exported HTTP helpers take fiber.Ctx by value; consumers must be on Fiber v3. X-Lerian-Ref: 0x1 --- assert/assert.go | 8 ++-- assert/assert_extended_test.go | 8 ++-- assert/assert_test.go | 2 +- context_tracking_test.go | 4 +- go.mod | 25 +++++++----- go.sum | 52 ++++++++++++++---------- log/go_logger.go | 2 +- metrics/metrics.go | 2 +- metrics/metrics_test.go | 2 +- middleware/context_span.go | 4 +- middleware/context_span_test.go | 4 +- middleware/helpers.go | 10 ++--- middleware/helpers_test.go | 4 +- middleware/logging.go | 22 +++++----- middleware/logging_obfuscation.go | 10 ++--- middleware/logging_test.go | 28 ++++++------- middleware/metrics.go | 4 +- middleware/request_attrs.go | 2 +- middleware/telemetry.go | 38 +++++++++--------- middleware/telemetry_metrics_test.go | 60 ++++++++++++++-------------- middleware/telemetry_route_test.go | 4 +- middleware/telemetry_test.go | 48 +++++++++++----------- middleware/tenant.go | 8 ++-- middleware/tenant_test.go | 8 ++-- observability.go | 4 +- runtime/goroutine.go | 2 +- runtime/helpers_test.go | 2 +- runtime/log_mode_link_test.go | 2 +- runtime/metrics.go | 6 +-- runtime/metrics_test.go | 2 +- runtime/recover.go | 4 +- runtime/tracing.go | 2 +- system.go | 4 +- system_test.go | 2 +- tracing/obfuscation.go | 4 +- tracing/obfuscation_test.go | 2 +- tracing/otel.go | 20 +++++----- tracing/otel_test.go | 6 +-- tracing/processor.go | 4 +- tracing/v2_test.go | 2 +- zap/zap.go | 6 +-- zap/zap_test.go | 2 +- 42 files changed, 225 insertions(+), 210 deletions(-) diff --git a/assert/assert.go b/assert/assert.go index 6502d6a..6ff6fe0 100644 --- a/assert/assert.go +++ b/assert/assert.go @@ -16,10 +16,10 @@ import ( "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/trace" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/log" - "github.com/LerianStudio/lib-observability/metrics" - "github.com/LerianStudio/lib-observability/runtime" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/log" + "github.com/LerianStudio/lib-observability/v2/metrics" + "github.com/LerianStudio/lib-observability/v2/runtime" ) // Logger defines the minimal logging interface required by assertions. diff --git a/assert/assert_extended_test.go b/assert/assert_extended_test.go index a657867..1f7e31d 100644 --- a/assert/assert_extended_test.go +++ b/assert/assert_extended_test.go @@ -7,14 +7,14 @@ import ( "strings" "testing" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/log" - libRuntime "github.com/LerianStudio/lib-observability/runtime" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/log" + libRuntime "github.com/LerianStudio/lib-observability/v2/runtime" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/metric/noop" tracesdk "go.opentelemetry.io/otel/sdk/trace" - "github.com/LerianStudio/lib-observability/metrics" + "github.com/LerianStudio/lib-observability/v2/metrics" ) func newTestMetricsFactory(t *testing.T) *metrics.MetricsFactory { diff --git a/assert/assert_test.go b/assert/assert_test.go index f6af13c..eb6b4d3 100644 --- a/assert/assert_test.go +++ b/assert/assert_test.go @@ -8,7 +8,7 @@ import ( "math" "testing" - "github.com/LerianStudio/lib-observability/log" + "github.com/LerianStudio/lib-observability/v2/log" "github.com/shopspring/decimal" "github.com/stretchr/testify/require" ) diff --git a/context_tracking_test.go b/context_tracking_test.go index a3ec77d..30b2d48 100644 --- a/context_tracking_test.go +++ b/context_tracking_test.go @@ -6,8 +6,8 @@ import ( "context" "testing" - "github.com/LerianStudio/lib-observability/log" - "github.com/LerianStudio/lib-observability/metrics" + "github.com/LerianStudio/lib-observability/v2/log" + "github.com/LerianStudio/lib-observability/v2/metrics" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel" diff --git a/go.mod b/go.mod index ff1ee7d..a00eb89 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ -module github.com/LerianStudio/lib-observability +module github.com/LerianStudio/lib-observability/v2 go 1.26.3 require ( - github.com/gofiber/fiber/v2 v2.52.13 + github.com/gofiber/fiber/v3 v3.4.0 github.com/google/uuid v1.6.0 github.com/shirou/gopsutil v3.21.11+incompatible github.com/shopspring/decimal v1.4.0 @@ -26,31 +26,34 @@ require ( ) require ( - github.com/andybalholm/brotli v1.2.1 // indirect + github.com/andybalholm/brotli v1.2.2 // indirect github.com/cenkalti/backoff/v5 v5.0.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect + github.com/gofiber/schema v1.8.0 // indirect + github.com/gofiber/utils/v2 v2.1.1 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect - github.com/klauspost/compress v1.18.6 // indirect - github.com/mattn/go-colorable v0.1.14 // indirect + github.com/klauspost/compress v1.19.0 // indirect + github.com/mattn/go-colorable v0.1.15 // indirect github.com/mattn/go-isatty v0.0.22 // indirect - github.com/mattn/go-runewidth v0.0.23 // indirect + github.com/philhofer/fwd v1.2.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/tinylib/msgp v1.6.4 // indirect github.com/tklauser/go-sysconf v0.4.0 // indirect github.com/tklauser/numcpus v0.12.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.71.0 // indirect + github.com/valyala/fasthttp v1.72.0 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect go.opentelemetry.io/proto/otlp v1.10.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/net v0.55.0 // indirect - golang.org/x/sys v0.45.0 // indirect - golang.org/x/text v0.37.0 // indirect + golang.org/x/crypto v0.53.0 // indirect + golang.org/x/net v0.56.0 // indirect + golang.org/x/sys v0.46.0 // indirect + golang.org/x/text v0.38.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa // indirect google.golang.org/protobuf v1.36.11 // indirect diff --git a/go.sum b/go.sum index 591309d..ab9120f 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,13 @@ -github.com/andybalholm/brotli v1.2.1 h1:R+f5xP285VArJDRgowrfb9DqL18yVK0gKAW/F+eTWro= -github.com/andybalholm/brotli v1.2.1/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= +github.com/andybalholm/brotli v1.2.2 h1:HzTuoo2ErYQqf5qvcJInB8uvqSVxRttzkFexPWtnceM= +github.com/andybalholm/brotli v1.2.2/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM= github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk= -github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fxamacker/cbor/v2 v2.9.2 h1:X4Ksno9+x3cz0TZv69ec1hxP/+tymuR8PXQJyDwfh78= +github.com/fxamacker/cbor/v2 v2.9.2/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -16,8 +16,12 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= -github.com/gofiber/fiber/v2 v2.52.13 h1:TOKP64iqC9b5P49VrBW5tHhUOvDyrtJ0xePEfzJbCbk= -github.com/gofiber/fiber/v2 v2.52.13/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw= +github.com/gofiber/fiber/v3 v3.4.0 h1:F0aND4vwZF7dR7cbvSwFQQEpBU902XHKWxrLsFBkVqw= +github.com/gofiber/fiber/v3 v3.4.0/go.mod h1:nAhJfdxUIJJph2tPWPmqWf8QDIN2iiqQiQf3lENZpdk= +github.com/gofiber/schema v1.8.0 h1:NGsC9toPHmj8Xg4KpznuXBzNmHG6V5YV0tXKpKMcmis= +github.com/gofiber/schema v1.8.0/go.mod h1:lmbXPQ8hvzXSLkdS2DS7pb4kpunC2Roh7Sj3HMjGfzA= +github.com/gofiber/utils/v2 v2.1.1 h1:kGnoGjwEnFW6w0x45W+kLlmMJvqBGkuUA4oMWKn/T/I= +github.com/gofiber/utils/v2 v2.1.1/go.mod h1:DdOgEVwQTi8cou/AKWPqhXOR4fHGRVhA/rEWL3IXG7Q= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -26,36 +30,42 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 h1:5VipnvEpbqr2gA2VbM+nYVbkIF28c5ZQfqCBQ5g2xfk= github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0/go.mod h1:Hyl3n6Twe1hvtd9XUXDec4pTvgMSEixRuQKPTMH2bNs= -github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao= -github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= +github.com/klauspost/compress v1.19.0 h1:sXLILfc9jV2QYWkzFOPWStmcUVH2RHEB1JCdY2oVvCQ= +github.com/klauspost/compress v1.19.0/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= -github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY= +github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4= github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= -github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3RybWcw= -github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= +github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM= +github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/shamaton/msgpack/v3 v3.1.2 h1:d5gWAIyMU4M0WgDjz6IFSCuXJUA2dFwRHBpDclE8CLw= +github.com/shamaton/msgpack/v3 v3.1.2/go.mod h1:DcQG8jrdrQCIxr3HlMYkiXdMhK+KfN2CitkyzsQV4uc= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/tinylib/msgp v1.6.4 h1:mOwYbyYDLPj35mkA2BjjYejgJk9BuHxDdvRnb6v2ZcQ= +github.com/tinylib/msgp v1.6.4/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA= github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRUgPQU= github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI= github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4= github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.71.0 h1:tepR7H+Guh9VUqxxcPggYi8R3lGUu2Rsdh+z7/FCY3k= -github.com/valyala/fasthttp v1.71.0/go.mod h1:z1sDUvOShhXq/C9mwH/fSm1Vb71tUJwmQdgkBrBNwnA= +github.com/valyala/fasthttp v1.72.0 h1:R7kYdoWhn1ye1fVpP+cDHDJwYm3NkwLliwgzJ/Abg7M= +github.com/valyala/fasthttp v1.72.0/go.mod h1:zsbLTYqcpIktdQytlVBwIjY9La5d6bs990nBxWg8efk= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= @@ -104,14 +114,16 @@ go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo= go.uber.org/zap v1.28.0/go.mod h1:rDLpOi171uODNm/mxFcuYWxDsqWSAVkFdX4XojSKg/Q= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8= -golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww= +golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto= +golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio= +golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= +golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY= -golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= -golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= -golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= +golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa h1:Kjn0N0tCrDgiAFW+lGO4JZ3ck44CehvJQMAwj9QF0G8= diff --git a/log/go_logger.go b/log/go_logger.go index 78347f6..a36532f 100644 --- a/log/go_logger.go +++ b/log/go_logger.go @@ -7,7 +7,7 @@ import ( "reflect" "strings" - "github.com/LerianStudio/lib-observability/redaction" + "github.com/LerianStudio/lib-observability/v2/redaction" ) var logControlCharReplacer = strings.NewReplacer( diff --git a/metrics/metrics.go b/metrics/metrics.go index 44abc0e..6f96a77 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -9,7 +9,7 @@ import ( "strings" "sync" - "github.com/LerianStudio/lib-observability/log" + "github.com/LerianStudio/lib-observability/v2/log" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/noop" ) diff --git a/metrics/metrics_test.go b/metrics/metrics_test.go index 2f7ef6c..7050a32 100644 --- a/metrics/metrics_test.go +++ b/metrics/metrics_test.go @@ -7,7 +7,7 @@ import ( "errors" "testing" - "github.com/LerianStudio/lib-observability/log" + "github.com/LerianStudio/lib-observability/v2/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" diff --git a/middleware/context_span.go b/middleware/context_span.go index 30ff927..1898f21 100644 --- a/middleware/context_span.go +++ b/middleware/context_span.go @@ -4,8 +4,8 @@ import ( "context" "reflect" - observability "github.com/LerianStudio/lib-observability" - constant "github.com/LerianStudio/lib-observability/constants" + observability "github.com/LerianStudio/lib-observability/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" "github.com/google/uuid" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" diff --git a/middleware/context_span_test.go b/middleware/context_span_test.go index 65f2f40..ca6f8fb 100644 --- a/middleware/context_span_test.go +++ b/middleware/context_span_test.go @@ -6,8 +6,8 @@ import ( "context" "testing" - observability "github.com/LerianStudio/lib-observability" - constant "github.com/LerianStudio/lib-observability/constants" + observability "github.com/LerianStudio/lib-observability/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" "github.com/google/uuid" "github.com/stretchr/testify/assert" "go.opentelemetry.io/otel/attribute" diff --git a/middleware/helpers.go b/middleware/helpers.go index 2789a45..ded5775 100644 --- a/middleware/helpers.go +++ b/middleware/helpers.go @@ -7,9 +7,9 @@ import ( "regexp" "strings" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/redaction" - "github.com/gofiber/fiber/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/redaction" + "github.com/gofiber/fiber/v3" "google.golang.org/grpc/metadata" ) @@ -47,7 +47,7 @@ func normalizeHTTPMethod(raw string) (normalized, original string, replaced bool // request path is NOT "/") and report the attribute as absent so callers // can omit it entirely, matching OTel guidance that http.route SHOULD be // absent when no route matched. -func routeAttribute(c *fiber.Ctx, effectiveStatus int) (string, bool) { +func routeAttribute(c fiber.Ctx, effectiveStatus int) (string, bool) { if c == nil { return "", false } @@ -129,7 +129,7 @@ func errorTypeOriginal(handlerErr error) string { // // Trailing slashes on excluded entries are tolerated, and empty entries // are ignored so they cannot act as accidental wildcards. -func isRouteExcludedFromList(c *fiber.Ctx, excludedRoutes []string) bool { +func isRouteExcludedFromList(c fiber.Ctx, excludedRoutes []string) bool { path := c.Path() for _, route := range excludedRoutes { diff --git a/middleware/helpers_test.go b/middleware/helpers_test.go index 8968f34..f80cc87 100644 --- a/middleware/helpers_test.go +++ b/middleware/helpers_test.go @@ -7,7 +7,7 @@ import ( "net/http/httptest" "testing" - "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v3" "github.com/stretchr/testify/assert" ) @@ -50,7 +50,7 @@ func TestIsRouteExcludedFromList(t *testing.T) { t.Run(tc.name, func(t *testing.T) { app := fiber.New() var got bool - app.Use(func(c *fiber.Ctx) error { + app.Use(func(c fiber.Ctx) error { got = isRouteExcludedFromList(c, tc.excluded) return c.SendStatus(http.StatusNoContent) }) diff --git a/middleware/logging.go b/middleware/logging.go index 306ac57..704d049 100644 --- a/middleware/logging.go +++ b/middleware/logging.go @@ -11,10 +11,10 @@ import ( "strings" "time" - observability "github.com/LerianStudio/lib-observability" - constant "github.com/LerianStudio/lib-observability/constants" - obslog "github.com/LerianStudio/lib-observability/log" - "github.com/gofiber/fiber/v2" + observability "github.com/LerianStudio/lib-observability/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" + obslog "github.com/LerianStudio/lib-observability/v2/log" + "github.com/gofiber/fiber/v3" "go.opentelemetry.io/otel/attribute" "google.golang.org/grpc" ) @@ -47,7 +47,7 @@ type RequestInfo struct { // ResponseMetricsWrapper stores response metadata used to finish RequestInfo. type ResponseMetricsWrapper struct { - Context *fiber.Ctx + Context fiber.Ctx StatusCode int Size int } @@ -130,7 +130,7 @@ func isNilLogger(logger obslog.Logger) bool { } // NewRequestInfo creates RequestInfo from a Fiber context. -func NewRequestInfo(c *fiber.Ctx, obfuscationDisabled bool) *RequestInfo { +func NewRequestInfo(c fiber.Ctx, obfuscationDisabled bool) *RequestInfo { if c == nil { return &RequestInfo{Date: time.Now().UTC()} } @@ -212,7 +212,7 @@ func (r *RequestInfo) FinishRequestInfo(rw *ResponseMetricsWrapper) { // WithExcludedRoutes to suppress additional paths without losing the // defaults. func WithHTTPLogging(opts ...LogMiddlewareOption) fiber.Handler { - return func(c *fiber.Ctx) error { + return func(c fiber.Ctx) error { mid := buildOpts(opts...) if isRouteExcludedFromList(c, mid.ExcludedRoutes) { @@ -228,7 +228,7 @@ func WithHTTPLogging(opts ...LogMiddlewareOption) fiber.Handler { info := NewRequestInfo(c, mid.ObfuscationDisabled) requestID := c.Get(headerID) - ctx := c.UserContext() + ctx := c.Context() if tenantID := ResolveTenantIDFromHTTP(c); tenantID != "" { ctx = observability.ContextWithSpanAttributes(ctx, attribute.String(constant.AttrKeyTenantID, tenantID)) @@ -243,7 +243,7 @@ func WithHTTPLogging(opts ...LogMiddlewareOption) fiber.Handler { } ctx = observability.ContextWithLogger(ctx, logger) - c.SetUserContext(ctx) + c.SetContext(ctx) err := c.Next() statusCode := httpStatusCode(c, err) @@ -260,13 +260,13 @@ func WithHTTPLogging(opts ...LogMiddlewareOption) fiber.Handler { obslog.String("http_method", info.Method), obslog.String("http_path", info.URI), obslog.Int("http_latency_ms", int(info.Duration.Milliseconds())), - ).Log(c.UserContext(), obslog.LevelInfo, info.CLFString()) + ).Log(c.Context(), obslog.LevelInfo, info.CLFString()) return err } } -func httpStatusCode(c *fiber.Ctx, err error) int { +func httpStatusCode(c fiber.Ctx, err error) int { statusCode := c.Response().StatusCode() if err == nil { return statusCode diff --git a/middleware/logging_obfuscation.go b/middleware/logging_obfuscation.go index 5095190..026809a 100644 --- a/middleware/logging_obfuscation.go +++ b/middleware/logging_obfuscation.go @@ -4,14 +4,14 @@ import ( "net/url" "strings" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/redaction" - "github.com/gofiber/fiber/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/redaction" + "github.com/gofiber/fiber/v3" ) const redactedBody = "[REDACTED]" -func getBodyObfuscatedString(c *fiber.Ctx, bodyBytes []byte) string { +func getBodyObfuscatedString(c fiber.Ctx, bodyBytes []byte) string { contentType := strings.ToLower(c.Get(headerContentType)) switch { @@ -86,7 +86,7 @@ func handleURLEncodedBody(bodyBytes []byte) string { return updatedBody.Encode() } -func handleMultipartBody(c *fiber.Ctx) string { +func handleMultipartBody(c fiber.Ctx) string { form, err := c.MultipartForm() if err != nil { return "[multipart/form-data]" diff --git a/middleware/logging_test.go b/middleware/logging_test.go index 50fa7e4..0c088a2 100644 --- a/middleware/logging_test.go +++ b/middleware/logging_test.go @@ -12,9 +12,9 @@ import ( "sync" "testing" - observability "github.com/LerianStudio/lib-observability" - obslog "github.com/LerianStudio/lib-observability/log" - "github.com/gofiber/fiber/v2" + observability "github.com/LerianStudio/lib-observability/v2" + obslog "github.com/LerianStudio/lib-observability/v2/log" + "github.com/gofiber/fiber/v3" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" @@ -71,7 +71,7 @@ func (r grpcRequestWithID) GetRequestId() string { func TestNewRequestInfoSanitizesRequestData(t *testing.T) { app := fiber.New() - app.Post("/charge", func(c *fiber.Ctx) error { + app.Post("/charge", func(c fiber.Ctx) error { info := NewRequestInfo(c, false) assert.Equal(t, "POST", info.Method) @@ -98,10 +98,10 @@ func TestWithHTTPLoggingAttachesLoggerAndLogsAccessEntry(t *testing.T) { logger := &captureLogger{} app := fiber.New() app.Use(WithHTTPLogging(WithCustomLogger(logger))) - app.Get("/ok", func(c *fiber.Ctx) error { - _, _, requestID, _ := observability.NewTrackingFromContext(c.UserContext()) + app.Get("/ok", func(c fiber.Ctx) error { + _, _, requestID, _ := observability.NewTrackingFromContext(c.Context()) assert.NotEmpty(t, requestID) - assert.Same(t, logger, observability.NewLoggerFromContext(c.UserContext())) + assert.Same(t, logger, observability.NewLoggerFromContext(c.Context())) return c.SendString("ok") }) @@ -144,8 +144,8 @@ func TestWithHTTPLoggingIgnoresTypedNilLogger(t *testing.T) { var logger *captureLogger app := fiber.New() app.Use(WithHTTPLogging(WithCustomLogger(logger))) - app.Get("/ok", func(c *fiber.Ctx) error { - assert.NotNil(t, observability.NewLoggerFromContext(c.UserContext())) + app.Get("/ok", func(c fiber.Ctx) error { + assert.NotNil(t, observability.NewLoggerFromContext(c.Context())) return c.SendStatus(http.StatusNoContent) }) @@ -164,7 +164,7 @@ func TestWithHTTPLoggingSkipsDefaultProbePaths(t *testing.T) { logger := &captureLogger{} app := fiber.New() app.Use(WithHTTPLogging(WithCustomLogger(logger))) - app.Get(path, func(c *fiber.Ctx) error { + app.Get(path, func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -188,7 +188,7 @@ func TestWithHTTPLoggingExcludedRoutesOptionSuppressesLogs(t *testing.T) { WithCustomLogger(logger), WithExcludedRoutes("/internal"), )) - app.Get("/internal/diag", func(c *fiber.Ctx) error { + app.Get("/internal/diag", func(c fiber.Ctx) error { return c.SendString("ok") }) @@ -209,7 +209,7 @@ func TestWithHTTPLoggingExcludedRoutesOptionPreservesDefaults(t *testing.T) { WithCustomLogger(logger), WithExcludedRoutes("/metrics"), )) - app.Get("/readyz", func(c *fiber.Ctx) error { + app.Get("/readyz", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -230,7 +230,7 @@ func TestWithHTTPLoggingExcludedRoutesIgnoresEmptyStrings(t *testing.T) { WithCustomLogger(logger), WithExcludedRoutes("", "/skip"), )) - app.Get("/ok", func(c *fiber.Ctx) error { + app.Get("/ok", func(c fiber.Ctx) error { return c.SendString("ok") }) @@ -249,7 +249,7 @@ func TestWithHTTPLoggingLogsErrorStatus(t *testing.T) { logger := &captureLogger{} app := fiber.New() app.Use(WithHTTPLogging(WithCustomLogger(logger))) - app.Get("/fail", func(*fiber.Ctx) error { + app.Get("/fail", func(fiber.Ctx) error { return errors.New("handler failed") }) diff --git a/middleware/metrics.go b/middleware/metrics.go index a277092..48dfdfc 100644 --- a/middleware/metrics.go +++ b/middleware/metrics.go @@ -7,8 +7,8 @@ import ( "sync" "time" - observability "github.com/LerianStudio/lib-observability" - "github.com/LerianStudio/lib-observability/runtime" + observability "github.com/LerianStudio/lib-observability/v2" + "github.com/LerianStudio/lib-observability/v2/runtime" ) // DefaultMetricsCollectionInterval is the default interval for collecting system metrics. diff --git a/middleware/request_attrs.go b/middleware/request_attrs.go index ad887a7..47fb46f 100644 --- a/middleware/request_attrs.go +++ b/middleware/request_attrs.go @@ -3,7 +3,7 @@ package middleware import ( "context" - observability "github.com/LerianStudio/lib-observability" + observability "github.com/LerianStudio/lib-observability/v2" "go.opentelemetry.io/otel/attribute" ) diff --git a/middleware/telemetry.go b/middleware/telemetry.go index 8ebf25c..0278b13 100644 --- a/middleware/telemetry.go +++ b/middleware/telemetry.go @@ -12,10 +12,10 @@ import ( "sync" "time" - observability "github.com/LerianStudio/lib-observability" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/tracing" - "github.com/gofiber/fiber/v2" + observability "github.com/LerianStudio/lib-observability/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/tracing" + "github.com/gofiber/fiber/v3" "github.com/google/uuid" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" @@ -156,7 +156,7 @@ func (tm *TelemetryMiddleware) WithTelemetry(tl *tracing.Telemetry, excludedRout ) } - return func(c *fiber.Ctx) error { + return func(c fiber.Ctx) error { effectiveTelemetry := tl if effectiveTelemetry == nil && tm != nil { effectiveTelemetry = tm.Telemetry @@ -177,14 +177,14 @@ func (tm *TelemetryMiddleware) WithTelemetry(tl *tracing.Telemetry, excludedRout // whether tracing is enabled below. requestStart := time.Now() - ctx := c.UserContext() + ctx := c.Context() _, _, reqId, _ := observability.NewTrackingFromContext(ctx) if tenantID := ResolveTenantIDFromHTTP(c); tenantID != "" { ctx = observability.ContextWithSpanAttributes(ctx, attribute.String(constant.AttrKeyTenantID, tenantID)) } - c.SetUserContext(observability.ContextWithSpanAttributes(ctx, + c.SetContext(observability.ContextWithSpanAttributes(ctx, attribute.String("app.request.request_id", reqId), )) @@ -212,7 +212,7 @@ func (tm *TelemetryMiddleware) WithTelemetry(tl *tracing.Telemetry, excludedRout tracer := effectiveTelemetry.TracerProvider.Tracer(effectiveTelemetry.LibraryName) routePathWithMethod := method + " " + replaceUUIDWithPlaceholder(c.Path()) - traceCtx := c.UserContext() + traceCtx := c.Context() // Compatibility note: trace extraction currently trusts the internal-service // User-Agent heuristic. This is an interoperability hint, not an authenticated // trust boundary, and is preserved to avoid changing existing caller behavior. @@ -228,7 +228,7 @@ func (tm *TelemetryMiddleware) WithTelemetry(tl *tracing.Telemetry, excludedRout ctx = observability.ContextWithTracer(ctx, tracer) ctx = observability.ContextWithMetricFactory(ctx, effectiveTelemetry.MetricsFactory) ctx = contextWithSpanEndState(ctx, endState) - c.SetUserContext(ctx) + c.SetContext(ctx) err := tm.collectMetrics(ctx) if err != nil { @@ -280,7 +280,7 @@ type telemetryRequestAttrs struct { // inline. func applyTelemetrySpanAttributes( span trace.Span, - c *fiber.Ctx, + c fiber.Ctx, statusCode int, req telemetryRequestAttrs, ) { @@ -348,7 +348,7 @@ func applyTelemetrySpanAttributes( // middleware/tenant.go, keeping the label safe for use in dashboards and // alerts that filter by tenant. func recordHTTPServerDuration( - c *fiber.Ctx, + c fiber.Ctx, hist metric.Float64Histogram, method string, start time.Time, @@ -372,12 +372,12 @@ func recordHTTPServerDuration( attrs = append(attrs, attribute.String("error.type", errType)) } - if tenantID := resolveTenantIDForTelemetry(c.UserContext()); tenantID != "" { + if tenantID := resolveTenantIDForTelemetry(c.Context()); tenantID != "" { attrs = append(attrs, attribute.String(constant.AttrKeyTenantID, tenantID)) } durationSeconds := time.Since(start).Seconds() - hist.Record(c.UserContext(), durationSeconds, metric.WithAttributes(attrs...)) + hist.Record(c.Context(), durationSeconds, metric.WithAttributes(attrs...)) } // classifyHTTPErrorType returns the stable, low-cardinality error.type @@ -396,15 +396,15 @@ func classifyHTTPErrorType(statusCode int) string { } // EndTracingSpans is a middleware that ends the tracing spans. -func (tm *TelemetryMiddleware) EndTracingSpans(c *fiber.Ctx) error { +func (tm *TelemetryMiddleware) EndTracingSpans(c fiber.Ctx) error { if c == nil { return ErrContextNotFound } - originalCtx := c.UserContext() + originalCtx := c.Context() err := c.Next() - endCtx := c.UserContext() + endCtx := c.Context() if endCtx == nil { endCtx = originalCtx } @@ -526,7 +526,7 @@ func (tm *TelemetryMiddleware) EndTracingSpansInterceptor() grpc.UnaryServerInte // The effective ID is always echoed back on the response so that callers can // correlate their request regardless of whether the ID was client-supplied or // server-generated. -func setRequestHeaderID(c *fiber.Ctx) { +func setRequestHeaderID(c fiber.Ctx) { hid := normalizeRequestID(c.Get(headerID)) if isNilOrEmptyString(&hid) { @@ -537,8 +537,8 @@ func setRequestHeaderID(c *fiber.Ctx) { c.Set(headerID, hid) c.Response().Header.Set(headerID, hid) - ctx := observability.ContextWithHeaderID(c.UserContext(), hid) - c.SetUserContext(ctx) + ctx := observability.ContextWithHeaderID(c.Context(), hid) + c.SetContext(ctx) } // resolveGRPCRequestID determines the request ID for a gRPC call from the request body, diff --git a/middleware/telemetry_metrics_test.go b/middleware/telemetry_metrics_test.go index 0db5026..895ae14 100644 --- a/middleware/telemetry_metrics_test.go +++ b/middleware/telemetry_metrics_test.go @@ -11,10 +11,10 @@ import ( "testing" "unicode/utf8" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/metrics" - "github.com/LerianStudio/lib-observability/tracing" - "github.com/gofiber/fiber/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/metrics" + "github.com/LerianStudio/lib-observability/v2/tracing" + "github.com/gofiber/fiber/v3" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" @@ -145,7 +145,7 @@ func TestWithTelemetry_RecordsDurationOnSuccess(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/users/:id", func(c *fiber.Ctx) error { + app.Get("/api/users/:id", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -185,7 +185,7 @@ func TestWithTelemetry_RecordsDurationOn4xx(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/items/:id", func(c *fiber.Ctx) error { + app.Get("/api/items/:id", func(c fiber.Ctx) error { return c.SendStatus(http.StatusNotFound) }) @@ -216,7 +216,7 @@ func TestWithTelemetry_RecordsDurationOn5xxStatus(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/health", func(c *fiber.Ctx) error { + app.Get("/api/health", func(c fiber.Ctx) error { return c.SendStatus(http.StatusServiceUnavailable) }) @@ -251,7 +251,7 @@ func TestWithTelemetry_RecordsDurationOnHandlerError(t *testing.T) { tel, reader, spanExp := newTelemetryHarness(t) app := fiber.New(fiber.Config{ - ErrorHandler: func(c *fiber.Ctx, err error) error { + ErrorHandler: func(c fiber.Ctx, err error) error { return c.Status(http.StatusInternalServerError).SendString(err.Error()) }, }) @@ -259,7 +259,7 @@ func TestWithTelemetry_RecordsDurationOnHandlerError(t *testing.T) { app.Use(mid.WithTelemetry(tel)) sentinel := errors.New("boom") - app.Get("/api/explode", func(c *fiber.Ctx) error { + app.Get("/api/explode", func(c fiber.Ctx) error { return sentinel }) @@ -302,7 +302,7 @@ func TestWithTelemetry_FiberError4xxOmitsErrorTypeOnMetric(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/items/:id", func(c *fiber.Ctx) error { + app.Get("/api/items/:id", func(c fiber.Ctx) error { return fiber.NewError(http.StatusNotFound, "not found") }) @@ -349,7 +349,7 @@ func TestWithTelemetry_FiberError400OmitsErrorTypeOnMetric(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Post("/api/validate", func(c *fiber.Ctx) error { + app.Post("/api/validate", func(c fiber.Ctx) error { return fiber.NewError(http.StatusBadRequest, "invalid payload") }) @@ -390,7 +390,7 @@ func TestWithTelemetry_RecordsDurationOnFiberError5xx(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/down", func(c *fiber.Ctx) error { + app.Get("/api/down", func(c fiber.Ctx) error { return fiber.NewError(http.StatusBadGateway, "upstream gone") }) @@ -433,10 +433,10 @@ func TestWithTelemetry_FiberErrorAndSendStatusAreConsistent(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/raise", func(c *fiber.Ctx) error { + app.Get("/api/raise", func(c fiber.Ctx) error { return fiber.NewError(http.StatusServiceUnavailable, "down") }) - app.Get("/api/send", func(c *fiber.Ctx) error { + app.Get("/api/send", func(c fiber.Ctx) error { return c.SendStatus(http.StatusServiceUnavailable) }) @@ -504,7 +504,7 @@ func TestWithTelemetry_GenericHandlerErrorStatusCodeIs500(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/explode", func(c *fiber.Ctx) error { + app.Get("/api/explode", func(c fiber.Ctx) error { return errors.New("boom") }) @@ -545,7 +545,7 @@ func TestWithTelemetry_DoesNotRecordForExcludedRoute(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel, "/swagger")) - app.Get("/swagger/index.html", func(c *fiber.Ctx) error { + app.Get("/swagger/index.html", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -571,7 +571,7 @@ func TestWithTelemetry_NilTelemetryDoesNotRecord(t *testing.T) { mid := NewTelemetryMiddleware(nil) app.Use(mid.WithTelemetry(nil)) - app.Get("/ping", func(c *fiber.Ctx) error { + app.Get("/ping", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -608,7 +608,7 @@ func TestWithTelemetry_NilMeterProviderDoesNotRecord(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/no-mp", func(c *fiber.Ctx) error { + app.Get("/no-mp", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -639,7 +639,7 @@ func TestWithTelemetry_NilMetricsFactoryDoesNotRecord(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/no-factory", func(c *fiber.Ctx) error { + app.Get("/no-factory", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -692,7 +692,7 @@ func TestWithTelemetry_UnmatchedRouteOmitsHTTPRoute(t *testing.T) { app := fiber.New() mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/", func(c *fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) + app.Get("/", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) resp, err := app.Test(httptest.NewRequest(http.MethodGet, "/", nil)) require.NoError(t, err) @@ -728,7 +728,7 @@ func TestWithTelemetry_NormalizesUnknownMethodOnSpan(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Add("PROPFIND", "/dav/:resource", func(c *fiber.Ctx) error { + app.Add([]string{"PROPFIND"}, "/dav/:resource", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -764,7 +764,7 @@ func TestWithTelemetry_KnownMethodHasNoOriginal(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/ping", func(c *fiber.Ctx) error { + app.Get("/ping", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -794,7 +794,7 @@ func TestWithTelemetry_TruncatesLongUserAgent(t *testing.T) { app := fiber.New() mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/x", func(c *fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) + app.Get("/x", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) longUA := strings.Repeat("a", 4000) req := httptest.NewRequest(http.MethodGet, "/x", nil) @@ -824,7 +824,7 @@ func TestWithTelemetry_TruncatesUserAgentAtRuneBoundary(t *testing.T) { app := fiber.New() mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/x", func(c *fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) + app.Get("/x", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) longUA := strings.Repeat("€", 1000) // 3000 bytes req := httptest.NewRequest(http.MethodGet, "/x", nil) @@ -860,7 +860,7 @@ func TestWithTelemetry_RecordsDurationWithTenantID(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/orders", func(c *fiber.Ctx) error { + app.Get("/api/orders", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -898,13 +898,13 @@ func TestWithTelemetry_RecordsDurationWithBaggageTenantID(t *testing.T) { // Seed the request UserContext with baggage-propagated tenant.id before the // telemetry middleware runs, mirroring an upstream service that injected // tenant.id into the OTel baggage rather than the X-Tenant-Id header. - app.Use(func(c *fiber.Ctx) error { - c.SetUserContext(ctxWithBaggageTenant(t, "acme")) + app.Use(func(c fiber.Ctx) error { + c.SetContext(ctxWithBaggageTenant(t, "acme")) return c.Next() }) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/orders", func(c *fiber.Ctx) error { + app.Get("/api/orders", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -934,7 +934,7 @@ func TestWithTelemetry_RecordsDurationWithoutTenantID(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/orders", func(c *fiber.Ctx) error { + app.Get("/api/orders", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -962,7 +962,7 @@ func TestWithTelemetry_RecordsDurationDropsOversizedTenantID(t *testing.T) { mid := NewTelemetryMiddleware(tel) app.Use(mid.WithTelemetry(tel)) - app.Get("/api/orders", func(c *fiber.Ctx) error { + app.Get("/api/orders", func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) diff --git a/middleware/telemetry_route_test.go b/middleware/telemetry_route_test.go index 0cc587c..8370523 100644 --- a/middleware/telemetry_route_test.go +++ b/middleware/telemetry_route_test.go @@ -8,8 +8,8 @@ import ( "net/http/httptest" "testing" - "github.com/LerianStudio/lib-observability/tracing" - "github.com/gofiber/fiber/v2" + "github.com/LerianStudio/lib-observability/v2/tracing" + "github.com/gofiber/fiber/v3" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel" diff --git a/middleware/telemetry_test.go b/middleware/telemetry_test.go index ccb39f0..2987f8c 100644 --- a/middleware/telemetry_test.go +++ b/middleware/telemetry_test.go @@ -12,9 +12,9 @@ import ( "testing" "time" - "github.com/LerianStudio/lib-observability/metrics" - "github.com/LerianStudio/lib-observability/tracing" - "github.com/gofiber/fiber/v2" + "github.com/LerianStudio/lib-observability/v2/metrics" + "github.com/LerianStudio/lib-observability/v2/tracing" + "github.com/gofiber/fiber/v3" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel" @@ -51,7 +51,7 @@ func TestWithTelemetry(t *testing.T) { name string path string method string - setupHandler func(c *fiber.Ctx) error + setupHandler func(c fiber.Ctx) error nilTelemetry bool traceparent string expectedStatusCode int @@ -62,7 +62,7 @@ func TestWithTelemetry(t *testing.T) { name: "Basic middleware functionality", path: "/api/resource", method: "GET", - setupHandler: func(c *fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, + setupHandler: func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, expectedStatusCode: http.StatusOK, expectSpan: true, }, @@ -70,7 +70,7 @@ func TestWithTelemetry(t *testing.T) { name: "Handler returns error", path: "/api/resource", method: "POST", - setupHandler: func(c *fiber.Ctx) error { return errors.New("handler error") }, + setupHandler: func(c fiber.Ctx) error { return errors.New("handler error") }, expectedStatusCode: http.StatusInternalServerError, expectSpan: true, }, @@ -78,7 +78,7 @@ func TestWithTelemetry(t *testing.T) { name: "Nil telemetry", path: "/api/resource", method: "GET", - setupHandler: func(c *fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, + setupHandler: func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, nilTelemetry: true, expectedStatusCode: http.StatusOK, expectSpan: false, @@ -87,7 +87,7 @@ func TestWithTelemetry(t *testing.T) { name: "With trace context", path: "/api/resource", method: "GET", - setupHandler: func(c *fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, + setupHandler: func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, traceparent: "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01", expectedStatusCode: http.StatusOK, expectSpan: true, @@ -96,7 +96,7 @@ func TestWithTelemetry(t *testing.T) { name: "UUID in path", path: "/api/users/123e4567-e89b-12d3-a456-426614174000/profile", method: "GET", - setupHandler: func(c *fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, + setupHandler: func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, expectedStatusCode: http.StatusOK, expectSpan: true, }, @@ -104,7 +104,7 @@ func TestWithTelemetry(t *testing.T) { name: "Swagger path bypass", path: "/swagger/api-docs", method: "GET", - setupHandler: func(c *fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, + setupHandler: func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }, expectedStatusCode: http.StatusOK, expectSpan: false, swaggerPath: true, @@ -138,7 +138,7 @@ func TestWithTelemetry(t *testing.T) { mid := NewTelemetryMiddleware(tel) app := fiber.New(fiber.Config{ - ErrorHandler: func(c *fiber.Ctx, err error) error { + ErrorHandler: func(c fiber.Ctx, err error) error { return c.Status(http.StatusInternalServerError).SendString(err.Error()) }, }) @@ -151,7 +151,7 @@ func TestWithTelemetry(t *testing.T) { } } - app.All(tt.path, func(c *fiber.Ctx) error { + app.All(tt.path, func(c fiber.Ctx) error { return tt.setupHandler(c) }) @@ -264,7 +264,7 @@ func TestWithTelemetryExcludedRoutes(t *testing.T) { app := fiber.New() app.Use(mid.WithTelemetry(tel, tt.excludedRoutes...)) - app.All(tt.path, func(c *fiber.Ctx) error { + app.All(tt.path, func(c fiber.Ctx) error { return c.SendStatus(http.StatusOK) }) @@ -343,8 +343,8 @@ func TestEndTracingSpans(t *testing.T) { app := fiber.New() - setupMiddleware := func(c *fiber.Ctx) error { - ctx := c.UserContext() + setupMiddleware := func(c fiber.Ctx) error { + ctx := c.Context() if ctx == nil { ctx = context.Background() } @@ -352,13 +352,13 @@ func TestEndTracingSpans(t *testing.T) { if tt.setupCtx { tracer := tp.Tracer("test") ctx, _ = tracer.Start(ctx, "test-span") - c.SetUserContext(ctx) + c.SetContext(ctx) } return c.Next() } - handler := func(c *fiber.Ctx) error { + handler := func(c fiber.Ctx) error { return tt.handlerErr } @@ -400,7 +400,7 @@ func TestEndTracingSpans_CallsNextWithoutInitialContext(t *testing.T) { mid := &TelemetryMiddleware{} handlerCalled := false - app.Get("/test", mid.EndTracingSpans, func(c *fiber.Ctx) error { + app.Get("/test", mid.EndTracingSpans, func(c fiber.Ctx) error { handlerCalled = true return c.SendStatus(http.StatusNoContent) }) @@ -422,9 +422,9 @@ func TestEndTracingSpans_EndsFinalContextSpan(t *testing.T) { app := fiber.New() mid := &TelemetryMiddleware{} - app.Get("/test", mid.EndTracingSpans, func(c *fiber.Ctx) error { + app.Get("/test", mid.EndTracingSpans, func(c fiber.Ctx) error { ctx, _ := tp.Tracer("test").Start(context.Background(), "handler-span") - c.SetUserContext(ctx) + c.SetContext(ctx) return c.SendStatus(http.StatusNoContent) }) @@ -572,8 +572,8 @@ func TestExtractHTTPContext(t *testing.T) { app := fiber.New() - app.Get("/test", func(c *fiber.Ctx) error { - ctx := tracing.ExtractHTTPContext(c.UserContext(), c) + app.Get("/test", func(c fiber.Ctx) error { + ctx := tracing.ExtractHTTPContext(c.Context(), c) spanCtx := oteltrace.SpanContextFromContext(ctx) @@ -663,8 +663,8 @@ func TestWithTelemetryConditionalTracePropagation(t *testing.T) { app.Use(mid.WithTelemetry(tel)) var capturedSpanContext oteltrace.SpanContext - app.Get("/test", func(c *fiber.Ctx) error { - capturedSpanContext = oteltrace.SpanContextFromContext(c.UserContext()) + app.Get("/test", func(c fiber.Ctx) error { + capturedSpanContext = oteltrace.SpanContextFromContext(c.Context()) return c.SendStatus(http.StatusOK) }) diff --git a/middleware/tenant.go b/middleware/tenant.go index 6a6de26..1a9130d 100644 --- a/middleware/tenant.go +++ b/middleware/tenant.go @@ -3,9 +3,9 @@ package middleware import ( "context" - observability "github.com/LerianStudio/lib-observability" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/gofiber/fiber/v2" + observability "github.com/LerianStudio/lib-observability/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/gofiber/fiber/v3" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/baggage" "google.golang.org/grpc/metadata" @@ -18,7 +18,7 @@ import ( // observability hint: callers MUST authenticate the tenant separately and // override via observability.ContextWithSpanAttributes when the real value // differs from the header. -func ResolveTenantIDFromHTTP(c *fiber.Ctx) string { +func ResolveTenantIDFromHTTP(c fiber.Ctx) string { if c == nil { return "" } diff --git a/middleware/tenant_test.go b/middleware/tenant_test.go index 9b1e712..982116c 100644 --- a/middleware/tenant_test.go +++ b/middleware/tenant_test.go @@ -9,9 +9,9 @@ import ( "strings" "testing" - observability "github.com/LerianStudio/lib-observability" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/gofiber/fiber/v2" + observability "github.com/LerianStudio/lib-observability/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/gofiber/fiber/v3" "github.com/stretchr/testify/assert" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/baggage" @@ -53,7 +53,7 @@ func TestResolveTenantIDFromHTTP(t *testing.T) { app := fiber.New() var got string - app.Get("/", func(c *fiber.Ctx) error { + app.Get("/", func(c fiber.Ctx) error { got = ResolveTenantIDFromHTTP(c) return nil }) diff --git a/observability.go b/observability.go index 7b3c5f3..ca6ee78 100644 --- a/observability.go +++ b/observability.go @@ -10,8 +10,8 @@ import ( "strings" "sync" - "github.com/LerianStudio/lib-observability/log" - "github.com/LerianStudio/lib-observability/metrics" + "github.com/LerianStudio/lib-observability/v2/log" + "github.com/LerianStudio/lib-observability/v2/metrics" "github.com/google/uuid" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" diff --git a/runtime/goroutine.go b/runtime/goroutine.go index a7f9bf9..7dda6f6 100644 --- a/runtime/goroutine.go +++ b/runtime/goroutine.go @@ -3,7 +3,7 @@ package runtime import ( "context" - "github.com/LerianStudio/lib-observability/log" + "github.com/LerianStudio/lib-observability/v2/log" ) // SafeGo launches a goroutine with panic recovery. If the goroutine panics, diff --git a/runtime/helpers_test.go b/runtime/helpers_test.go index 3644b62..be83a9e 100644 --- a/runtime/helpers_test.go +++ b/runtime/helpers_test.go @@ -9,7 +9,7 @@ import ( "sync/atomic" "time" - "github.com/LerianStudio/lib-observability/log" + "github.com/LerianStudio/lib-observability/v2/log" ) // testLogger is a test logger that captures log calls. diff --git a/runtime/log_mode_link_test.go b/runtime/log_mode_link_test.go index 39a5646..9233cae 100644 --- a/runtime/log_mode_link_test.go +++ b/runtime/log_mode_link_test.go @@ -9,7 +9,7 @@ import ( "sync" "testing" - "github.com/LerianStudio/lib-observability/log" + "github.com/LerianStudio/lib-observability/v2/log" "github.com/stretchr/testify/assert" ) diff --git a/runtime/metrics.go b/runtime/metrics.go index d6dc777..d7b3ab0 100644 --- a/runtime/metrics.go +++ b/runtime/metrics.go @@ -4,9 +4,9 @@ import ( "context" "sync" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/log" - "github.com/LerianStudio/lib-observability/metrics" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/log" + "github.com/LerianStudio/lib-observability/v2/metrics" ) // PanicMetrics provides panic-related metrics using OpenTelemetry. diff --git a/runtime/metrics_test.go b/runtime/metrics_test.go index 5e954a8..19e25c4 100644 --- a/runtime/metrics_test.go +++ b/runtime/metrics_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - constant "github.com/LerianStudio/lib-observability/constants" + constant "github.com/LerianStudio/lib-observability/v2/constants" "github.com/stretchr/testify/assert" ) diff --git a/runtime/recover.go b/runtime/recover.go index 6920762..9875a5e 100644 --- a/runtime/recover.go +++ b/runtime/recover.go @@ -4,7 +4,7 @@ import ( "context" "runtime/debug" - "github.com/LerianStudio/lib-observability/log" + "github.com/LerianStudio/lib-observability/v2/log" ) // Logger defines the minimal logging interface required by runtime. @@ -217,7 +217,7 @@ func recordPanicObservability( // Example (Fiber middleware): // // recover.New(recover.Config{ -// StackTraceHandler: func(c *fiber.Ctx, panicValue any) { +// StackTraceHandler: func(c fiber.Ctx, panicValue any) { // ctx := extractContext(c) // runtime.HandlePanicValue(ctx, logger, panicValue, "matcher", "http_handler") // }, diff --git a/runtime/tracing.go b/runtime/tracing.go index 6b13690..7785f2c 100644 --- a/runtime/tracing.go +++ b/runtime/tracing.go @@ -6,7 +6,7 @@ import ( "fmt" "regexp" - constant "github.com/LerianStudio/lib-observability/constants" + constant "github.com/LerianStudio/lib-observability/v2/constants" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/trace" diff --git a/system.go b/system.go index 155adf8..dc9b6c7 100644 --- a/system.go +++ b/system.go @@ -4,8 +4,8 @@ import ( "context" "time" - "github.com/LerianStudio/lib-observability/log" - "github.com/LerianStudio/lib-observability/metrics" + "github.com/LerianStudio/lib-observability/v2/log" + "github.com/LerianStudio/lib-observability/v2/metrics" "github.com/shirou/gopsutil/cpu" "github.com/shirou/gopsutil/mem" ) diff --git a/system_test.go b/system_test.go index 6970981..8e9b4d6 100644 --- a/system_test.go +++ b/system_test.go @@ -6,7 +6,7 @@ import ( "context" "testing" - "github.com/LerianStudio/lib-observability/metrics" + "github.com/LerianStudio/lib-observability/v2/metrics" "github.com/stretchr/testify/assert" ) diff --git a/tracing/obfuscation.go b/tracing/obfuscation.go index ab99b25..152f75d 100644 --- a/tracing/obfuscation.go +++ b/tracing/obfuscation.go @@ -10,8 +10,8 @@ import ( "fmt" "regexp" - cn "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/redaction" + cn "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/redaction" ) // RedactionAction defines how sensitive values are transformed. diff --git a/tracing/obfuscation_test.go b/tracing/obfuscation_test.go index 90477d0..5b067c6 100644 --- a/tracing/obfuscation_test.go +++ b/tracing/obfuscation_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - constant "github.com/LerianStudio/lib-observability/constants" + constant "github.com/LerianStudio/lib-observability/v2/constants" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/attribute" diff --git a/tracing/otel.go b/tracing/otel.go index d1231e5..94c42c5 100644 --- a/tracing/otel.go +++ b/tracing/otel.go @@ -14,13 +14,13 @@ import ( "strings" "unicode/utf8" - observability "github.com/LerianStudio/lib-observability" - "github.com/LerianStudio/lib-observability/assert" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/log" - "github.com/LerianStudio/lib-observability/metrics" - "github.com/LerianStudio/lib-observability/redaction" - "github.com/gofiber/fiber/v2" + observability "github.com/LerianStudio/lib-observability/v2" + "github.com/LerianStudio/lib-observability/v2/assert" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/log" + "github.com/LerianStudio/lib-observability/v2/metrics" + "github.com/LerianStudio/lib-observability/v2/redaction" + "github.com/gofiber/fiber/v3" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" @@ -738,7 +738,7 @@ func truncateUTF8(s string, maxBytes int) string { // SetSpanAttributeForParam adds a request parameter attribute to the current context bag. // Sensitive parameter names (as determined by redaction.IsSensitiveField) are masked. -func SetSpanAttributeForParam(c *fiber.Ctx, param, value, entityName string) { +func SetSpanAttributeForParam(c fiber.Ctx, param, value, entityName string) { if c == nil { return } @@ -754,7 +754,7 @@ func SetSpanAttributeForParam(c *fiber.Ctx, param, value, entityName string) { attrValue = "[REDACTED]" } - c.SetUserContext(observability.ContextWithSpanAttributes(c.UserContext(), attribute.String(spanAttrKey, attrValue))) + c.SetContext(observability.ContextWithSpanAttributes(c.Context(), attribute.String(spanAttrKey, attrValue))) } // InjectTraceContext injects trace context into a generic text map carrier. @@ -785,7 +785,7 @@ func InjectHTTPContext(ctx context.Context, headers http.Header) { } // ExtractHTTPContext extracts trace headers from a Fiber request. -func ExtractHTTPContext(ctx context.Context, c *fiber.Ctx) context.Context { +func ExtractHTTPContext(ctx context.Context, c fiber.Ctx) context.Context { if c == nil { return ctx } diff --git a/tracing/otel_test.go b/tracing/otel_test.go index 2592f06..25a0b69 100644 --- a/tracing/otel_test.go +++ b/tracing/otel_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - observability "github.com/LerianStudio/lib-observability" - constant "github.com/LerianStudio/lib-observability/constants" - "github.com/LerianStudio/lib-observability/log" + observability "github.com/LerianStudio/lib-observability/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" + "github.com/LerianStudio/lib-observability/v2/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel" diff --git a/tracing/processor.go b/tracing/processor.go index e5bceac..a90d464 100644 --- a/tracing/processor.go +++ b/tracing/processor.go @@ -4,8 +4,8 @@ import ( "context" "strings" - observability "github.com/LerianStudio/lib-observability" - constant "github.com/LerianStudio/lib-observability/constants" + observability "github.com/LerianStudio/lib-observability/v2" + constant "github.com/LerianStudio/lib-observability/v2/constants" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/baggage" sdktrace "go.opentelemetry.io/otel/sdk/trace" diff --git a/tracing/v2_test.go b/tracing/v2_test.go index 406b5f6..63b1a1d 100644 --- a/tracing/v2_test.go +++ b/tracing/v2_test.go @@ -7,7 +7,7 @@ import ( "encoding/json" "testing" - "github.com/LerianStudio/lib-observability/log" + "github.com/LerianStudio/lib-observability/v2/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel" diff --git a/zap/zap.go b/zap/zap.go index 70fc24b..a1f27be 100644 --- a/zap/zap.go +++ b/zap/zap.go @@ -6,9 +6,9 @@ import ( "strings" "time" - logpkg "github.com/LerianStudio/lib-observability/log" - "github.com/LerianStudio/lib-observability/redaction" - "github.com/LerianStudio/lib-observability/runtime" + logpkg "github.com/LerianStudio/lib-observability/v2/log" + "github.com/LerianStudio/lib-observability/v2/redaction" + "github.com/LerianStudio/lib-observability/v2/runtime" "go.opentelemetry.io/otel/trace" "go.uber.org/zap" "go.uber.org/zap/zapcore" diff --git a/zap/zap_test.go b/zap/zap_test.go index 7e966f7..104024a 100644 --- a/zap/zap_test.go +++ b/zap/zap_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - logpkg "github.com/LerianStudio/lib-observability/log" + logpkg "github.com/LerianStudio/lib-observability/v2/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/trace" From ddb09cc3a2771cbbff41785d1f22d57104c98654 Mon Sep 17 00:00:00 2001 From: rodrigodh Date: Tue, 14 Jul 2026 13:56:49 -0300 Subject: [PATCH 2/2] chore(ci): accept GO-2026-5932 (unmaintained x/crypto/openpgp) Fiber v3 pulls golang.org/x/crypto via acme/autocert; the openpgp unmaintained advisory has no fixed version and the package is not imported. Matches the suppression already present on other services' develop. X-Lerian-Ref: 0x1 --- .trivyignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .trivyignore diff --git a/.trivyignore b/.trivyignore new file mode 100644 index 0000000..3554440 --- /dev/null +++ b/.trivyignore @@ -0,0 +1,5 @@ +# GO-2026-5932: golang.org/x/crypto/openpgp is unmaintained (no upstream fix). +# Introduced transitively by gofiber/fiber/v3 -> golang.org/x/crypto/acme/autocert. +# The openpgp package is not imported by this module. Accepted risk. +# Revisit 2026-07-30. +GO-2026-5932 exp:2026-07-30