Skip to content

Commit

Permalink
fix #2850
Browse files Browse the repository at this point in the history
[goreleaser]
  • Loading branch information
trajan0x committed Jul 7, 2024
1 parent d787c29 commit 8048ad1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion contrib/opbot/botmd/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (b *Bot) tracingMiddleware() slacker.CommandMiddlewareHandler {
return func(cmdCtx *slacker.CommandContext) {
ctx, span := b.handler.Tracer().Start(cmdCtx.Context(), fmt.Sprintf("command.%s", cmdCtx.Definition().Command), trace.WithAttributes(
attribute.String("user_id", cmdCtx.Event().UserID),
attribute.String("channel_id", cmdCtx.Event().Channel.ID),
attribute.String("channel_id", retrieveChannelIfExists(cmdCtx.Event())),

Check warning on line 26 in contrib/opbot/botmd/middleware.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/middleware.go#L26

Added line #L26 was not covered by tests
))

cmdCtx.WithContext(ctx)
Expand All @@ -37,6 +37,15 @@ func (b *Bot) tracingMiddleware() slacker.CommandMiddlewareHandler {
}
}

const unknownChannel = "unknown"

func retrieveChannelIfExists(event *slacker.MessageEvent) string {
if event != nil && event.Channel != nil {
return event.Channel.ID
}
return unknownChannel

Check warning on line 46 in contrib/opbot/botmd/middleware.go

View check run for this annotation

Codecov / codecov/patch

contrib/opbot/botmd/middleware.go#L42-L46

Added lines #L42 - L46 were not covered by tests
}

// assumes method is only called once.
type otelRecorder struct {
attemptsCounter metric.Int64UpDownCounter
Expand Down

0 comments on commit 8048ad1

Please sign in to comment.