Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
f9cdd41c94 | |||
ecad15fe17 | |||
fa3d18b353 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.idea
|
@@ -27,6 +27,9 @@ var (
|
|||||||
DefaultMeterStatsInterval = 5 * time.Second
|
DefaultMeterStatsInterval = 5 * time.Second
|
||||||
// DefaultMeterMetricPrefix holds default metric prefix
|
// DefaultMeterMetricPrefix holds default metric prefix
|
||||||
DefaultMeterMetricPrefix = "micro_store_"
|
DefaultMeterMetricPrefix = "micro_store_"
|
||||||
|
|
||||||
|
labelHost = "redis_host"
|
||||||
|
labelName = "redis_name"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options struct holds wrapper options
|
// Options struct holds wrapper options
|
||||||
@@ -36,6 +39,8 @@ type Options struct {
|
|||||||
Tracer tracer.Tracer
|
Tracer tracer.Tracer
|
||||||
MeterMetricPrefix string
|
MeterMetricPrefix string
|
||||||
MeterStatsInterval time.Duration
|
MeterStatsInterval time.Duration
|
||||||
|
RedisHost string
|
||||||
|
RedisName string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option func signature
|
// Option func signature
|
||||||
@@ -56,7 +61,9 @@ func NewOptions(opts ...Option) Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
options.Meter = options.Meter.Clone(
|
options.Meter = options.Meter.Clone(
|
||||||
meter.MetricPrefix(options.MeterMetricPrefix),
|
meter.Labels(
|
||||||
|
labelHost, options.RedisHost,
|
||||||
|
labelName, options.RedisName),
|
||||||
)
|
)
|
||||||
|
|
||||||
options.Logger = options.Logger.Clone(logger.WithCallerSkipCount(1))
|
options.Logger = options.Logger.Clone(logger.WithCallerSkipCount(1))
|
||||||
|
11
tracer.go
11
tracer.go
@@ -6,7 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/redis/go-redis/extra/rediscmd/v9"
|
rediscmd "github.com/redis/go-redis/extra/rediscmd/v9"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"go.unistack.org/micro/v3/tracer"
|
"go.unistack.org/micro/v3/tracer"
|
||||||
)
|
)
|
||||||
@@ -53,11 +53,12 @@ func newTracingHook(connString string, tr tracer.Tracer, opts ...tracer.SpanOpti
|
|||||||
|
|
||||||
func (h *tracingHook) DialHook(hook redis.DialHook) redis.DialHook {
|
func (h *tracingHook) DialHook(hook redis.DialHook) redis.DialHook {
|
||||||
return func(ctx context.Context, network, addr string) (net.Conn, error) {
|
return func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||||
_, span := h.tr.Start(ctx, "redis.dial", h.opts...)
|
/*
|
||||||
defer span.Finish()
|
_, span := h.tr.Start(ctx, "redis.dial", h.opts...)
|
||||||
|
defer span.Finish()
|
||||||
|
*/
|
||||||
conn, err := hook(ctx, network, addr)
|
conn, err := hook(ctx, network, addr)
|
||||||
recordError(span, err)
|
// recordError(span, err)
|
||||||
|
|
||||||
return conn, err
|
return conn, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user