[VOL-3199] Added support for dynamic enable/disable of Trace Publishing
Change-Id: Iefa126a82dc9ad127ae361b79b1ada429b609f33
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/backend.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/backend.go
index f595dc1..efc0953 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/backend.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/backend.go
@@ -20,6 +20,7 @@
"context"
"errors"
"fmt"
+ "sync"
"time"
"github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
@@ -40,7 +41,8 @@
Timeout time.Duration
Address string
PathPrefix string
- alive bool // Is this backend connection alive?
+ alive bool // Is this backend connection alive?
+ livenessMutex sync.Mutex
liveness chan bool // channel to post alive state
LivenessChannelInterval time.Duration // regularly push alive state beyond this interval
lastLivenessTime time.Time // Instant of last alive state push
@@ -91,8 +93,9 @@
// so that in a live state, the core does not timeout and
// send a forced liveness message. Push alive state if the
// last push to channel was beyond livenessChannelInterval
+ b.livenessMutex.Lock()
+ defer b.livenessMutex.Unlock()
if b.liveness != nil {
-
if b.alive != alive {
logger.Debug(ctx, "update-liveness-channel-reason-change")
b.liveness <- alive
@@ -128,14 +131,10 @@
// and/or take other actions.
func (b *Backend) EnableLivenessChannel(ctx context.Context) chan bool {
logger.Debug(ctx, "enable-kvstore-liveness-channel")
-
+ b.livenessMutex.Lock()
+ defer b.livenessMutex.Unlock()
if b.liveness == nil {
- logger.Debug(ctx, "create-kvstore-liveness-channel")
-
- // Channel size of 10 to avoid any possibility of blocking in Load conditions
b.liveness = make(chan bool, 10)
-
- // Post initial alive state
b.liveness <- b.alive
b.lastLivenessTime = time.Now()
}
@@ -182,6 +181,9 @@
// List retrieves one or more items that match the specified key
func (b *Backend) List(ctx context.Context, key string) (map[string]*kvstore.KVPair, error) {
+ span, ctx := log.CreateChildSpan(ctx, "etcd-list")
+ defer span.Finish()
+
formattedPath := b.makePath(ctx, key)
logger.Debugw(ctx, "listing-key", log.Fields{"key": key, "path": formattedPath})
@@ -194,6 +196,9 @@
// Get retrieves an item that matches the specified key
func (b *Backend) Get(ctx context.Context, key string) (*kvstore.KVPair, error) {
+ span, ctx := log.CreateChildSpan(ctx, "etcd-get")
+ defer span.Finish()
+
formattedPath := b.makePath(ctx, key)
logger.Debugw(ctx, "getting-key", log.Fields{"key": key, "path": formattedPath})
@@ -206,6 +211,9 @@
// Put stores an item value under the specifed key
func (b *Backend) Put(ctx context.Context, key string, value interface{}) error {
+ span, ctx := log.CreateChildSpan(ctx, "etcd-put")
+ defer span.Finish()
+
formattedPath := b.makePath(ctx, key)
logger.Debugw(ctx, "putting-key", log.Fields{"key": key, "path": formattedPath})
@@ -218,6 +226,9 @@
// Delete removes an item under the specified key
func (b *Backend) Delete(ctx context.Context, key string) error {
+ span, ctx := log.CreateChildSpan(ctx, "etcd-delete")
+ defer span.Finish()
+
formattedPath := b.makePath(ctx, key)
logger.Debugw(ctx, "deleting-key", log.Fields{"key": key, "path": formattedPath})
@@ -230,6 +241,9 @@
// CreateWatch starts watching events for the specified key
func (b *Backend) CreateWatch(ctx context.Context, key string, withPrefix bool) chan *kvstore.Event {
+ span, ctx := log.CreateChildSpan(ctx, "etcd-create-watch")
+ defer span.Finish()
+
formattedPath := b.makePath(ctx, key)
logger.Debugw(ctx, "creating-key-watch", log.Fields{"key": key, "path": formattedPath})
@@ -238,6 +252,9 @@
// DeleteWatch stops watching events for the specified key
func (b *Backend) DeleteWatch(ctx context.Context, key string, ch chan *kvstore.Event) {
+ span, ctx := log.CreateChildSpan(ctx, "etcd-delete-watch")
+ defer span.Finish()
+
formattedPath := b.makePath(ctx, key)
logger.Debugw(ctx, "deleting-key-watch", log.Fields{"key": key, "path": formattedPath})