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
})
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
A DB wraps a buntdb.DB, automatically tracing any transactions.
type Option ¶
An Option customizes the config.
func WithAnalytics ¶ added in v1.11.0
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶ added in v1.11.0
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithContext ¶
WithContext sets the context for the transaction.
func WithServiceName ¶
WithServiceName sets the given service name for the transaction.
Click to show internal directories.
Click to hide internal directories.