dd-trace-go.v1: gopkg.in/DataDog/dd-trace-go.v1/contrib/tidwall/buntdb Index | Examples | Files

package buntdb

import "gopkg.in/DataDog/dd-trace-go.v1/contrib/tidwall/buntdb"

Code:

db, err := buntdbtrace.Open(":memory:")
if err != nil {
    log.Fatal(err)
}

// Create a root span, giving name, server and resource.
_, ctx := tracer.StartSpanFromContext(context.Background(), "my-query",
    tracer.ServiceName("my-db"),
    tracer.ResourceName("initial-access"),
)

// use WithContext to associate the span with the parent
db.WithContext(ctx).
    Update(func(tx *buntdbtrace.Tx) error {
        _, _, err := tx.Set("key", "value", nil)
        return err
    })

db.View(func(tx *buntdbtrace.Tx) error {
    // you can also use WithContext on the transaction
    val, err := tx.WithContext(ctx).Get("key")
    log.Println(val)
    return err
})

Index

Examples

Package Files

buntdb.go option.go

type DB Uses

type DB struct {
    *buntdb.DB
    // contains filtered or unexported fields
}

A DB wraps a buntdb.DB, automatically tracing any transactions.

func Open Uses

func Open(path string, opts ...Option) (*DB, error)

Open calls buntdb.Open and wraps the result.

func WrapDB Uses

func WrapDB(db *buntdb.DB, opts ...Option) *DB

WrapDB wraps a buntdb.DB so it can be traced.

func (*DB) Begin Uses

func (db *DB) Begin(writable bool) (*Tx, error)

Begin calls the underlying DB.Begin and traces the transaction.

func (*DB) Update Uses

func (db *DB) Update(fn func(tx *Tx) error) error

Update calls the underlying DB.Update and traces the transaction.

func (*DB) View Uses

func (db *DB) View(fn func(tx *Tx) error) error

View calls the underlying DB.View and traces the transaction.

func (*DB) WithContext Uses

func (db *DB) WithContext(ctx context.Context) *DB

WithContext sets the context for the DB.

type Option Uses

type Option func(cfg *config)

An Option customizes the config.

func WithAnalytics Uses

func WithAnalytics(on bool) Option

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate Uses

func WithAnalyticsRate(rate float64) Option

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

func WithContext Uses

func WithContext(ctx context.Context) Option

WithContext sets the context for the transaction.

func WithServiceName Uses

func WithServiceName(serviceName string) Option

WithServiceName sets the given service name for the transaction.

type Tx Uses

type Tx struct {
    *buntdb.Tx
    // contains filtered or unexported fields
}

A Tx wraps a buntdb.Tx, automatically tracing any queries.

func WrapTx Uses

func WrapTx(tx *buntdb.Tx, opts ...Option) *Tx

WrapTx wraps a buntdb.Tx so it can be traced.

func (*Tx) Ascend Uses

func (tx *Tx) Ascend(index string, iterator func(key, value string) bool) error

Ascend calls the underlying Tx.Ascend and traces the query.

func (*Tx) AscendEqual Uses

func (tx *Tx) AscendEqual(index, pivot string, iterator func(key, value string) bool) error

AscendEqual calls the underlying Tx.AscendEqual and traces the query.

func (*Tx) AscendGreaterOrEqual Uses

func (tx *Tx) AscendGreaterOrEqual(index, pivot string, iterator func(key, value string) bool) error

AscendGreaterOrEqual calls the underlying Tx.AscendGreaterOrEqual and traces the query.

func (*Tx) AscendKeys Uses

func (tx *Tx) AscendKeys(pattern string, iterator func(key, value string) bool) error

AscendKeys calls the underlying Tx.AscendKeys and traces the query.

func (*Tx) AscendLessThan Uses

func (tx *Tx) AscendLessThan(index, pivot string, iterator func(key, value string) bool) error

AscendLessThan calls the underlying Tx.AscendLessThan and traces the query.

func (*Tx) AscendRange Uses

func (tx *Tx) AscendRange(index, greaterOrEqual, lessThan string, iterator func(key, value string) bool) error

AscendRange calls the underlying Tx.AscendRange and traces the query.

func (*Tx) CreateIndex Uses

func (tx *Tx) CreateIndex(name, pattern string, less ...func(a, b string) bool) error

CreateIndex calls the underlying Tx.CreateIndex and traces the query.

func (*Tx) CreateIndexOptions Uses

func (tx *Tx) CreateIndexOptions(name, pattern string, opts *buntdb.IndexOptions, less ...func(a, b string) bool) error

CreateIndexOptions calls the underlying Tx.CreateIndexOptions and traces the query.

func (*Tx) CreateSpatialIndex Uses

func (tx *Tx) CreateSpatialIndex(name, pattern string, rect func(item string) (min, max []float64)) error

CreateSpatialIndex calls the underlying Tx.CreateSpatialIndex and traces the query.

func (*Tx) CreateSpatialIndexOptions Uses

func (tx *Tx) CreateSpatialIndexOptions(name, pattern string, opts *buntdb.IndexOptions, rect func(item string) (min, max []float64)) error

CreateSpatialIndexOptions calls the underlying Tx.CreateSpatialIndexOptions and traces the query.

func (*Tx) Delete Uses

func (tx *Tx) Delete(key string) (val string, err error)

Delete calls the underlying Tx.Delete and traces the query.

func (*Tx) DeleteAll Uses

func (tx *Tx) DeleteAll() error

DeleteAll calls the underlying Tx.DeleteAll and traces the query.

func (*Tx) Descend Uses

func (tx *Tx) Descend(index string, iterator func(key, value string) bool) error

Descend calls the underlying Tx.Descend and traces the query.

func (*Tx) DescendEqual Uses

func (tx *Tx) DescendEqual(index, pivot string, iterator func(key, value string) bool) error

DescendEqual calls the underlying Tx.DescendEqual and traces the query.

func (*Tx) DescendGreaterThan Uses

func (tx *Tx) DescendGreaterThan(index, pivot string, iterator func(key, value string) bool) error

DescendGreaterThan calls the underlying Tx.DescendGreaterThan and traces the query.

func (*Tx) DescendKeys Uses

func (tx *Tx) DescendKeys(pattern string, iterator func(key, value string) bool) error

DescendKeys calls the underlying Tx.DescendKeys and traces the query.

func (*Tx) DescendLessOrEqual Uses

func (tx *Tx) DescendLessOrEqual(index, pivot string, iterator func(key, value string) bool) error

DescendLessOrEqual calls the underlying Tx.DescendLessOrEqual and traces the query.

func (*Tx) DescendRange Uses

func (tx *Tx) DescendRange(index, lessOrEqual, greaterThan string, iterator func(key, value string) bool) error

DescendRange calls the underlying Tx.DescendRange and traces the query.

func (*Tx) DropIndex Uses

func (tx *Tx) DropIndex(name string) error

DropIndex calls the underlying Tx.DropIndex and traces the query.

func (*Tx) Get Uses

func (tx *Tx) Get(key string, ignoreExpired ...bool) (val string, err error)

Get calls the underlying Tx.Get and traces the query.

func (*Tx) Indexes Uses

func (tx *Tx) Indexes() ([]string, error)

Indexes calls the underlying Tx.Indexes and traces the query.

func (*Tx) Intersects Uses

func (tx *Tx) Intersects(index, bounds string, iterator func(key, value string) bool) error

Intersects calls the underlying Tx.Intersects and traces the query.

func (*Tx) Len Uses

func (tx *Tx) Len() (int, error)

Len calls the underlying Tx.Len and traces the query.

func (*Tx) Nearby Uses

func (tx *Tx) Nearby(index, bounds string, iterator func(key, value string, dist float64) bool) error

Nearby calls the underlying Tx.Nearby and traces the query.

func (*Tx) Set Uses

func (tx *Tx) Set(key, value string, opts *buntdb.SetOptions) (previousValue string, replaced bool, err error)

Set calls the underlying Tx.Set and traces the query.

func (*Tx) TTL Uses

func (tx *Tx) TTL(key string) (time.Duration, error)

TTL calls the underlying Tx.TTL and traces the query.

func (*Tx) WithContext Uses

func (tx *Tx) WithContext(ctx context.Context) *Tx

WithContext sets the context for the Tx.

Package buntdb imports 8 packages (graph). Updated 2020-08-09. Refresh now. Tools for package owners.