Skip to content

Commit

Permalink
GOCBC-264: Added support for OpenTracing tracing.
Browse files Browse the repository at this point in the history
Motivation
----------
In order to enable more detailed introspection on the behavior
and performance of the SDK, having access to internal trace
metrics is highly valuable.

Changes
-------
Implemented the ability to trace the majority of the internal
methods of the SDK both for KV and non-KV.

Change-Id: Ia3e9b1bc3d62e73ab1688e47efbb104d9bba24a7
Reviewed-on: http://review.couchbase.org/90165
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Brett Lawson <brett19@gmail.com>
  • Loading branch information
brett19 committed Mar 23, 2018
1 parent 36e4e5d commit 28d5eda
Show file tree
Hide file tree
Showing 16 changed files with 921 additions and 406 deletions.
4 changes: 3 additions & 1 deletion auth.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gocb

import "gopkg.in/couchbase/gocbcore.v7"
import (
"gopkg.in/couchbase/gocbcore.v7"
)

// UserPassPair represents a username and password pair.
type UserPassPair gocbcore.UserPassPair
Expand Down
9 changes: 9 additions & 0 deletions bucket.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gocb

import (
"github.com/opentracing/opentracing-go"
"gopkg.in/couchbase/gocbcore.v7"
"math/rand"
"time"
Expand All @@ -13,6 +14,7 @@ type Bucket struct {
password string
client *gocbcore.Agent
mtEnabled bool
tracer opentracing.Tracer

transcoder Transcoder
opTimeout time.Duration
Expand All @@ -26,6 +28,12 @@ type Bucket struct {
internal *BucketInternal
}

func (b *Bucket) startKvOpTrace(operationName string) opentracing.Span {
return b.tracer.StartSpan(operationName,
opentracing.Tag{Key: "couchbase.bucket", Value: b.name},
opentracing.Tag{Key: "couchbase.service", Value: "kv"})
}

func createBucket(cluster *Cluster, config *gocbcore.AgentConfig) (*Bucket, error) {
cli, err := gocbcore.CreateAgent(config)
if err != nil {
Expand All @@ -39,6 +47,7 @@ func createBucket(cluster *Cluster, config *gocbcore.AgentConfig) (*Bucket, erro
client: cli,
mtEnabled: config.UseMutationTokens,
transcoder: &DefaultTranscoder{},
tracer: config.Tracer,

opTimeout: 2500 * time.Millisecond,
bulkOpTimeout: 10000 * time.Millisecond,
Expand Down
Loading

0 comments on commit 28d5eda

Please sign in to comment.