Skip to content

Commit

Permalink
Revert "contrib/bradfitz/gomemcache: trace item info for memcached op…
Browse files Browse the repository at this point in the history
…erations (#642)"

This reverts commit 3f45f6d.
  • Loading branch information
knusbaum authored May 18, 2020
1 parent 0543fdc commit 1afe50d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 51 deletions.
35 changes: 0 additions & 35 deletions contrib/bradfitz/gomemcache/memcache/memcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ func (c *Client) startSpan(resourceName string) ddtrace.Span {
func (c *Client) Add(item *memcache.Item) error {
span := c.startSpan("Add")
err := c.Client.Add(item)
span.SetTag("item.key", item.Key)
if c.cfg.withValueTags {
span.SetTag("item.value", item.Value)
}
span.SetTag("item.expiration", item.Expiration)
span.Finish(tracer.WithError(err))
return err
}
Expand All @@ -93,11 +88,6 @@ func (c *Client) Add(item *memcache.Item) error {
func (c *Client) CompareAndSwap(item *memcache.Item) error {
span := c.startSpan("CompareAndSwap")
err := c.Client.CompareAndSwap(item)
span.SetTag("item.key", item.Key)
if c.cfg.withValueTags {
span.SetTag("item.value", item.Value)
}
span.SetTag("item.expiration", item.Expiration)
span.Finish(tracer.WithError(err))
return err
}
Expand All @@ -106,11 +96,6 @@ func (c *Client) CompareAndSwap(item *memcache.Item) error {
func (c *Client) Decrement(key string, delta uint64) (newValue uint64, err error) {
span := c.startSpan("Decrement")
newValue, err = c.Client.Decrement(key, delta)
span.SetTag("item.key", key)
if c.cfg.withValueTags {
span.SetTag("item.value.before", newValue-delta)
span.SetTag("item.value.after", newValue)
}
span.Finish(tracer.WithError(err))
return newValue, err
}
Expand All @@ -119,7 +104,6 @@ func (c *Client) Decrement(key string, delta uint64) (newValue uint64, err error
func (c *Client) Delete(key string) error {
span := c.startSpan("Delete")
err := c.Client.Delete(key)
span.SetTag("item.key", key)
span.Finish(tracer.WithError(err))
return err
}
Expand All @@ -144,7 +128,6 @@ func (c *Client) FlushAll() error {
func (c *Client) Get(key string) (item *memcache.Item, err error) {
span := c.startSpan("Get")
item, err = c.Client.Get(key)
span.SetTag("item.key", key)
span.Finish(tracer.WithError(err))
return item, err
}
Expand All @@ -153,7 +136,6 @@ func (c *Client) Get(key string) (item *memcache.Item, err error) {
func (c *Client) GetMulti(keys []string) (map[string]*memcache.Item, error) {
span := c.startSpan("GetMulti")
items, err := c.Client.GetMulti(keys)
span.SetTag("item.keys", keys)
span.Finish(tracer.WithError(err))
return items, err
}
Expand All @@ -162,11 +144,6 @@ func (c *Client) GetMulti(keys []string) (map[string]*memcache.Item, error) {
func (c *Client) Increment(key string, delta uint64) (newValue uint64, err error) {
span := c.startSpan("Increment")
newValue, err = c.Client.Increment(key, delta)
span.SetTag("item.key", key)
if c.cfg.withValueTags {
span.SetTag("item.value.before", newValue-delta)
span.SetTag("item.value.after", newValue)
}
span.Finish(tracer.WithError(err))
return newValue, err
}
Expand All @@ -175,11 +152,6 @@ func (c *Client) Increment(key string, delta uint64) (newValue uint64, err error
func (c *Client) Replace(item *memcache.Item) error {
span := c.startSpan("Replace")
err := c.Client.Replace(item)
span.SetTag("item.key", item.Key)
if c.cfg.withValueTags {
span.SetTag("item.value", item.Value)
}
span.SetTag("item.expiration", item.Expiration)
span.Finish(tracer.WithError(err))
return err
}
Expand All @@ -188,11 +160,6 @@ func (c *Client) Replace(item *memcache.Item) error {
func (c *Client) Set(item *memcache.Item) error {
span := c.startSpan("Set")
err := c.Client.Set(item)
span.SetTag("item.key", item.Key)
if c.cfg.withValueTags {
span.SetTag("item.value", item.Value)
}
span.SetTag("item.expiration", item.Expiration)
span.Finish(tracer.WithError(err))
return err
}
Expand All @@ -201,8 +168,6 @@ func (c *Client) Set(item *memcache.Item) error {
func (c *Client) Touch(key string, seconds int32) error {
span := c.startSpan("Touch")
err := c.Client.Touch(key, seconds)
span.SetTag("item.key", key)
span.SetTag("item.expiration", seconds)
span.Finish(tracer.WithError(err))
return err
}
10 changes: 3 additions & 7 deletions contrib/bradfitz/gomemcache/memcache/memcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestMemcacheIntegration(t *testing.T) {
}

func testMemcache(t *testing.T, addr string) {
client := WrapClient(memcache.New(addr), WithServiceName("test-memcache"), WithValueTags())
client := WrapClient(memcache.New(addr), WithServiceName("test-memcache"))
defer client.DeleteAll()

validateMemcacheSpan := func(t *testing.T, span mocktracer.Span, resourceName string) {
Expand Down Expand Up @@ -76,9 +76,8 @@ func testMemcache(t *testing.T, addr string) {
err := client.
WithContext(ctx).
Add(&memcache.Item{
Key: "key2",
Value: []byte("value2"),
Expiration: 10,
Key: "key2",
Value: []byte("value2"),
})
assert.Nil(t, err)

Expand All @@ -90,9 +89,6 @@ func testMemcache(t *testing.T, addr string) {
assert.Equal(t, span, spans[1])
assert.Equal(t, spans[1].TraceID(), spans[0].TraceID(),
"memcache span should be part of the parent trace")
assert.Equal(t, "key2", spans[0].Tag("item.key"))
assert.Equal(t, []byte("value2"), spans[0].Tag("item.value"))
assert.Equal(t, int32(10), spans[0].Tag("item.expiration"))
})
}

Expand Down
9 changes: 0 additions & 9 deletions contrib/bradfitz/gomemcache/memcache/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const (
type clientConfig struct {
serviceName string
analyticsRate float64
withValueTags bool
}

// ClientOption represents an option that can be passed to Dial.
Expand Down Expand Up @@ -58,11 +57,3 @@ func WithAnalyticsRate(rate float64) ClientOption {
}
}
}

// WithValueTags specifies whether values assigned to keys in memcache operations
// should be added to spans as tags.
func WithValueTags() ClientOption {
return func(cfg *clientConfig) {
cfg.withValueTags = true
}
}

0 comments on commit 1afe50d

Please sign in to comment.