Documentation ¶
Overview ¶
Package leveldb provides functions to trace the syndtr/goleveldb package (https://github.com/syndtr/goleveldb).
Example ¶
package main import ( "context" leveldbtrace "gitlab.com/otavio3/go-tracer/contrib/syndtr/goleveldb/leveldb" "gitlab.com/otavio3/go-tracer/ddtrace/tracer" ) func main() { db, _ := leveldbtrace.OpenFile("/tmp/example.leveldb", nil) // 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). // calls will be traced Put([]byte("key"), []byte("value"), nil) }
Output:
Index ¶
- type DB
- func (db *DB) CompactRange(r util.Range) error
- func (db *DB) Delete(key []byte, wo *opt.WriteOptions) error
- func (db *DB) Get(key []byte, ro *opt.ReadOptions) (value []byte, err error)
- func (db *DB) GetSnapshot() (*Snapshot, error)
- func (db *DB) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error)
- func (db *DB) NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator
- func (db *DB) OpenTransaction() (*Transaction, error)
- func (db *DB) Put(key, value []byte, wo *opt.WriteOptions) error
- func (db *DB) WithContext(ctx context.Context) *DB
- func (db *DB) Write(batch *leveldb.Batch, wo *opt.WriteOptions) error
- type Iterator
- type Option
- type Snapshot
- func (snap *Snapshot) Get(key []byte, ro *opt.ReadOptions) (value []byte, err error)
- func (snap *Snapshot) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error)
- func (snap *Snapshot) NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator
- func (snap *Snapshot) WithContext(ctx context.Context) *Snapshot
- type Transaction
- func (tr *Transaction) Commit() error
- func (tr *Transaction) Get(key []byte, ro *opt.ReadOptions) ([]byte, error)
- func (tr *Transaction) Has(key []byte, ro *opt.ReadOptions) (bool, error)
- func (tr *Transaction) NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator
- func (tr *Transaction) WithContext(ctx context.Context) *Transaction
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
A DB wraps a leveldb.DB and traces all queries.
func (*DB) CompactRange ¶
CompactRange calls DB.CompactRange and traces the result.
func (*DB) Delete ¶
func (db *DB) Delete(key []byte, wo *opt.WriteOptions) error
Delete calls DB.Delete and traces the result.
func (*DB) GetSnapshot ¶
GetSnapshot calls DB.GetSnapshot and returns a wrapped Snapshot.
func (*DB) NewIterator ¶
NewIterator calls DB.NewIterator and returns a wrapped Iterator.
func (*DB) OpenTransaction ¶
func (db *DB) OpenTransaction() (*Transaction, error)
OpenTransaction calls DB.OpenTransaction and returns a wrapped Transaction.
func (*DB) Put ¶
func (db *DB) Put(key, value []byte, wo *opt.WriteOptions) error
Put calls DB.Put and traces the result.
func (*DB) WithContext ¶
WithContext returns a new DB with the context set to ctx.
type Iterator ¶
An Iterator wraps a leveldb.Iterator and traces until Release is called.
func WrapIterator ¶
WrapIterator wraps a leveldb.Iterator so that queries are traced.
type Option ¶
type Option func(*config)
Option represents an option that can be used customize the db tracing config.
func WithAnalytics ¶
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithContext ¶
WithContext sets the tracing context for the db.
func WithServiceName ¶
WithServiceName sets the given service name for the db.
type Snapshot ¶
A Snapshot wraps a leveldb.Snapshot and traces all queries.
func WrapSnapshot ¶
WrapSnapshot wraps a leveldb.Snapshot so that queries are traced.
func (*Snapshot) NewIterator ¶
NewIterator calls Snapshot.NewIterator and returns a wrapped Iterator.
type Transaction ¶
type Transaction struct { *leveldb.Transaction // contains filtered or unexported fields }
A Transaction wraps a leveldb.Transaction and traces all queries.
func WrapTransaction ¶
func WrapTransaction(tr *leveldb.Transaction, opts ...Option) *Transaction
WrapTransaction wraps a leveldb.Transaction so that queries are traced.
func (*Transaction) Commit ¶
func (tr *Transaction) Commit() error
Commit calls Transaction.Commit and traces the result.
func (*Transaction) Get ¶
func (tr *Transaction) Get(key []byte, ro *opt.ReadOptions) ([]byte, error)
Get calls Transaction.Get and traces the result.
func (*Transaction) Has ¶
func (tr *Transaction) Has(key []byte, ro *opt.ReadOptions) (bool, error)
Has calls Transaction.Has and traces the result.
func (*Transaction) NewIterator ¶
func (tr *Transaction) NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator
NewIterator calls Transaction.NewIterator and returns a wrapped Iterator.
func (*Transaction) WithContext ¶
func (tr *Transaction) WithContext(ctx context.Context) *Transaction
WithContext returns a new Transaction with the context set to ctx.