memcache

package
v1.999.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 2 Imported by: 0

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 "gopkg.in/DataDog/dd-trace-go.v1/contrib/bradfitz/gomemcache/memcache"
	"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"

	"github.com/bradfitz/gomemcache/memcache"
)

func main() {
	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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client = v2.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".

type ClientOption

type ClientOption = v2.ClientOption

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