splunkbuntdb

package module
v0.0.0-...-4d63041 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

Splunk instrumentation for github.com/tidwall/buntdb

This package provides OpenTelemetry instrumentation for the github.com/tidwall/buntdb package.

Getting Started

This package is designed to be used as a drop-in replacement for the use of the github.com/tidwall/buntdb package. See example_test.go for more information.

Documentation

Overview

Package splunkbuntdb provides instrumentation for the github.com/tidwall/buntdb package.

Example
package main

import (
	"fmt"

	"github.com/unionai/splunk-otel-go/instrumentation/github.com/tidwall/buntdb/splunkbuntdb"
)

func main() {
	// Open the data.db file. It will be created if it doesn't exist.
	db, err := splunkbuntdb.Open(":memory:")
	if err != nil {
		panic(err)
	}
	defer db.Close()

	err = db.Update(func(tx *splunkbuntdb.Tx) error {
		_, _, errIn := tx.Set("mykey", "myvalue", nil)
		return errIn
	})
	if err != nil {
		panic(err)
	}

	err = db.View(func(tx *splunkbuntdb.Tx) error {
		errIn := tx.Ascend("", func(key, value string) bool {
			fmt.Printf("key: %s, value: %s\n", key, value)
			return true
		})
		return errIn
	})
	if err != nil {
		panic(err)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version returns the version of splunkbuntdb.

Types

type DB

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

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.

func (*DB) Begin

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

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

func (*DB) Update

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

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

func (*DB) View

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

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

func (*DB) WithContext

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

WithContext sets the context for the DB.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option applies options to a configuration.

func WithAttributes

func WithAttributes(attr []attribute.KeyValue) Option

WithAttributes returns an Option that appends attr to the attributes set for every span created with this instrumentation library.

func WithContext

func WithContext(ctx context.Context) Option

WithContext returns an Option that sets the Context used with this instrumentation library by default. This is used to pass context of any existing trace to the instrumentation.

func WithTracerProvider

func WithTracerProvider(tp trace.TracerProvider) Option

WithTracerProvider returns an Option that sets the TracerProvider used with this instrumentation library.

type Tx

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

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.

func (*Tx) Ascend

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

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

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

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

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

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

func (tx *Tx) Commit() error

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

func (*Tx) CreateIndex

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

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

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

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

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

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

func (*Tx) DeleteAll

func (tx *Tx) DeleteAll() error

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

func (*Tx) Descend

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

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

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

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

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

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

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

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

func (*Tx) Get

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

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

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

func (*Tx) Intersects

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

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

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

func (*Tx) Nearby

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

func (tx *Tx) Rollback() error

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

func (*Tx) Set

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

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

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

func (*Tx) WithContext

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

WithContext sets the context for the Tx.

Directories

Path Synopsis
test module

Jump to

Keyboard shortcuts

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