From 170697534140da8ad4599c53206efd0788f3d678 Mon Sep 17 00:00:00 2001 From: idealism-xxm Date: Wed, 3 Jun 2020 09:41:05 +0800 Subject: [PATCH 1/2] feat(apmgoredisv8): support apm for go-redis v8 --- docs/instrumenting.asciidoc | 27 +++++ module/apmgoredisv8/doc.go | 21 ++++ module/apmgoredisv8/go.mod | 11 ++ module/apmgoredisv8/go.sum | 163 ++++++++++++++++++++++++++++++ module/apmgoredisv8/hook.go | 96 ++++++++++++++++++ module/apmgoredisv8/hook_test.go | 166 +++++++++++++++++++++++++++++++ scripts/Dockerfile-testing | 2 + 7 files changed, 486 insertions(+) create mode 100644 module/apmgoredisv8/doc.go create mode 100644 module/apmgoredisv8/go.mod create mode 100644 module/apmgoredisv8/go.sum create mode 100644 module/apmgoredisv8/hook.go create mode 100644 module/apmgoredisv8/hook_test.go diff --git a/docs/instrumenting.asciidoc b/docs/instrumenting.asciidoc index 68244171e..61aa0d1b4 100644 --- a/docs/instrumenting.asciidoc +++ b/docs/instrumenting.asciidoc @@ -20,6 +20,7 @@ that framework's API. The request context can be used for reporting <> * <> * <> +* <> * <> * <> * <> @@ -517,6 +518,32 @@ func handleRequest(w http.ResponseWriter, req *http.Request) { } ---- +[[builtin-modules-apmgoredisv8]] +==== module/apmgoredisv8 +Package apmgoredisv8 provides a means of instrumenting https://github.com/go-redis/redis[go-redis/redis] for v8 +so that Redis commands are reported as spans within the current transaction. + +To report Redis commands, you can call `AddHook(apmgoredis.NewGoRedisApmHook())` +from instance of `redis.Client`, `redis.ClusterClient`, or `redis.Ring`. + +[source,go] +---- +import ( + "github.com/go-redis/redis/v8" + + apmgoredis "go.elastic.co/apm/module/apmgoredisv8" +) + +func main() { + redisClient := redis.NewClient(&redis.Options{}) + // Add apm hook to redisClient. + // Redis commands will be reported as spans within the current transaction. + redisClient.AddHook(apmgoredis.NewGoRedisApmHook()) + + redisClient.Get(ctx, "key") +} +---- + [[builtin-modules-apmrestful]] ==== module/apmrestful Package apmrestful provides a https://github.com/emicklei/go-restful[go-restful] filter diff --git a/module/apmgoredisv8/doc.go b/module/apmgoredisv8/doc.go new file mode 100644 index 000000000..8199a85de --- /dev/null +++ b/module/apmgoredisv8/doc.go @@ -0,0 +1,21 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// +build go1.11 + +// Package apmgoredisv8 provides helpers for tracing github.com/go-redis/redis/v8 client operations as spans. +package apmgoredisv8 diff --git a/module/apmgoredisv8/go.mod b/module/apmgoredisv8/go.mod new file mode 100644 index 000000000..1b9369eb8 --- /dev/null +++ b/module/apmgoredisv8/go.mod @@ -0,0 +1,11 @@ +module go.elastic.co/apm/module/apmgoredisv8 + +go 1.14 + +require ( + github.com/go-redis/redis/v8 v8.0.0-beta.2 + github.com/stretchr/testify v1.4.0 + go.elastic.co/apm v1.8.0 +) + +replace go.elastic.co/apm => ../.. diff --git a/module/apmgoredisv8/go.sum b/module/apmgoredisv8/go.sum new file mode 100644 index 000000000..70ca94d6e --- /dev/null +++ b/module/apmgoredisv8/go.sum @@ -0,0 +1,163 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7 h1:qELHH0AWCvf98Yf+CNIJx9vOZOfHFDDzgDRYsnNk/vs= +github.com/DataDog/sketches-go v0.0.0-20190923095040-43f19ad77ff7/go.mod h1:Q5DbzQ+3AkgGwymQO7aZFNP7ns2lZKGtvRBzRXfdi60= +github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/benbjohnson/clock v1.0.0 h1:78Jk/r6m4wCi6sndMpty7A//t4dw/RW5fV4ZgDVfX1w= +github.com/benbjohnson/clock v1.0.0/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cucumber/godog v0.8.1 h1:lVb+X41I4YDreE+ibZ50bdXmySxgRviYFgKY6Aw4XE8= +github.com/cucumber/godog v0.8.1/go.mod h1:vSh3r/lM+psC1BPXvdkSEuNjmXfpVqrMGYAElF6hxnA= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/elastic/go-sysinfo v1.1.1 h1:ZVlaLDyhVkDfjwPGU55CQRCRolNpc7P0BbyhhQZQmMI= +github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= +github.com/elastic/go-windows v1.0.0 h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY= +github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/go-redis/redis/v8 v8.0.0-beta.2 h1:9S28J9QMBotgI3tGgXbX1Wk9i8QYC3Orw4bTLoPrQeI= +github.com/go-redis/redis/v8 v8.0.0-beta.2/go.mod h1:o1M7JtsgfDYyv3o+gBn/jJ1LkqpnCrmil7PSppZGBak= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4= +github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= +github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= +github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.3 h1:CTwfnzjQ+8dS6MhHHu4YswVAD99sL2wjPqP+VkURmKE= +github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= +github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis= +github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4= +go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI= +go.opentelemetry.io/otel v0.5.0 h1:tdIR1veg/z+VRJaw/6SIxz+QX3l+m+BDleYLTs+GC1g= +go.opentelemetry.io/otel v0.5.0/go.mod h1:jzBIgIzK43Iu1BpDAXwqOd6UPsSAk+ewVZ5ofSXw4Ek= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e h1:9vRrk9YW2BTzLP0VCB9ZDjU4cPqkg+IDWL7XgxA1yxQ= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03 h1:4HYDjxeNXAOTv3o1N2tjo8UUSlhQgAD52FVkwxnWgM8= +google.golang.org/genproto v0.0.0-20191009194640-548a555dbc03/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M= +howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= diff --git a/module/apmgoredisv8/hook.go b/module/apmgoredisv8/hook.go new file mode 100644 index 000000000..5c871bd0f --- /dev/null +++ b/module/apmgoredisv8/hook.go @@ -0,0 +1,96 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// +build go1.11 + +package apmgoredisv8 + +import ( + "bytes" + "context" + "strings" + + "github.com/go-redis/redis/v8" + + "go.elastic.co/apm" +) + +// goRedisApmHook is an implementation of redis.Hook that reports cmds as spans to Elastic APM. +type goRedisApmHook struct{} + +// NewGoRedisApmHook returns a redis.Hook that reports cmds as spans to Elastic APM. +func NewGoRedisApmHook() redis.Hook { + return &goRedisApmHook{} +} + +// BeforeProcess initiates the span for the redis cmd +func (r *goRedisApmHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error) { + span, ctx := apm.StartSpan(ctx, getCmdName(cmd), "db.redis") + return withSpan(ctx, span), nil +} + +// AfterProcess ends the initiated span from BeforeProcess +func (r *goRedisApmHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error { + if span := spanFromContext(ctx); span != nil { + span.End() + } + return nil +} + +// BeforeProcessPipeline initiates the span for the redis cmds +func (r *goRedisApmHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error) { + // Join all cmd names with ", ". + var cmdNameBuf bytes.Buffer + for i, cmd := range cmds { + if i != 0 { + cmdNameBuf.WriteString(", ") + } + cmdNameBuf.WriteString(getCmdName(cmd)) + } + + span, ctx := apm.StartSpan(ctx, cmdNameBuf.String(), "db.redis") + return withSpan(ctx, span), nil +} + +// AfterProcess ends the initiated span from BeforeProcessPipeline +func (r *goRedisApmHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error { + if span := spanFromContext(ctx); span != nil { + span.End() + } + return nil +} + +func getCmdName(cmd redis.Cmder) string { + cmdName := strings.ToUpper(cmd.Name()) + if cmdName == "" { + cmdName = "(empty command)" + } + return cmdName +} + +type goRedisApmSpanKey struct{} + +var key = goRedisApmSpanKey{} + +func withSpan(ctx context.Context, span *apm.Span) context.Context { + return context.WithValue(ctx, key, span) +} + +func spanFromContext(ctx context.Context) *apm.Span { + span, _ := ctx.Value(key).(*apm.Span) + return span +} diff --git a/module/apmgoredisv8/hook_test.go b/module/apmgoredisv8/hook_test.go new file mode 100644 index 000000000..56521c27e --- /dev/null +++ b/module/apmgoredisv8/hook_test.go @@ -0,0 +1,166 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// +build go1.11 + +package apmgoredisv8_test + +import ( + "context" + "fmt" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/go-redis/redis/v8" + + "go.elastic.co/apm/apmtest" + apmgoredis "go.elastic.co/apm/module/apmgoredisv8" +) + +const ( + clientTypeBase = iota + clientTypeCluster + clientTypeRing +) + +var ( + unitTestCases = []struct { + clientType int + client redis.UniversalClient + }{ + { + clientTypeBase, + redisHookedClient(), + }, + { + clientTypeCluster, + redisHookedClusterClient(), + }, + { + clientTypeRing, + redisHookedRing(), + }, + } +) + +func TestHook(t *testing.T) { + for i, testCase := range unitTestCases { + t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) { + client := testCase.client + + _, spans, _ := apmtest.WithTransaction(func(ctx context.Context) { + client.Ping(ctx) + client.Get(ctx, "key") + client.Do(ctx, "") + }) + require.Len(t, spans, 3) + assert.Equal(t, "PING", spans[0].Name) + assert.Equal(t, "db", spans[0].Type) + assert.Equal(t, "redis", spans[0].Subtype) + assert.Equal(t, "GET", spans[1].Name) + assert.Equal(t, "db", spans[1].Type) + assert.Equal(t, "redis", spans[1].Subtype) + assert.Equal(t, "(empty command)", spans[2].Name) + assert.Equal(t, "db", spans[2].Type) + assert.Equal(t, "redis", spans[2].Subtype) + }) + } +} + +func TestHookPipeline(t *testing.T) { + for i, testCase := range unitTestCases { + t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) { + client := testCase.client + + _, spans, _ := apmtest.WithTransaction(func(ctx context.Context) { + pipe := client.Pipeline() + pipe.Get(ctx, "key") + pipe.Set(ctx, "key", "value", 0) + pipe.Get(ctx, "key") + pipe.Do(ctx, "") + _, _ = pipe.Exec(ctx) + }) + + require.Len(t, spans, 1) + assert.Equal(t, "GET, SET, GET, (empty command)", spans[0].Name) + assert.Equal(t, "db", spans[0].Type) + assert.Equal(t, "redis", spans[0].Subtype) + }) + } +} + +func TestHookTxPipeline(t *testing.T) { + for i, testCase := range unitTestCases { + t.Run(fmt.Sprintf("test %d", i), func(t *testing.T) { + client := testCase.client + + _, spans, _ := apmtest.WithTransaction(func(ctx context.Context) { + pipe := client.TxPipeline() + pipe.Get(ctx, "key") + pipe.Set(ctx, "key", "value", 0) + pipe.Get(ctx, "key") + pipe.Do(ctx, "") + _, _ = pipe.Exec(ctx) + }) + + require.Len(t, spans, 1) + if _, ok := client.(*redis.Client); ok { + // *redis.Client wraps queued commands with MULTI/EXEC + // in (*redis.Client) processTxPipeline + assert.Equal(t, "MULTI, GET, SET, GET, (empty command), EXEC", spans[0].Name) + } else { + // *redis.ClusterClient and *redis.Ring don't wrap queued commands + // with MULTI/EXEC in (*redis.Client) processTxPipeline + assert.Equal(t, "GET, SET, GET, (empty command)", spans[0].Name) + } + assert.Equal(t, "db", spans[0].Type) + assert.Equal(t, "redis", spans[0].Subtype) + }) + } +} + +func redisEmptyClient() *redis.Client { + return redis.NewClient(&redis.Options{}) +} + +func redisHookedClient() *redis.Client { + client := redisEmptyClient() + client.AddHook(apmgoredis.NewGoRedisApmHook()) + return client +} + +func redisEmptyClusterClient() *redis.ClusterClient { + return redis.NewClusterClient(&redis.ClusterOptions{}) +} + +func redisHookedClusterClient() *redis.ClusterClient { + client := redisEmptyClusterClient() + client.AddHook(apmgoredis.NewGoRedisApmHook()) + return client +} + +func redisEmptyRing() *redis.Ring { + return redis.NewRing(&redis.RingOptions{}) +} + +func redisHookedRing() *redis.Ring { + client := redisEmptyRing() + client.AddHook(apmgoredis.NewGoRedisApmHook()) + return client +} diff --git a/scripts/Dockerfile-testing b/scripts/Dockerfile-testing index 1c61644a4..fe393834b 100644 --- a/scripts/Dockerfile-testing +++ b/scripts/Dockerfile-testing @@ -16,6 +16,7 @@ COPY module/apmgokit/go.mod module/apmgokit/go.sum /go/src/go.elastic.co/apm/mod COPY module/apmgometrics/go.mod module/apmgometrics/go.sum /go/src/go.elastic.co/apm/module/apmgometrics/ COPY module/apmgopg/go.mod module/apmgopg/go.sum /go/src/go.elastic.co/apm/module/apmgopg/ COPY module/apmgoredis/go.mod module/apmgoredis/go.sum /go/src/go.elastic.co/apm/module/apmgoredis/ +COPY module/apmgoredisv8/go.mod module/apmgoredisv8/go.sum /go/src/go.elastic.co/apm/module/apmgoredisv8/ COPY module/apmgorilla/go.mod module/apmgorilla/go.sum /go/src/go.elastic.co/apm/module/apmgorilla/ COPY module/apmgorm/go.mod module/apmgorm/go.sum /go/src/go.elastic.co/apm/module/apmgorm/ COPY module/apmgrpc/go.mod module/apmgrpc/go.sum /go/src/go.elastic.co/apm/module/apmgrpc/ @@ -48,6 +49,7 @@ RUN cd /go/src/go.elastic.co/apm/module/apmgokit && go mod download RUN cd /go/src/go.elastic.co/apm/module/apmgometrics && go mod download RUN cd /go/src/go.elastic.co/apm/module/apmgopg && go mod download RUN cd /go/src/go.elastic.co/apm/module/apmgoredis && go mod download +RUN cd /go/src/go.elastic.co/apm/module/apmgoredisv8 && go mod download RUN cd /go/src/go.elastic.co/apm/module/apmgorilla && go mod download RUN cd /go/src/go.elastic.co/apm/module/apmgorm && go mod download RUN cd /go/src/go.elastic.co/apm/module/apmgrpc && go mod download From 8f54a186e089928c5b36b6885fc816c413a82287 Mon Sep 17 00:00:00 2001 From: idealism-xxm Date: Thu, 4 Jun 2020 12:50:38 +0800 Subject: [PATCH 2/2] fix(apmgoredisv8): rename hook type name; use apm.SpanFromContext to retrieve started span Co-authored-by: Andrew Wilkins --- docs/instrumenting.asciidoc | 4 +-- module/apmgoredisv8/hook.go | 43 +++++++++++--------------------- module/apmgoredisv8/hook_test.go | 6 ++--- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/docs/instrumenting.asciidoc b/docs/instrumenting.asciidoc index 61aa0d1b4..2589a7cce 100644 --- a/docs/instrumenting.asciidoc +++ b/docs/instrumenting.asciidoc @@ -523,7 +523,7 @@ func handleRequest(w http.ResponseWriter, req *http.Request) { Package apmgoredisv8 provides a means of instrumenting https://github.com/go-redis/redis[go-redis/redis] for v8 so that Redis commands are reported as spans within the current transaction. -To report Redis commands, you can call `AddHook(apmgoredis.NewGoRedisApmHook())` +To report Redis commands, you can call `AddHook(apmgoredis.NewHook())` from instance of `redis.Client`, `redis.ClusterClient`, or `redis.Ring`. [source,go] @@ -538,7 +538,7 @@ func main() { redisClient := redis.NewClient(&redis.Options{}) // Add apm hook to redisClient. // Redis commands will be reported as spans within the current transaction. - redisClient.AddHook(apmgoredis.NewGoRedisApmHook()) + redisClient.AddHook(apmgoredis.NewHook()) redisClient.Get(ctx, "key") } diff --git a/module/apmgoredisv8/hook.go b/module/apmgoredisv8/hook.go index 5c871bd0f..af7cdaf12 100644 --- a/module/apmgoredisv8/hook.go +++ b/module/apmgoredisv8/hook.go @@ -29,30 +29,30 @@ import ( "go.elastic.co/apm" ) -// goRedisApmHook is an implementation of redis.Hook that reports cmds as spans to Elastic APM. -type goRedisApmHook struct{} +// hook is an implementation of redis.Hook that reports cmds as spans to Elastic APM. +type hook struct{} -// NewGoRedisApmHook returns a redis.Hook that reports cmds as spans to Elastic APM. -func NewGoRedisApmHook() redis.Hook { - return &goRedisApmHook{} +// NewHook returns a redis.Hook that reports cmds as spans to Elastic APM. +func NewHook() redis.Hook { + return &hook{} } // BeforeProcess initiates the span for the redis cmd -func (r *goRedisApmHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error) { - span, ctx := apm.StartSpan(ctx, getCmdName(cmd), "db.redis") - return withSpan(ctx, span), nil +func (r *hook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error) { + _, ctx = apm.StartSpan(ctx, getCmdName(cmd), "db.redis") + return ctx, nil } // AfterProcess ends the initiated span from BeforeProcess -func (r *goRedisApmHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error { - if span := spanFromContext(ctx); span != nil { +func (r *hook) AfterProcess(ctx context.Context, cmd redis.Cmder) error { + if span := apm.SpanFromContext(ctx); span != nil { span.End() } return nil } // BeforeProcessPipeline initiates the span for the redis cmds -func (r *goRedisApmHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error) { +func (r *hook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error) { // Join all cmd names with ", ". var cmdNameBuf bytes.Buffer for i, cmd := range cmds { @@ -62,13 +62,13 @@ func (r *goRedisApmHook) BeforeProcessPipeline(ctx context.Context, cmds []redis cmdNameBuf.WriteString(getCmdName(cmd)) } - span, ctx := apm.StartSpan(ctx, cmdNameBuf.String(), "db.redis") - return withSpan(ctx, span), nil + _, ctx = apm.StartSpan(ctx, cmdNameBuf.String(), "db.redis") + return ctx, nil } // AfterProcess ends the initiated span from BeforeProcessPipeline -func (r *goRedisApmHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error { - if span := spanFromContext(ctx); span != nil { +func (r *hook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error { + if span := apm.SpanFromContext(ctx); span != nil { span.End() } return nil @@ -81,16 +81,3 @@ func getCmdName(cmd redis.Cmder) string { } return cmdName } - -type goRedisApmSpanKey struct{} - -var key = goRedisApmSpanKey{} - -func withSpan(ctx context.Context, span *apm.Span) context.Context { - return context.WithValue(ctx, key, span) -} - -func spanFromContext(ctx context.Context) *apm.Span { - span, _ := ctx.Value(key).(*apm.Span) - return span -} diff --git a/module/apmgoredisv8/hook_test.go b/module/apmgoredisv8/hook_test.go index 56521c27e..a20782a37 100644 --- a/module/apmgoredisv8/hook_test.go +++ b/module/apmgoredisv8/hook_test.go @@ -141,7 +141,7 @@ func redisEmptyClient() *redis.Client { func redisHookedClient() *redis.Client { client := redisEmptyClient() - client.AddHook(apmgoredis.NewGoRedisApmHook()) + client.AddHook(apmgoredis.NewHook()) return client } @@ -151,7 +151,7 @@ func redisEmptyClusterClient() *redis.ClusterClient { func redisHookedClusterClient() *redis.ClusterClient { client := redisEmptyClusterClient() - client.AddHook(apmgoredis.NewGoRedisApmHook()) + client.AddHook(apmgoredis.NewHook()) return client } @@ -161,6 +161,6 @@ func redisEmptyRing() *redis.Ring { func redisHookedRing() *redis.Ring { client := redisEmptyRing() - client.AddHook(apmgoredis.NewGoRedisApmHook()) + client.AddHook(apmgoredis.NewHook()) return client }