MCPcopy
hub / github.com/uptrace/uptrace / AfterQuery

Method AfterQuery

pkg/clickhouse/chdebug/debug.go:55–73  ·  view source on GitHub ↗
(ctx context.Context, event *ch.QueryEvent)

Source from the content-addressed store, hash-verified

53 return ctx, nil
54}
55func (h *QueryHook) AfterQuery(ctx context.Context, event *ch.QueryEvent) {
56 if !h.enabled {
57 return
58 }
59 if !h.verbose {
60 switch event.Err {
61 case nil, sql.ErrNoRows:
62 return
63 }
64 }
65 now := time.Now()
66 dur := now.Sub(event.StartTime)
67 args := []any{"[ch]", now.Format(" 15:04:05.000 "), formatOperation(event), formatFileLine(), fmt.Sprintf(" %10s ", dur.Round(time.Microsecond)), event.Query}
68 if event.Err != nil {
69 typ := reflect.TypeOf(event.Err).String()
70 args = append(args, "\t", color.New(color.BgRed).Sprintf(" %s ", typ+": "+event.Err.Error()))
71 }
72 fmt.Fprintln(h.writer, args...)
73}
74func formatOperation(event *ch.QueryEvent) string {
75 operation := event.Operation()
76 return operationColor(operation).Sprintf(" %-16s ", operation)

Callers

nothing calls this directly

Calls 7

formatOperationFunction · 0.85
formatFileLineFunction · 0.85
SubMethod · 0.80
FormatMethod · 0.80
RoundMethod · 0.80
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected