(ctx context.Context, dump bool)
| 183 | } |
| 184 | |
| 185 | func (s *ShellStateStore) debug(ctx context.Context, dump bool) { |
| 186 | slog := slog.SpanLogger(ctx, InstrumentationLibrary) |
| 187 | |
| 188 | // Dumping the full states in the store can be useful to debug issues related |
| 189 | // to managing state but it can generate a bunch of hard to read output so |
| 190 | // tailor to verbosity level. |
| 191 | |
| 192 | if verbose < 2 { |
| 193 | s.mu.RLock() |
| 194 | size := len(s.data) |
| 195 | s.mu.RUnlock() |
| 196 | slog.Debug("state store", "items", size) |
| 197 | return |
| 198 | } |
| 199 | |
| 200 | if !dump || verbose < 4 { |
| 201 | s.mu.RLock() |
| 202 | keys := slices.Collect(maps.Keys(s.data)) |
| 203 | s.mu.RUnlock() |
| 204 | slog.Debug("state store", "items", keys) |
| 205 | return |
| 206 | } |
| 207 | |
| 208 | s.mu.RLock() |
| 209 | states := slices.Collect(maps.Values(s.data)) |
| 210 | s.mu.RUnlock() |
| 211 | |
| 212 | for _, st := range states { |
| 213 | slog.Debug("state store dump", spreadDebugArgs(&st)...) |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | func spreadDebugArgs(args ...any) []any { |
| 218 | a := []any{} |
no test coverage detected