Documentation
¶
Overview ¶
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.
Example ¶
package main import ( "context" memcachetrace "github.com/DataDog/dd-trace-go/contrib/bradfitz/gomemcache/v2/memcache" "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer" "github.com/bradfitz/gomemcache/memcache" ) func main() { tracer.Start() defer tracer.Stop() 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")}) }
Output:
Index ¶
- type Client
- func (c *Client) Add(item *memcache.Item) error
- func (c *Client) Append(item *memcache.Item) error
- func (c *Client) CompareAndSwap(item *memcache.Item) error
- func (c *Client) Decrement(key string, delta uint64) (newValue uint64, err error)
- func (c *Client) Delete(key string) error
- func (c *Client) DeleteAll() error
- func (c *Client) FlushAll() error
- func (c *Client) Get(key string) (item *memcache.Item, err error)
- func (c *Client) GetMulti(keys []string) (map[string]*memcache.Item, error)
- func (c *Client) Increment(key string, delta uint64) (newValue uint64, err error)
- func (c *Client) Prepend(item *memcache.Item) error
- func (c *Client) Replace(item *memcache.Item) error
- func (c *Client) Set(item *memcache.Item) error
- func (c *Client) Touch(key string, seconds int32) error
- func (c *Client) WithContext(ctx context.Context) *Client
- type ClientOption
- type ClientOptionFn
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
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) CompareAndSwap ¶
CompareAndSwap invokes and traces Client.CompareAndSwap.
type ClientOption ¶
type ClientOption interface {
// contains filtered or unexported methods
}
ClientOption describes options for the Memcache integration.
type ClientOptionFn ¶
type ClientOptionFn func(*clientConfig)
ClientOptionFn represents options applicable to WrapClient.
func WithAnalytics ¶
func WithAnalytics(on bool) ClientOptionFn
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
func WithAnalyticsRate(rate float64) ClientOptionFn
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithService ¶
func WithService(name string) ClientOptionFn
WithService sets the given service name for the dialled connection.