Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix opbot issue in public chan (#2850) #2851

Merged
merged 2 commits into from
Jul 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
}
}

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
Loading