v1.60.3 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2024 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 10 Imported by: 0



Package memcache provides functions to trace the bradfitz/gomemcache package (

`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.

package main

import (

	memcachetrace ""


func main() {
	span, ctx := tracer.StartSpanFromContext(context.Background(), "parent.request",
	defer span.Finish()

	mc := memcachetrace.WrapClient(memcache.New(""))
	// you can use WithContext to set the parent span
	mc.WithContext(ctx).Set(&memcache.Item{Key: "my key", Value: []byte("my value")})





This section is empty.


This section is empty.


This section is empty.


type Client

type Client struct {
	// contains filtered or unexported fields

A Client is used to trace requests to the memcached server.

func WrapClient

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".

func (*Client) Add

func (c *Client) Add(item *memcache.Item) error

Add invokes and traces Client.Add.

func (*Client) Append added in v1.54.0

func (c *Client) Append(item *memcache.Item) error

Append invokes and traces Client.Append.

func (*Client) CompareAndSwap

func (c *Client) CompareAndSwap(item *memcache.Item) error

CompareAndSwap invokes and traces Client.CompareAndSwap.

func (*Client) Decrement

func (c *Client) Decrement(key string, delta uint64) (newValue uint64, err error)

Decrement invokes and traces Client.Decrement.

func (*Client) Delete

func (c *Client) Delete(key string) error

Delete invokes and traces Client.Delete.

func (*Client) DeleteAll

func (c *Client) DeleteAll() error

DeleteAll invokes and traces Client.DeleteAll.

func (*Client) FlushAll

func (c *Client) FlushAll() error

FlushAll invokes and traces Client.FlushAll.

func (*Client) Get

func (c *Client) Get(key string) (item *memcache.Item, err error)

Get invokes and traces Client.Get.

func (*Client) GetMulti

func (c *Client) GetMulti(keys []string) (map[string]*memcache.Item, error)

GetMulti invokes and traces Client.GetMulti.

func (*Client) Increment

func (c *Client) Increment(key string, delta uint64) (newValue uint64, err error)

Increment invokes and traces Client.Increment.

func (*Client) Prepend added in v1.54.0

func (c *Client) Prepend(item *memcache.Item) error

Prepend invokes and traces Client.Prepend.

func (*Client) Replace

func (c *Client) Replace(item *memcache.Item) error

Replace invokes and traces Client.Replace.

func (*Client) Set

func (c *Client) Set(item *memcache.Item) error

Set invokes and traces Client.Set.

func (*Client) Touch

func (c *Client) Touch(key string, seconds int32) error

Touch invokes and traces Client.Touch.

func (*Client) WithContext

func (c *Client) WithContext(ctx context.Context) *Client

WithContext creates a copy of the Client with the given context.

type ClientOption

type ClientOption func(*clientConfig)

ClientOption represents an option that can be passed to Dial.

func WithAnalytics added in v1.11.0

func WithAnalytics(on bool) ClientOption

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate added in v1.11.0

func WithAnalyticsRate(rate float64) ClientOption

WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.

func WithServiceName

func WithServiceName(name string) ClientOption

WithServiceName sets the given service name for the dialled connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL