|
|
@ -785,7 +785,7 @@ func registerHandlers(sess *discordgo.Session, handlers map[string]Handler) {
|
|
|
|
defer cancel()
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
|
|
if h, ok := handlers[i.ApplicationCommandData().Name]; ok {
|
|
|
|
if h, ok := handlers[i.ApplicationCommandData().Name]; ok {
|
|
|
|
withLogging(i.ApplicationCommandData().Name, h)(ctx, s, i)
|
|
|
|
inSpan(i.ApplicationCommandData().Name, withLogging(i.ApplicationCommandData().Name, h))(ctx, s, i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case discordgo.InteractionModalSubmit:
|
|
|
|
case discordgo.InteractionModalSubmit:
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
|
@ -952,11 +952,17 @@ func serve(address string) error {
|
|
|
|
return http.ListenAndServe(address, nil)
|
|
|
|
return http.ListenAndServe(address, nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func withLogging(name string, h Handler) Handler {
|
|
|
|
func inSpan(name string, h Handler) Handler {
|
|
|
|
return func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error {
|
|
|
|
return func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error {
|
|
|
|
ctx, span := tracer.Start(ctx, fmt.Sprintf("discord_command %s", name))
|
|
|
|
ctx, span := tracer.Start(ctx, fmt.Sprintf("discord_command %s", name))
|
|
|
|
defer span.End()
|
|
|
|
defer span.End()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return h(ctx, s, i)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func withLogging(name string, h Handler) Handler {
|
|
|
|
|
|
|
|
return func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error {
|
|
|
|
start := time.Now()
|
|
|
|
start := time.Now()
|
|
|
|
logCommandInvocation(ctx, name, s, i)
|
|
|
|
logCommandInvocation(ctx, name, s, i)
|
|
|
|
err := h(ctx, s, i)
|
|
|
|
err := h(ctx, s, i)
|
|
|
|