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 ¶
- type TracedIter
- type TracedQuery
- func (tq *TracedQuery) Exec() error
- func (tq *TracedQuery) Iter() *TracedIter
- func (tq *TracedQuery) MapScan(m map[string]interface{}) error
- func (tq *TracedQuery) NewChildSpan(ctx context.Context) *tracer.Span
- func (tq *TracedQuery) PageState(state []byte) *TracedQuery
- func (tq *TracedQuery) Scan(dest ...interface{}) error
- func (tq *TracedQuery) ScanCAS(dest ...interface{}) (applied bool, err error)
- func (tq *TracedQuery) WithContext(ctx context.Context) *TracedQuery
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TracedIter ¶
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 ¶
TracedQuery inherits from gocql.Query, it keeps the tracer and the context.
func TraceQuery ¶
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