sendProfilingMetadata reads the profiling output file written by DuckDB and sends it as gRPC trailing metadata so the control plane can attach it to the trace span.
(ctx context.Context, session *Session)
| 23 | // clearProfilingOutput removes the previous statement's profile before a |
| 24 | // statement begins. The returned timestamp is used to reject a profile that |
| 25 | // was not produced by this execution. |
| 26 | func clearProfilingOutput() time.Time { |
| 27 | _ = os.Remove(profilingOutputPath) |
| 28 | return time.Now() |
| 29 | } |
| 30 | |
| 31 | func profilingMetadataSince(startedAt time.Time) string { |
| 32 | info, err := os.Stat(profilingOutputPath) |
| 33 | if err != nil || !info.ModTime().After(startedAt) { |
| 34 | return "" |
| 35 | } |
| 36 | data, err := os.ReadFile(profilingOutputPath) |
| 37 | if err != nil || len(data) == 0 { |
| 38 | return "" |
| 39 | } |
no test coverage detected