Documentation
¶
Overview ¶
Package gocql provides functions to trace the gocql/gocql package (https://github.com/gocql/gocql).
Index ¶
- func CreateTracedSession(cluster *gocql.ClusterConfig, opts ...WrapOption) (*gocql.Session, error)
- type Batchdeprecated
- type ClusterConfigdeprecated
- type Iterdeprecated
- type Observer
- type Querydeprecated
- func (tq *Query) Exec() error
- func (tq *Query) Iter() *Iter
- func (tq *Query) MapScan(m map[string]interface{}) error
- func (tq *Query) MapScanCAS(m map[string]interface{}) (applied bool, err error)
- func (tq *Query) PageState(state []byte) *Query
- func (tq *Query) Scan(dest ...interface{}) error
- func (tq *Query) ScanCAS(dest ...interface{}) (applied bool, err error)
- func (tq *Query) WithContext(ctx context.Context) *Query
- func (tq *Query) WithWrapOptions(opts ...WrapOption) *Query
- type Scannerdeprecated
- type Sessiondeprecated
- type WrapOption
- func NoDebugStack() WrapOption
- func WithAnalytics(on bool) WrapOption
- func WithAnalyticsRate(rate float64) WrapOption
- func WithCustomTag(key string, value interface{}) WrapOption
- func WithErrorCheck(fn func(err error) bool) WrapOption
- func WithResourceName(name string) WrapOption
- func WithServiceName(name string) WrapOption
- func WithTraceBatch(enabled bool) WrapOption
- func WithTraceConnect(enabled bool) WrapOption
- func WithTraceQuery(enabled bool) WrapOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTracedSession ¶ added in v1.67.0
func CreateTracedSession(cluster *gocql.ClusterConfig, opts ...WrapOption) (*gocql.Session, error)
CreateTracedSession returns a new session augmented with tracing.
Types ¶
type Batch
deprecated
added in
v1.36.0
Batch inherits from gocql.Batch, it keeps the tracer and the context.
Deprecated: use the Observer based method CreateTracedSession instead, which allows to use native gocql types instead of wrapped types.
func WrapBatch
deprecated
added in
v1.36.0
func WrapBatch(b *gocql.Batch, opts ...WrapOption) *Batch
WrapBatch wraps a gocql.Batch into a traced Batch under the given service name. Note that the returned Batch structure embeds the original gocql.Batch structure. This means that any method returning the batch for chaining that is not part of this package's Batch structure should be called before WrapBatch, otherwise the tracing context could be lost.
To be more specific: it is ok (and recommended) to use and chain the return value of `WithContext` and `WithTimestamp` but not that of `SerialConsistency`, `Trace`, `Observer`, etc.
Deprecated: use the Observer based method CreateTracedSession instead, which allows to use native gocql types instead of wrapped types.
func (*Batch) ExecuteBatch ¶ added in v1.36.0
ExecuteBatch calls session.ExecuteBatch on the Batch, tracing the execution.
func (*Batch) WithContext ¶ added in v1.36.0
WithContext adds the specified context to the traced Batch structure.
func (*Batch) WithTimestamp ¶ added in v1.36.0
WithTimestamp will enable the with default timestamp flag on the query like DefaultTimestamp does. But also allows to define value for timestamp. It works the same way as USING TIMESTAMP in the query itself, but should not break prepared query optimization.
func (*Batch) WithWrapOptions ¶ added in v1.52.0
func (tb *Batch) WithWrapOptions(opts ...WrapOption) *Batch
WithWrapOptions applies the given set of options to the batch.
type ClusterConfig
deprecated
added in
v1.52.0
type ClusterConfig struct { *gocql.ClusterConfig // contains filtered or unexported fields }
ClusterConfig embeds gocql.ClusterConfig and keeps information relevant to tracing.
Deprecated: use the Observer based method CreateTracedSession instead, which allows to use native gocql types instead of wrapped types.
func NewCluster
deprecated
added in
v1.52.0
func NewCluster(hosts []string, opts ...WrapOption) *ClusterConfig
NewCluster calls gocql.NewCluster and returns a wrapped instrumented version of it.
Deprecated: use the Observer based method CreateTracedSession instead, which allows to use native gocql types instead of wrapped types.
func (*ClusterConfig) CreateSession ¶ added in v1.52.0
func (c *ClusterConfig) CreateSession() (*Session, error)
CreateSession calls the underlying gocql.ClusterConfig's CreateSession method and returns a new Session augmented with tracing.
type Observer ¶ added in v1.67.0
type Observer struct {
// contains filtered or unexported fields
}
Observer implements gocql observer interfaces to support tracing.
func NewObserver ¶ added in v1.67.0
func NewObserver(cluster *gocql.ClusterConfig, opts ...WrapOption) *Observer
NewObserver creates a new Observer to trace gocql. This method is useful in case you want to attach the observer to individual traces / batches instead of instrumenting the whole client.
func (*Observer) ObserveBatch ¶ added in v1.67.0
func (o *Observer) ObserveBatch(ctx context.Context, batch gocql.ObservedBatch)
ObserveBatch implements gocql.BatchObserver.
func (*Observer) ObserveConnect ¶ added in v1.67.0
func (o *Observer) ObserveConnect(connect gocql.ObservedConnect)
ObserveConnect implements gocql.ConnectObserver.
func (*Observer) ObserveQuery ¶ added in v1.67.0
func (o *Observer) ObserveQuery(ctx context.Context, query gocql.ObservedQuery)
ObserveQuery implements gocql.QueryObserver.
type Query
deprecated
Query inherits from gocql.Query, it keeps the tracer and the context.
Deprecated: use the Observer based method CreateTracedSession instead, which allows to use native gocql types instead of wrapped types.
func WrapQuery
deprecated
func WrapQuery(q *gocql.Query, opts ...WrapOption) *Query
WrapQuery wraps a gocql.Query into a traced Query under the given service name. Note that the returned Query structure embeds the original gocql.Query structure. This means that any method returning the query for chaining that is not part of this package's Query structure should be called before WrapQuery, otherwise the tracing context could be lost.
To be more specific: it is ok (and recommended) to use and chain the return value of `WithContext` and `PageState` but not that of `Consistency`, `Trace`, `Observer`, etc.
Deprecated: use the Observer based method CreateTracedSession instead, which allows to use native gocql types instead of wrapped types.
func (*Query) MapScanCAS ¶ added in v1.67.0
MapScanCAS wraps in a span query.MapScanCAS call.
func (*Query) PageState ¶
PageState rewrites the original function so that spans are aware of the change.
func (*Query) WithContext ¶
WithContext adds the specified context to the traced Query structure.
func (*Query) WithWrapOptions ¶ added in v1.52.0
func (tq *Query) WithWrapOptions(opts ...WrapOption) *Query
WithWrapOptions applies the given set of options to the query.
type Scanner
deprecated
added in
v1.36.0
Scanner inherits from a gocql.Scanner derived from an Iter.
Deprecated: use the Observer based method CreateTracedSession instead, which allows to use native gocql types instead of wrapped types.
type Session
deprecated
added in
v1.52.0
Session embeds gocql.Session and keeps information relevant to tracing.
Deprecated: use the Observer based method CreateTracedSession instead, which allows to use native gocql types instead of wrapped types.
func (*Session) NewBatch
deprecated
added in
v1.52.0
NewBatch calls the underlying gocql.Session's NewBatch method and returns a new Batch augmented with tracing.
Deprecated: use the Observer based method CreateTracedSession instead, which allows to use native gocql types instead of wrapped types.
type WrapOption ¶
type WrapOption func(*config)
WrapOption represents an option that can be passed to WrapQuery.
func NoDebugStack ¶ added in v1.12.0
func NoDebugStack() WrapOption
NoDebugStack prevents stack traces from being attached to spans finishing with an error. This is useful in situations where errors are frequent and performance is critical.
func WithAnalytics ¶ added in v1.11.0
func WithAnalytics(on bool) WrapOption
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶ added in v1.11.0
func WithAnalyticsRate(rate float64) WrapOption
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithCustomTag ¶ added in v1.53.0
func WithCustomTag(key string, value interface{}) WrapOption
WithCustomTag will attach the value to the span tagged by the key.
func WithErrorCheck ¶ added in v1.40.0
func WithErrorCheck(fn func(err error) bool) WrapOption
WithErrorCheck specifies a function fn which determines whether the passed error should be marked as an error. The fn is called whenever a CQL request finishes with an error.
func WithResourceName ¶
func WithResourceName(name string) WrapOption
WithResourceName sets a custom resource name to be used with the traced query. By default, the query statement is extracted automatically. This method should be used when a different resource name is desired or in performance critical environments. The gocql library returns the query statement using an fmt.Sprintf call, which can be costly when called repeatedly. Using WithResourceName will avoid that call. Under normal circumstances, it is safe to rely on the default.
func WithServiceName ¶
func WithServiceName(name string) WrapOption
WithServiceName sets the given service name for the returned query.
func WithTraceBatch ¶ added in v1.67.0
func WithTraceBatch(enabled bool) WrapOption
WithTraceBatch will enable tracing for batches (default is true). This option only takes effect in CreateTracedSession and NewObserver.
func WithTraceConnect ¶ added in v1.67.0
func WithTraceConnect(enabled bool) WrapOption
WithTraceConnect will enable tracing for connections (default is true). This option only takes effect in CreateTracedSession and NewObserver.
func WithTraceQuery ¶ added in v1.67.0
func WithTraceQuery(enabled bool) WrapOption
WithTraceQuery will enable tracing for queries (default is true). This option only takes effect in CreateTracedSession and NewObserver.