Skip to content

Commit

Permalink
otelgrpc: gctx nil check before make metricAttrs
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
  • Loading branch information
zchee committed Nov 27, 2023
1 parent d50aa19 commit 7d513b9
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ func (c *config) handleRPC(ctx context.Context, rs stats.RPCStats, isServer bool
span := trace.SpanFromContext(ctx)
gctx, _ := ctx.Value(gRPCContextKey{}).(*gRPCContext)
var messageId int64
metricAttrs := make([]attribute.KeyValue, 0, len(gctx.metricAttrs)+1)
metricAttrs = append(metricAttrs, gctx.metricAttrs...)
var metricAttrs []attribute.KeyValue
if gctx != nil {
metricAttrs := make([]attribute.KeyValue, 0, len(gctx.metricAttrs)+1)
metricAttrs = append(metricAttrs, gctx.metricAttrs...)
}
wctx := withoutCancel(ctx)

switch rs := rs.(type) {
Expand Down

0 comments on commit 7d513b9

Please sign in to comment.