RecordError in OpenTelemetryHook

This commit is contained in:
Vladimir Mihailenco 2020-07-09 12:23:03 +03:00
parent 6b9f61cf75
commit f3d06886e6
1 changed files with 10 additions and 2 deletions

View File

@ -34,7 +34,11 @@ func (OpenTelemetryHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (co
}
func (OpenTelemetryHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error {
trace.SpanFromContext(ctx).End()
span := trace.SpanFromContext(ctx)
if err := cmd.Err(); err != nil {
internal.RecordError(ctx, err)
}
span.End()
return nil
}
@ -84,7 +88,11 @@ func (OpenTelemetryHook) BeforeProcessPipeline(ctx context.Context, cmds []redis
}
func (OpenTelemetryHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error {
trace.SpanFromContext(ctx).End()
span := trace.SpanFromContext(ctx)
if err := cmds[0].Err(); err != nil {
internal.RecordError(ctx, err)
}
span.End()
return nil
}