buntdb

package
v1.999.0-beta.11 Latest Latest
Warning

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

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

Documentation

Overview

Example
package main

import (
	"context"
	"log"

	buntdbtrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/tidwall/buntdb"
	"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
)

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB = v2.DB

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

func Open

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

Open calls buntdb.Open and wraps the result.

func WrapDB

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

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

type Option

type Option = v2.Option

An Option customizes the config.

func WithAnalytics added in v1.11.0

func WithAnalytics(on bool) Option

WithAnalytics enables Trace Analytics for all started spans.

func WithAnalyticsRate added in v1.11.0

func WithAnalyticsRate(rate float64) Option

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

func WithContext

func WithContext(ctx context.Context) Option

WithContext sets the context for the transaction.

func WithServiceName

func WithServiceName(serviceName string) Option

WithServiceName sets the given service name for the transaction.

type Tx

type Tx = v2.Tx

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

func WrapTx

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

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

Jump to

Keyboard shortcuts

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