diff --git a/cmd/themis-server/main.go b/cmd/themis-server/main.go index 908385e..51bd6a7 100644 --- a/cmd/themis-server/main.go +++ b/cmd/themis-server/main.go @@ -785,7 +785,7 @@ func registerHandlers(sess *discordgo.Session, handlers map[string]Handler) { defer cancel() 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: ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) @@ -952,11 +952,17 @@ func serve(address string) error { 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 { ctx, span := tracer.Start(ctx, fmt.Sprintf("discord_command %s", name)) 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() logCommandInvocation(ctx, name, s, i) err := h(ctx, s, i)