fixup tracing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
1f4cf11afe
commit
058b6354c0
9
kgo.go
9
kgo.go
@ -76,9 +76,8 @@ func (k *Broker) Name() string {
|
|||||||
func (k *Broker) connect(ctx context.Context, opts ...kgo.Opt) (*kgo.Client, error) {
|
func (k *Broker) connect(ctx context.Context, opts ...kgo.Opt) (*kgo.Client, error) {
|
||||||
var c *kgo.Client
|
var c *kgo.Client
|
||||||
var err error
|
var err error
|
||||||
var span tracer.Span
|
|
||||||
ctx, span = k.opts.Tracer.Start(ctx, "Connect")
|
sp, _ := tracer.SpanFromContext(ctx)
|
||||||
defer span.Finish()
|
|
||||||
|
|
||||||
clientID := "kgo"
|
clientID := "kgo"
|
||||||
group := ""
|
group := ""
|
||||||
@ -99,7 +98,7 @@ func (k *Broker) connect(ctx context.Context, opts ...kgo.Opt) (*kgo.Client, err
|
|||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
span.SetStatus(tracer.SpanStatusError, ctx.Err().Error())
|
sp.SetStatus(tracer.SpanStatusError, ctx.Err().Error())
|
||||||
}
|
}
|
||||||
return nil, ctx.Err()
|
return nil, ctx.Err()
|
||||||
default:
|
default:
|
||||||
@ -108,7 +107,7 @@ func (k *Broker) connect(ctx context.Context, opts ...kgo.Opt) (*kgo.Client, err
|
|||||||
err = c.Ping(ctx) // check connectivity to cluster
|
err = c.Ping(ctx) // check connectivity to cluster
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.SetStatus(tracer.SpanStatusError, err.Error())
|
sp.SetStatus(tracer.SpanStatusError, err.Error())
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user