From 2512123b7686dca1f7f0208eaada6cdf3ef0189c Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Tue, 23 Jan 2024 13:09:47 +0200 Subject: [PATCH 01/11] chore: update OpenTelemetry and Uptrace to the latest version (#2864) * chore: update OpenTelemetry and Uptrace to the latest version * chore: remove Go 1.19.x build since many popular Go packages only support 2 last major Go versions * chore: bump uptrace version --- .github/workflows/build.yml | 2 +- example/otel/config/otel-collector.yaml | 20 +++--- example/otel/docker-compose.yml | 6 +- example/otel/go.mod | 46 +++++++------- example/otel/go.sum | 48 +++++++++++++++ example/otel/uptrace.yml | 82 +++++++++++++------------ 6 files changed, 130 insertions(+), 74 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4061bbdff..e78801685 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - go-version: [1.19.x, 1.20.x, 1.21.x] + go-version: [1.20.x, 1.21.x] services: redis: diff --git a/example/otel/config/otel-collector.yaml b/example/otel/config/otel-collector.yaml index 3e64cb455..2cb130dd6 100644 --- a/example/otel/config/otel-collector.yaml +++ b/example/otel/config/otel-collector.yaml @@ -30,18 +30,18 @@ receivers: processors: resourcedetection: detectors: ['system'] + cumulativetodelta: batch: send_batch_size: 10000 timeout: 10s exporters: - logging: - logLevel: debug - otlp: - endpoint: uptrace:14317 + otlp/uptrace: + endpoint: http://uptrace:14317 tls: insecure: true headers: { 'uptrace-dsn': 'http://project2_secret_token@localhost:14317/2' } + debug: service: # telemetry: @@ -51,18 +51,18 @@ service: traces: receivers: [otlp, jaeger] processors: [batch] - exporters: [otlp, logging] + exporters: [otlp/uptrace] metrics: receivers: [otlp] - processors: [batch] - exporters: [otlp] + processors: [cumulativetodelta, batch] + exporters: [otlp/uptrace] metrics/hostmetrics: receivers: [hostmetrics, redis] - processors: [batch, resourcedetection] - exporters: [otlp] + processors: [cumulativetodelta, batch, resourcedetection] + exporters: [otlp/uptrace] logs: receivers: [otlp] processors: [batch] - exporters: [otlp] + exporters: [otlp/uptrace] extensions: [health_check, pprof, zpages] diff --git a/example/otel/docker-compose.yml b/example/otel/docker-compose.yml index 92c7958d2..4244792a9 100644 --- a/example/otel/docker-compose.yml +++ b/example/otel/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: clickhouse: - image: clickhouse/clickhouse-server:22.10 + image: clickhouse/clickhouse-server:23.7 restart: on-failure environment: CLICKHOUSE_DB: uptrace @@ -36,7 +36,7 @@ services: - '5432:5432' uptrace: - image: 'uptrace/uptrace:1.5.0' + image: 'uptrace/uptrace:1.6.2' #image: 'uptrace/uptrace-dev:latest' restart: on-failure volumes: @@ -51,7 +51,7 @@ services: condition: service_healthy otelcol: - image: otel/opentelemetry-collector-contrib:0.70.0 + image: otel/opentelemetry-collector-contrib:0.91.0 restart: on-failure volumes: - ./config/otel-collector.yaml:/etc/otelcol-contrib/config.yaml diff --git a/example/otel/go.mod b/example/otel/go.mod index 4d2d9df81..3b2a7a002 100644 --- a/example/otel/go.mod +++ b/example/otel/go.mod @@ -11,35 +11,37 @@ replace github.com/redis/go-redis/extra/rediscmd/v9 => ../../extra/rediscmd require ( github.com/redis/go-redis/extra/redisotel/v9 v9.4.0 github.com/redis/go-redis/v9 v9.4.0 - github.com/uptrace/uptrace-go v1.16.0 - go.opentelemetry.io/otel v1.16.0 + github.com/uptrace/uptrace-go v1.21.0 + go.opentelemetry.io/otel v1.21.0 ) require ( github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/logr v1.4.1 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect github.com/redis/go-redis/extra/rediscmd/v9 v9.4.0 // indirect - go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.39.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 // indirect - go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 // indirect - go.opentelemetry.io/otel/metric v1.16.0 // indirect - go.opentelemetry.io/otel/sdk v1.16.0 // indirect - go.opentelemetry.io/otel/sdk/metric v0.39.0 // indirect - go.opentelemetry.io/otel/trace v1.16.0 // indirect - go.opentelemetry.io/proto/otlp v0.19.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.30.0 // indirect + go.opentelemetry.io/contrib/instrumentation/runtime v0.46.1 // indirect + go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.17.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.43.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect + go.opentelemetry.io/otel/metric v1.21.0 // indirect + go.opentelemetry.io/otel/sdk v1.21.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect + go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.opentelemetry.io/proto/otlp v1.0.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/text v0.14.0 // indirect + google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect + google.golang.org/grpc v1.60.1 // indirect + google.golang.org/protobuf v1.32.0 // indirect ) diff --git a/example/otel/go.sum b/example/otel/go.sum index c40f81d0f..c07aa0100 100644 --- a/example/otel/go.sum +++ b/example/otel/go.sum @@ -77,6 +77,8 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -139,6 +141,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFb github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2 h1:gDLXvp5S9izjldquuoAhDzccbskOL6tDC5jMSyx3zxE= github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.2/go.mod h1:7pdNwVWBBHGiCxa9lAszqCJMbfTISJ7oMftp8+UGV08= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -161,6 +165,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/uptrace/uptrace-go v1.16.0 h1:yB9vt1hBYYoXWExNx0okubLOjd339d7lH+/5o+Lp+MY= github.com/uptrace/uptrace-go v1.16.0/go.mod h1:Ssc5wLpoL+9V0qkT5FtrIiru9SY4xb7q1UVLjSpxpCg= +github.com/uptrace/uptrace-go v1.21.0 h1:oJoUjhiVT7aiuoG6B3ClVHtJozLn3cK9hQt8U5dQO1M= +github.com/uptrace/uptrace-go v1.21.0/go.mod h1:/aXAFGKOqeAFBqWa1xtzLnGX2xJm1GScqz9NJ0TJjLM= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -171,31 +177,57 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0 h1:EbmAUG9hEAMXyfWEasIt2kmh/WmXUznUksChApTgBGc= go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0/go.mod h1:rD9feqRYP24P14t5kmhNMqsqm1jvKmpx2H2rKVw52V8= +go.opentelemetry.io/contrib/instrumentation/runtime v0.46.1 h1:m9ReioVPIffxjJlGNRd0d5poy+9oTro3D+YbiEzUDOc= +go.opentelemetry.io/contrib/instrumentation/runtime v0.46.1/go.mod h1:CANkrsXNzqOKXfOomu2zhOmc1/J5UZK9SGjrat6ZCG0= go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= +go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= +go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 h1:t4ZwRPU+emrcvM2e9DHd0Fsf0JTPVcbfa/BhTDF03d0= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0/go.mod h1:vLarbg68dH2Wa77g71zmKQqlQ8+8Rq3GRG31uc0WcWI= +go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.17.0 h1:eU0ffpYuEY7eQ75K+nKr9CI5KcY8h+GPk/9DDlEO1NI= +go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.17.0/go.mod h1:9P5RK5JS2sjKepuCkqFwPp3etwV/57E0eigLw18Mn1k= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 h1:f6BwB2OACc3FCbYVznctQ9V6KK7Vq6CjmYXJ7DeSs4E= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0/go.mod h1:UqL5mZ3qs6XYhDnZaW1Ps4upD+PX6LipH40AoeuIlwU= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.43.0 h1:f+VtlQwREKbGdbq/Mx/xMDLrPktBZ1+5PzNMrYSsdXo= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.43.0/go.mod h1:V0A1wlhxQUdvqQk+vMA5+NwT7I6AFSyQv1EXLQBb8dM= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.39.0 h1:rm+Fizi7lTM2UefJ1TO347fSRcwmIsUAaZmYmIGBRAo= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.39.0/go.mod h1:sWFbI3jJ+6JdjOVepA5blpv/TJ20Hw+26561iMbWcwU= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0 h1:jd0+5t/YynESZqsSyPz+7PAFdEop0dlN0+PkyHYo8oI= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0/go.mod h1:U707O40ee1FpQGyhvqnzmCJm1Wh6OX6GGBVn0E6Uyyk= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 h1:cbsD4cUcviQGXdw8+bo5x2wazq10SKz8hEbtCRPcU78= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0/go.mod h1:JgXSGah17croqhJfhByOLVY719k1emAXC8MVhCIJlRs= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 h1:TVQp/bboR4mhZSav+MdgXB8FaRho1RC8UwVn3T0vjVc= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0/go.mod h1:I33vtIe0sR96wfrUcilIzLoA3mLHhRmz9S9Te0S3gDo= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 h1:tIqheXEFWAZ7O8A7m+J0aPTmpJN3YQ7qetUAdkkkKpk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0/go.mod h1:nUeKExfxAQVbiVFn32YXpXZZHZ61Cc3s3Rn1pDBGAb0= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 h1:+XWJd3jf75RXJq29mxbuXhCXFDG3S3R4vBUeSI2P7tE= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0/go.mod h1:hqgzBPTf4yONMFgdZvL/bK42R/iinTyVQtiWihs3SZc= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 h1:VhlEQAPp9R1ktYfrPk5SOryw1e9LDDTZCbIPFrho0ec= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0/go.mod h1:kB3ufRbfU+CQ4MlUcqtW8Z7YEOBeK2DJ6CmR5rYYF3E= go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= +go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= +go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE= go.opentelemetry.io/otel/sdk v1.16.0/go.mod h1:tMsIuKXuuIWPBAOrH+eHtvhTL+SntFtXF9QD68aP6p4= +go.opentelemetry.io/otel/sdk v1.21.0 h1:FTt8qirL1EysG6sTQRZ5TokkU8d0ugCj8htOgThZXQ8= +go.opentelemetry.io/otel/sdk v1.21.0/go.mod h1:Nna6Yv7PWTdgJHVRD9hIYywQBRx7pbox6nwBnZIxl/E= go.opentelemetry.io/otel/sdk/metric v0.39.0 h1:Kun8i1eYf48kHH83RucG93ffz0zGV1sh46FAScOTuDI= go.opentelemetry.io/otel/sdk/metric v0.39.0/go.mod h1:piDIRgjcK7u0HCL5pCA4e74qpK/jk3NiUoAHATVAmiI= +go.opentelemetry.io/otel/sdk/metric v1.21.0 h1:smhI5oD714d6jHE6Tie36fPx4WDFIg+Y6RfAY4ICcR0= +go.opentelemetry.io/otel/sdk/metric v1.21.0/go.mod h1:FJ8RAsoPGv/wYMgBdUJXOm+6pzFY3YdljnXtv1SBE8Q= go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= +go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= +go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= +go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= +go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -261,6 +293,8 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -305,6 +339,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -314,6 +350,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -416,6 +454,12 @@ google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 h1:/IWabOtPziuXTEtI1KYCpM6Ss7vaAkeMxk+uXV/xvZs= +google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= +google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 h1:OPXtXn7fNMaXwO3JvOmF1QyTc00jsSFFz1vXXBOdCDo= +google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:B5xPO//w8qmBDjGReYLpR6UJPnkldGkCSMoH/2vxJeg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 h1:gphdwh0npgs8elJ4T6J+DQJHPVF7RsuJHCfwztUb4J4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -434,6 +478,8 @@ google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9K google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -449,6 +495,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= diff --git a/example/otel/uptrace.yml b/example/otel/uptrace.yml index 0fa28bcac..90ecbf750 100644 --- a/example/otel/uptrace.yml +++ b/example/otel/uptrace.yml @@ -22,12 +22,16 @@ ch: password: database: uptrace + # Maximum query execution time. + max_execution_time: 30s + # TLS configuration. Uncomment to enable. # tls: # insecure_skip_verify: true - # Maximum query execution time. - max_execution_time: 30s + # TLS configuration. Uncomment to enable. + # tls: + # insecure_skip_verify: true # only for self-signed certificates ## ## PostgreSQL db that is used to store metadata such us metric names, dashboards, alerts, @@ -49,13 +53,15 @@ projects: # Token grants write access to the project. Keep a secret. token: project1_secret_token pinned_attrs: - - service.name - - host.name - - deployment.environment + - service_name + - host_name + - deployment_environment # Group spans by deployment.environment attribute. group_by_env: false # Group funcs spans by service.name attribute. group_funcs_by_service: false + # Enable prom_compat if you want to use the project as a Prometheus datasource in Grafana. + prom_compat: true # Other projects can be used to monitor your applications. # To monitor micro-services or multiple related services, use a single project. @@ -63,13 +69,12 @@ projects: name: My project token: project2_secret_token pinned_attrs: - - service.name - - host.name - - deployment.environment - # Group spans by deployment.environment attribute. + - service_name + - host_name + - deployment_environment group_by_env: false - # Group funcs spans by service.name attribute. group_funcs_by_service: false + prom_compat: true ## ## Create metrics from spans and events. @@ -79,30 +84,30 @@ metrics_from_spans: description: Spans duration (excluding events) instrument: histogram unit: microseconds - value: .duration / 1000 + value: _duration / 1000 attrs: - - .system - - .group_id - - service.name - - host.name - - .status_code + - _system + - _group_id + - service_name + - host_name + - _status_code annotations: - - display.name - where: .event_name = '' + - display_name + where: _event_name = '' - name: uptrace.tracing.events description: Events count (excluding spans) instrument: counter unit: 1 - value: .count + value: _count attrs: - - .system - - .group_id - - .name - - host.name + - _system + - _group_id + - _name + - host_name annotations: - - display.name - where: .is_event = 1 + - display_name + where: _is_event = 1 ## ## To require authentication, uncomment one of the following sections. @@ -158,12 +163,12 @@ ch_schema: spans: # Delete spans data after 30 days. - ttl_delete: 30 DAY + ttl_delete: 7 DAY storage_policy: 'default' metrics: # Delete metrics data after 90 days. - ttl_delete: 90 DAY + ttl_delete: 30 DAY storage_policy: 'default' ## @@ -173,16 +178,14 @@ listen: # OTLP/gRPC API. grpc: addr: ':14317' - # tls: - # cert_file: config/tls/uptrace.crt - # key_file: config/tls/uptrace.key # OTLP/HTTP API and Uptrace API with UI. http: addr: ':14318' - # tls: - # cert_file: config/tls/uptrace.crt - # key_file: config/tls/uptrace.key + + # tls: + # cert_file: config/tls/uptrace.crt + # key_file: config/tls/uptrace.key ## ## Various options for Uptrace UI. @@ -190,8 +193,6 @@ listen: site: # Overrides public URL for Vue-powered UI in case you put Uptrace behind a proxy. #addr: 'https://uptrace.mydomain.com' - # The base path for the Vue-powered UI in case you serve Uptrace UI behind a sub path. - path: '/' ## ## Spans processing options. @@ -210,9 +211,9 @@ spans: metrics: # List of attributes to drop for being noisy. drop_attrs: - - telemetry.sdk.language - - telemetry.sdk.name - - telemetry.sdk.version + - telemetry_sdk_language + - telemetry_sdk_name + - telemetry_sdk_version # The size of the Go chan used to buffer incoming measures. # If the buffer is full, Uptrace starts to drop measures. @@ -226,7 +227,12 @@ metrics: ## Uptrace sends internal telemetry here. Defaults to listen.grpc.addr. ## uptrace_go: + # Enabled by default. + #disabled: true + + # Defaults to the first projects. # dsn: http://project1_secret_token@localhost:14317/1 + # tls: # cert_file: config/tls/uptrace.crt # key_file: config/tls/uptrace.key From 83dd4d7200f83d8123fdb39d9f4748d04b8ab84e Mon Sep 17 00:00:00 2001 From: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:02:52 +0200 Subject: [PATCH 02/11] Change RE image to edge-focal (#2884) * Change RE image to edge-focal * Fix typo * change tag to 7.2.4-108 --- .github/workflows/test-redis-enterprise.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-redis-enterprise.yml b/.github/workflows/test-redis-enterprise.yml index d14766fb1..82946dd3c 100644 --- a/.github/workflows/test-redis-enterprise.yml +++ b/.github/workflows/test-redis-enterprise.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: go-version: [1.21.x] - re-build: ["7.2.4-92"] + re-build: ["7.2.4-108"] steps: - name: Checkout code From ffe9125a2415c51921362742bc1fa01ed9dfebe9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:03:49 +0200 Subject: [PATCH 03/11] chore(deps): bump golangci/golangci-lint-action from 3 to 4 (#2890) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3 to 4. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](https://github.com/golangci/golangci-lint-action/compare/v3...v4) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index e35ee85c0..a139f5dab 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -23,4 +23,4 @@ jobs: steps: - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 From a1577376e178e609522098e0cd1c8fd048ce7a03 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:04:25 +0200 Subject: [PATCH 04/11] chore(deps): bump rojopolis/spellcheck-github-actions (#2889) Bumps [rojopolis/spellcheck-github-actions](https://github.com/rojopolis/spellcheck-github-actions) from 0.35.0 to 0.36.0. - [Release notes](https://github.com/rojopolis/spellcheck-github-actions/releases) - [Changelog](https://github.com/rojopolis/spellcheck-github-actions/blob/master/CHANGELOG.md) - [Commits](https://github.com/rojopolis/spellcheck-github-actions/compare/0.35.0...0.36.0) --- updated-dependencies: - dependency-name: rojopolis/spellcheck-github-actions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- .github/workflows/spellcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml index a48781aa8..f739a5424 100644 --- a/.github/workflows/spellcheck.yml +++ b/.github/workflows/spellcheck.yml @@ -8,7 +8,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Check Spelling - uses: rojopolis/spellcheck-github-actions@0.35.0 + uses: rojopolis/spellcheck-github-actions@0.36.0 with: config_path: .github/spellcheck-settings.yml task_name: Markdown From 36bab9c8dc72a894c81a2d23171c95a0815af8d8 Mon Sep 17 00:00:00 2001 From: Oleg Stotsky Date: Thu, 15 Feb 2024 00:14:50 +0400 Subject: [PATCH 05/11] fix ConnPool race in newConn (#2885) Co-authored-by: Oleg Stotskiy Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- internal/pool/pool.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/pool/pool.go b/internal/pool/pool.go index 986c05d0a..2125f3e13 100644 --- a/internal/pool/pool.go +++ b/internal/pool/pool.go @@ -168,9 +168,12 @@ func (p *ConnPool) newConn(ctx context.Context, pooled bool) (*Conn, error) { return nil, ErrClosed } + p.connsMu.Lock() if p.cfg.MaxActiveConns > 0 && p.poolSize >= p.cfg.MaxActiveConns { + p.connsMu.Unlock() return nil, ErrPoolExhausted } + p.connsMu.Unlock() cn, err := p.dialConn(ctx, pooled) if err != nil { @@ -180,6 +183,11 @@ func (p *ConnPool) newConn(ctx context.Context, pooled bool) (*Conn, error) { p.connsMu.Lock() defer p.connsMu.Unlock() + if p.cfg.MaxActiveConns > 0 && p.poolSize >= p.cfg.MaxActiveConns { + _ = cn.Close() + return nil, ErrPoolExhausted + } + p.conns = append(p.conns, cn) if pooled { // If pool is full remove the cn on next Put. From 8d2a022fd5fbe71ee011004295d6991d894e811b Mon Sep 17 00:00:00 2001 From: Nanthen Hale Date: Thu, 15 Feb 2024 04:15:30 +0800 Subject: [PATCH 06/11] Add support for specifying bitcount unit as byte or bit, byte default (#2887) * Add support for specifying bitcount unit as byte or bit, byte default * Add bitcount test * Test bitcount without unit specified --------- Co-authored-by: wanghongwei5 Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- bitmap_commands.go | 14 ++++++ bitmap_commands_test.go | 98 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 bitmap_commands_test.go diff --git a/bitmap_commands.go b/bitmap_commands.go index 550d7f528..d9fc50dce 100644 --- a/bitmap_commands.go +++ b/bitmap_commands.go @@ -2,6 +2,7 @@ package redis import ( "context" + "errors" ) type BitMapCmdable interface { @@ -37,15 +38,28 @@ func (c cmdable) SetBit(ctx context.Context, key string, offset int64, value int type BitCount struct { Start, End int64 + Unit string // BYTE(default) | BIT } +const BitCountIndexByte string = "BYTE" +const BitCountIndexBit string = "BIT" + func (c cmdable) BitCount(ctx context.Context, key string, bitCount *BitCount) *IntCmd { args := []interface{}{"bitcount", key} if bitCount != nil { + if bitCount.Unit == "" { + bitCount.Unit = "BYTE" + } + if bitCount.Unit != BitCountIndexByte && bitCount.Unit != BitCountIndexBit { + cmd := NewIntCmd(ctx) + cmd.SetErr(errors.New("redis: invalid bitcount index")) + return cmd + } args = append( args, bitCount.Start, bitCount.End, + string(bitCount.Unit), ) } cmd := NewIntCmd(ctx, args...) diff --git a/bitmap_commands_test.go b/bitmap_commands_test.go new file mode 100644 index 000000000..f3cc3205f --- /dev/null +++ b/bitmap_commands_test.go @@ -0,0 +1,98 @@ +package redis_test + +import ( + . "github.com/bsm/ginkgo/v2" + . "github.com/bsm/gomega" + "github.com/redis/go-redis/v9" +) + +type bitCountExpected struct { + Start int64 + End int64 + Expected int64 +} + +var _ = Describe("BitCountBite", func() { + var client *redis.Client + key := "bit_count_test" + + BeforeEach(func() { + client = redis.NewClient(redisOptions()) + Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred()) + values := []int{0, 1, 0, 0, 1, 0, 1, 0, 1, 1} + for i, v := range values { + cmd := client.SetBit(ctx, key, int64(i), v) + Expect(cmd.Err()).NotTo(HaveOccurred()) + } + }) + + AfterEach(func() { + Expect(client.Close()).NotTo(HaveOccurred()) + }) + + It("bit count bite", func() { + var expected = []bitCountExpected{ + {0, 0, 0}, + {0, 1, 1}, + {0, 2, 1}, + {0, 3, 1}, + {0, 4, 2}, + {0, 5, 2}, + {0, 6, 3}, + {0, 7, 3}, + {0, 8, 4}, + {0, 9, 5}, + } + + for _, e := range expected { + cmd := client.BitCount(ctx, key, &redis.BitCount{Start: e.Start, End: e.End, Unit: redis.BitCountIndexBit}) + Expect(cmd.Err()).NotTo(HaveOccurred()) + Expect(cmd.Val()).To(Equal(e.Expected)) + } + }) +}) + +var _ = Describe("BitCountByte", func() { + var client *redis.Client + key := "bit_count_test" + + BeforeEach(func() { + client = redis.NewClient(redisOptions()) + Expect(client.FlushDB(ctx).Err()).NotTo(HaveOccurred()) + values := []int{0, 0, 0, 0, 0, 0, 0, 1, 1, 1} + for i, v := range values { + cmd := client.SetBit(ctx, key, int64(i), v) + Expect(cmd.Err()).NotTo(HaveOccurred()) + } + }) + + AfterEach(func() { + Expect(client.Close()).NotTo(HaveOccurred()) + }) + + It("bit count byte", func() { + var expected = []bitCountExpected{ + {0, 0, 1}, + {0, 1, 3}, + } + + for _, e := range expected { + cmd := client.BitCount(ctx, key, &redis.BitCount{Start: e.Start, End: e.End, Unit: redis.BitCountIndexByte}) + Expect(cmd.Err()).NotTo(HaveOccurred()) + Expect(cmd.Val()).To(Equal(e.Expected)) + } + }) + + It("bit count byte with no unit specified", func() { + var expected = []bitCountExpected{ + {0, 0, 1}, + {0, 1, 3}, + } + + for _, e := range expected { + cmd := client.BitCount(ctx, key, &redis.BitCount{Start: e.Start, End: e.End}) + Expect(cmd.Err()).NotTo(HaveOccurred()) + Expect(cmd.Val()).To(Equal(e.Expected)) + } + }) +}) From afffb47b0b169f0ce1097801db0104f231bf46be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 22:15:44 +0200 Subject: [PATCH 07/11] chore(deps): bump release-drafter/release-drafter from 5 to 6 (#2883) Bumps [release-drafter/release-drafter](https://github.com/release-drafter/release-drafter) from 5 to 6. - [Release notes](https://github.com/release-drafter/release-drafter/releases) - [Commits](https://github.com/release-drafter/release-drafter/compare/v5...v6) --- updated-dependencies: - dependency-name: release-drafter/release-drafter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index eebb3e678..6695abfe4 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: # Drafts your next Release notes as Pull Requests are merged into "master" - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v6 with: # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml config-name: release-drafter-config.yml From 51897bc5bf5ad2e6ec4e126ce585a4c0d29eb8a0 Mon Sep 17 00:00:00 2001 From: limotley <54456437+limotley@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:16:27 -0800 Subject: [PATCH 08/11] Remove unnecessary Node project definition file (#2863) Co-authored-by: Personalizer Team Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- package.json | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 package.json diff --git a/package.json b/package.json deleted file mode 100644 index 1a690047d..000000000 --- a/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "redis", - "version": "9.4.0", - "main": "index.js", - "repository": "git@github.com:redis/go-redis.git", - "author": "Vladimir Mihailenco ", - "license": "BSD-2-clause" -} From 9133749cd3ef42459a8698b59ab212537db5fb98 Mon Sep 17 00:00:00 2001 From: "fengyun.rui" Date: Thu, 15 Feb 2024 04:16:50 +0800 Subject: [PATCH 09/11] test: add ut for util_test (#2840) Signed-off-by: rfyiamcool Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- internal/util_test.go | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 internal/util_test.go diff --git a/internal/util_test.go b/internal/util_test.go new file mode 100644 index 000000000..f090ebaa4 --- /dev/null +++ b/internal/util_test.go @@ -0,0 +1,53 @@ +package internal + +import ( + "strings" + "testing" + + . "github.com/bsm/ginkgo/v2" + . "github.com/bsm/gomega" +) + +func BenchmarkToLowerStd(b *testing.B) { + str := "AaBbCcDdEeFfGgHhIiJjKk" + for i := 0; i < b.N; i++ { + _ = strings.ToLower(str) + } +} + +// util.ToLower is 3x faster than strings.ToLower. +func BenchmarkToLowerInternal(b *testing.B) { + str := "AaBbCcDdEeFfGgHhIiJjKk" + for i := 0; i < b.N; i++ { + _ = ToLower(str) + } +} + +func TestToLower(t *testing.T) { + It("toLower", func() { + str := "AaBbCcDdEeFfGg" + Expect(ToLower(str)).To(Equal(strings.ToLower(str))) + + str = "ABCDE" + Expect(ToLower(str)).To(Equal(strings.ToLower(str))) + + str = "ABCDE" + Expect(ToLower(str)).To(Equal(strings.ToLower(str))) + + str = "abced" + Expect(ToLower(str)).To(Equal(strings.ToLower(str))) + }) +} + +func TestIsLower(t *testing.T) { + It("isLower", func() { + str := "AaBbCcDdEeFfGg" + Expect(isLower(str)).To(BeFalse()) + + str = "ABCDE" + Expect(isLower(str)).To(BeFalse()) + + str = "abcdefg" + Expect(isLower(str)).To(BeTrue()) + }) +} From 7b9e81fd418e16d1317e6e896624a62b40cbbf80 Mon Sep 17 00:00:00 2001 From: "fengyun.rui" Date: Thu, 15 Feb 2024 04:22:32 +0800 Subject: [PATCH 10/11] fix: add bytes in scan struct example (#2836) * fix: add bytes in scan struct example Signed-off-by: rfyiamcool * fix: add bytes in scan struct example Signed-off-by: rfyiamcool --------- Signed-off-by: rfyiamcool Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- example/scan-struct/main.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/example/scan-struct/main.go b/example/scan-struct/main.go index 9d270b530..cc877b847 100644 --- a/example/scan-struct/main.go +++ b/example/scan-struct/main.go @@ -11,6 +11,7 @@ import ( type Model struct { Str1 string `redis:"str1"` Str2 string `redis:"str2"` + Bytes []byte `redis:"bytes"` Int int `redis:"int"` Bool bool `redis:"bool"` Ignored struct{} `redis:"-"` @@ -22,6 +23,7 @@ func main() { rdb := redis.NewClient(&redis.Options{ Addr: ":6379", }) + _ = rdb.FlushDB(ctx).Err() // Set some fields. if _, err := rdb.Pipelined(ctx, func(rdb redis.Pipeliner) error { @@ -29,6 +31,7 @@ func main() { rdb.HSet(ctx, "key", "str2", "world") rdb.HSet(ctx, "key", "int", 123) rdb.HSet(ctx, "key", "bool", 1) + rdb.HSet(ctx, "key", "bytes", []byte("this is bytes !")) return nil }); err != nil { panic(err) @@ -47,5 +50,28 @@ func main() { } spew.Dump(model1) + // Output: + // (main.Model) { + // Str1: (string) (len=5) "hello", + // Str2: (string) (len=5) "world", + // Bytes: ([]uint8) (len=15 cap=16) { + // 00000000 74 68 69 73 20 69 73 20 62 79 74 65 73 20 21 |this is bytes !| + // }, + // Int: (int) 123, + // Bool: (bool) true, + // Ignored: (struct {}) { + // } + // } + spew.Dump(model2) + // Output: + // (main.Model) { + // Str1: (string) (len=5) "hello", + // Str2: (string) "", + // Bytes: ([]uint8) , + // Int: (int) 123, + // Bool: (bool) false, + // Ignored: (struct {}) { + // } + // } } From 21ed15bbed2774a40fe831f7618332aa4f207fd1 Mon Sep 17 00:00:00 2001 From: Tiago Peczenyj Date: Wed, 14 Feb 2024 21:40:20 +0100 Subject: [PATCH 11/11] Add helpers to set libinfo without panic (#2724) * add helpers to set library name and library info without risk of panic if we try to set both * refactor code to use helpers * add example * refactor tests * fix testable example * simplify example * rename exampl * fix ring.go * update example --------- Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com> --- command.go | 10 ++++++++++ commands_test.go | 4 ++-- example_test.go | 24 +++++++++++++++++++++++- redis.go | 7 +++---- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/command.go b/command.go index 06ed86ed0..9fb9a8310 100644 --- a/command.go +++ b/command.go @@ -5310,6 +5310,16 @@ type LibraryInfo struct { LibVer *string } +// WithLibraryName returns a valid LibraryInfo with library name only. +func WithLibraryName(libName string) LibraryInfo { + return LibraryInfo{LibName: &libName} +} + +// WithLibraryVersion returns a valid LibraryInfo with library version only. +func WithLibraryVersion(libVer string) LibraryInfo { + return LibraryInfo{LibVer: &libVer} +} + // ------------------------------------------- type InfoCmd struct { diff --git a/commands_test.go b/commands_test.go index 3d2ebf514..fbeff1c20 100644 --- a/commands_test.go +++ b/commands_test.go @@ -248,7 +248,7 @@ var _ = Describe("Commands", func() { // Test setting the libName libName := "go-redis" - libInfo := redis.LibraryInfo{LibName: &libName} + libInfo := redis.WithLibraryName(libName) setInfo := pipe.ClientSetInfo(ctx, libInfo) _, err := pipe.Exec(ctx) @@ -258,7 +258,7 @@ var _ = Describe("Commands", func() { // Test setting the libVer libVer := "vX.x" - libInfo = redis.LibraryInfo{LibVer: &libVer} + libInfo = redis.WithLibraryVersion(libVer) setInfo = pipe.ClientSetInfo(ctx, libInfo) _, err = pipe.Exec(ctx) diff --git a/example_test.go b/example_test.go index 67559fcea..62aa8cb56 100644 --- a/example_test.go +++ b/example_test.go @@ -154,7 +154,7 @@ func ExampleClient() { // missing_key does not exist } -func ExampleConn() { +func ExampleConn_name() { conn := rdb.Conn() err := conn.ClientSetName(ctx, "foobar").Err() @@ -175,6 +175,28 @@ func ExampleConn() { // Output: foobar } +func ExampleConn_client_setInfo_libraryVersion() { + conn := rdb.Conn() + + err := conn.ClientSetInfo(ctx, redis.WithLibraryVersion("1.2.3")).Err() + if err != nil { + panic(err) + } + + // Open other connections. + for i := 0; i < 10; i++ { + go rdb.Ping(ctx) + } + + s, err := conn.ClientInfo(ctx).Result() + if err != nil { + panic(err) + } + + fmt.Println(s.LibVer) + // Output: 1.2.3 +} + func ExampleClient_Set() { // Last argument is expiration. Zero means the key has no // expiration time. diff --git a/redis.go b/redis.go index 4dd862b84..c8f513119 100644 --- a/redis.go +++ b/redis.go @@ -315,13 +315,12 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error { if !c.opt.DisableIndentity { libName := "" libVer := Version() + if c.opt.IdentitySuffix != "" { libName = c.opt.IdentitySuffix } - libInfo := LibraryInfo{LibName: &libName} - conn.ClientSetInfo(ctx, libInfo) - libInfo = LibraryInfo{LibVer: &libVer} - conn.ClientSetInfo(ctx, libInfo) + conn.ClientSetInfo(ctx, WithLibraryName(libName)) + conn.ClientSetInfo(ctx, WithLibraryVersion(libVer)) } _, err := conn.Pipelined(ctx, func(pipe Pipeliner) error { if !auth && password != "" {