Documentation
¶
Overview ¶
Example ¶
Here's an example illustrating a simple use case for interacting with consul with tracing enabled.
Output: test: 1000
Index ¶
- type Client
- type ClientOption
- type KV
- func (k *KV) Acquire(p *consul.KVPair, q *consul.WriteOptions) (bool, *consul.WriteMeta, error)
- func (k *KV) CAS(p *consul.KVPair, q *consul.WriteOptions) (bool, *consul.WriteMeta, error)
- func (k *KV) Delete(key string, w *consul.WriteOptions) (*consul.WriteMeta, error)
- func (k *KV) DeleteCAS(p *consul.KVPair, q *consul.WriteOptions) (bool, *consul.WriteMeta, error)
- func (k *KV) DeleteTree(prefix string, w *consul.WriteOptions) (*consul.WriteMeta, error)
- func (k *KV) Get(key string, q *consul.QueryOptions) (*consul.KVPair, *consul.QueryMeta, error)
- func (k *KV) Keys(prefix, separator string, q *consul.QueryOptions) ([]string, *consul.QueryMeta, error)
- func (k *KV) List(prefix string, q *consul.QueryOptions) ([]*consul.KVPair, *consul.QueryMeta, error)
- func (k *KV) Put(p *consul.KVPair, q *consul.WriteOptions) (*consul.WriteMeta, error)
- func (k *KV) Release(p *consul.KVPair, q *consul.WriteOptions) (bool, *consul.WriteMeta, error)
Examples ¶
Constants ¶
Variables ¶
Functions ¶
Types ¶
type Client ¶
Client wraps the regular *consul.Client and augments it with tracing. Use NewClient to initialize it.
func NewClient ¶
func NewClient(config *consul.Config, opts ...ClientOption) (*Client, error)
NewClient returns a traced Consul client.
func WrapClient ¶
func WrapClient(c *consul.Client, opts ...ClientOption) *Client
WrapClient wraps a given consul.Client with a tracer under the given service name.
type ClientOption ¶
type ClientOption func(*clientConfig)
ClientOption represents an option that can be used to create or wrap a client.
func WithAnalytics ¶
func WithAnalytics(on bool) ClientOption
WithAnalytics enables Trace Analytics for all started spans.
func WithAnalyticsRate ¶
func WithAnalyticsRate(rate float64) ClientOption
WithAnalyticsRate sets the sampling rate for Trace Analytics events correlated to started spans.
func WithServiceName ¶
func WithServiceName(name string) ClientOption
WithServiceName sets the given service name for the client.
type KV ¶
A KV is used to trace requests to Consul's KV.
func (*KV) Acquire ¶
Acquire is used for a lock acquisition operation. The Key, Flags, Value and Session are respected. Returns true on success or false on failures.
func (*KV) CAS ¶
CAS is used for a Check-And-Set operation. The Key, ModifyIndex, Flags and Value are respected. Returns true on success or false on failures.
func (*KV) DeleteCAS ¶
DeleteCAS is used for a Delete Check-And-Set operation. The Key and ModifyIndex are respected. Returns true on success or false on failures.
func (*KV) DeleteTree ¶
DeleteTree is used to delete all keys under a prefix.
func (*KV) Get ¶
Get is used to lookup a single key. The returned pointer to the KVPair will be nil if the key does not exist.
func (*KV) Keys ¶
func (k *KV) Keys(prefix, separator string, q *consul.QueryOptions) ([]string, *consul.QueryMeta, error)
Keys is used to list all the keys under a prefix. Optionally, a separator can be used to limit the responses.
func (*KV) List ¶
func (k *KV) List(prefix string, q *consul.QueryOptions) ([]*consul.KVPair, *consul.QueryMeta, error)
List is used to lookup all keys under a prefix.