import "gopkg.in/DataDog/dd-trace-go.v1/contrib/bradfitz/gomemcache/memcache"
Package memcache provides functions to trace the bradfitz/gomemcache package (https://github.com/bradfitz/gomemcache).
`WrapClient` will wrap a memcache `Client` and return a new struct with all the same methods, so should be seamless for existing applications. It also has an additional `WithContext` method which can be used to connect a span to an existing trace.
Code:
span, ctx := tracer.StartSpanFromContext(context.Background(), "parent.request",
tracer.ServiceName("web"),
tracer.ResourceName("/home"),
)
defer span.Finish()
mc := memcachetrace.WrapClient(memcache.New("127.0.0.1:11211"))
// you can use WithContext to set the parent span
mc.WithContext(ctx).Set(&memcache.Item{Key: "my key", Value: []byte("my value")})
A Client is used to trace requests to the memcached server.
func WrapClient(client *memcache.Client, opts ...ClientOption) *Client
WrapClient wraps a memcache.Client so that all requests are traced using the default tracer with the service name "memcached".
Add invokes and traces Client.Add.
CompareAndSwap invokes and traces Client.CompareAndSwap.
Decrement invokes and traces Client.Decrement.
Delete invokes and traces Client.Delete.
DeleteAll invokes and traces Client.DeleteAll.
FlushAll invokes and traces Client.FlushAll.
Get invokes and traces Client.Get.
GetMulti invokes and traces Client.GetMulti.
Increment invokes and traces Client.Increment.
Replace invokes and traces Client.Replace.
Set invokes and traces Client.Set.
Touch invokes and traces Client.Touch.
WithContext creates a copy of the Client with the given context.
type ClientOption func(*clientConfig)
ClientOption represents an option that can be passed to Dial.
func WithAnalytics(on bool) ClientOption
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate(rate float64) ClientOption
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithServiceName(name string) ClientOption
WithServiceName sets the given service name for the dialled connection.
Package memcache imports 7 packages (graph). Updated 2021-01-04. Refresh now. Tools for package owners.