gocqltrace

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package gocqltrace provides tracing for the Cassandra Gocql client (https://github.com/gocql/gocql)

Example

To trace Cassandra commands, use our query wrapper TraceQuery.

// Initialise a Cassandra session as usual, create a query.
cluster := gocql.NewCluster("127.0.0.1")
session, _ := cluster.CreateSession()
query := session.Query("CREATE KEYSPACE if not exists trace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor': 1}")

// Use context to pass information down the call chain
root := tracer.NewRootSpan("parent.request", "web", "/home")
ctx := root.Context(context.Background())

// Wrap the query to trace it and pass the context for inheritance
tracedQuery := TraceQuery("ServiceName", tracer.DefaultTracer, query)
tracedQuery.WithContext(ctx)

// Execute your query as usual
tracedQuery.Exec()
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TracedIter

type TracedIter struct {
	*gocql.Iter
	// contains filtered or unexported fields
}

TracedIter inherits from gocql.Iter and contains a span.

func (*TracedIter) Close

func (tIter *TracedIter) Close() error

Close closes the TracedIter and finish the span created on Iter call.

type TracedQuery

type TracedQuery struct {
	*gocql.Query
	// contains filtered or unexported fields
}

TracedQuery inherits from gocql.Query, it keeps the tracer and the context.

func TraceQuery

func TraceQuery(service string, tracer *tracer.Tracer, q *gocql.Query) *TracedQuery

TraceQuery wraps a gocql.Query into a TracedQuery

func (*TracedQuery) Exec

func (tq *TracedQuery) Exec() error

Exec is rewritten so that it passes by our custom Iter

func (*TracedQuery) Iter

func (tq *TracedQuery) Iter() *TracedIter

Iter starts a new span at query.Iter call.

func (*TracedQuery) MapScan

func (tq *TracedQuery) MapScan(m map[string]interface{}) error

MapScan wraps in a span query.MapScan call.

func (*TracedQuery) NewChildSpan

func (tq *TracedQuery) NewChildSpan(ctx context.Context) *tracer.Span

NewChildSpan creates a new span from the traceParams and the context.

func (*TracedQuery) PageState

func (tq *TracedQuery) PageState(state []byte) *TracedQuery

PageState rewrites the original function so that spans are aware of the change.

func (*TracedQuery) Scan

func (tq *TracedQuery) Scan(dest ...interface{}) error

Scan wraps in a span query.Scan call.

func (*TracedQuery) ScanCAS

func (tq *TracedQuery) ScanCAS(dest ...interface{}) (applied bool, err error)

ScanCAS wraps in a span query.ScanCAS call.

func (*TracedQuery) WithContext

func (tq *TracedQuery) WithContext(ctx context.Context) *TracedQuery

WithContext rewrites the original function so that ctx can be used for inheritance

Jump to

Keyboard shortcuts

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