leveldb

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package leveldb provides functions to trace the syndtr/goleveldb package (https://github.com/syndtr/goleveldb).

Example
package main

import (
	"context"

	leveldbtrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/syndtr/goleveldb/leveldb"
	"gopkg.in/DataDog/dd-trace-go.v1/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

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

A DB wraps a leveldb.DB and traces all queries.

func Open

func Open(stor storage.Storage, o *opt.Options, opts ...Option) (*DB, error)

Open calls leveldb.Open and wraps the resulting DB.

func OpenFile

func OpenFile(path string, o *opt.Options, opts ...Option) (*DB, error)

OpenFile calls leveldb.OpenFile and wraps the resulting DB.

func WrapDB

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

WrapDB wraps a leveldb.DB so that queries are traced.

func (*DB) CompactRange

func (db *DB) CompactRange(r util.Range) error

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) Get

func (db *DB) Get(key []byte, ro *opt.ReadOptions) (value []byte, err error)

Get calls DB.Get and traces the result.

func (*DB) GetSnapshot

func (db *DB) GetSnapshot() (*Snapshot, error)

GetSnapshot calls DB.GetSnapshot and returns a wrapped Snapshot.

func (*DB) Has

func (db *DB) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error)

Has calls DB.Has and traces the result.

func (*DB) NewIterator

func (db *DB) NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator

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

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

WithContext returns a new DB with the context set to ctx.

func (*DB) Write

func (db *DB) Write(batch *leveldb.Batch, wo *opt.WriteOptions) error

Write calls DB.Write and traces the result.

type Iterator

type Iterator struct {
	iterator.Iterator
	// contains filtered or unexported fields
}

An Iterator wraps a leveldb.Iterator and traces until Release is called.

func WrapIterator

func WrapIterator(it iterator.Iterator, opts ...Option) *Iterator

WrapIterator wraps a leveldb.Iterator so that queries are traced.

func (*Iterator) Release

func (it *Iterator) Release()

Release calls Iterator.Release and traces the result.

type Option

type Option func(*config)

Option represents an option that can be used customize the db tracing config.

func WithContext

func WithContext(ctx context.Context) Option

WithContext sets the tracing context for the db.

func WithServiceName

func WithServiceName(serviceName string) Option

WithServiceName sets the given service name for the db.

type Snapshot

type Snapshot struct {
	*leveldb.Snapshot
	// contains filtered or unexported fields
}

A Snapshot wraps a leveldb.Snapshot and traces all queries.

func WrapSnapshot

func WrapSnapshot(snap *leveldb.Snapshot, opts ...Option) *Snapshot

WrapSnapshot wraps a leveldb.Snapshot so that queries are traced.

func (*Snapshot) Get

func (snap *Snapshot) Get(key []byte, ro *opt.ReadOptions) (value []byte, err error)

Get calls Snapshot.Get and traces the result.

func (*Snapshot) Has

func (snap *Snapshot) Has(key []byte, ro *opt.ReadOptions) (ret bool, err error)

Has calls Snapshot.Has and traces the result.

func (*Snapshot) NewIterator

func (snap *Snapshot) NewIterator(slice *util.Range, ro *opt.ReadOptions) iterator.Iterator

NewIterator calls Snapshot.NewIterator and returns a wrapped Iterator.

func (*Snapshot) WithContext

func (snap *Snapshot) WithContext(ctx context.Context) *Snapshot

WithContext returns a new Snapshot with the context set to ctx.

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.

Jump to

Keyboard shortcuts

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