|
| 1 | +--- |
| 2 | +title: 'Task History' |
| 3 | +sidebar_label: 'Task History' |
| 4 | +pagination_prev: 'reference/index' |
| 5 | +pagination_next: null |
| 6 | +sidebar_position: 4 |
| 7 | +--- |
| 8 | + |
| 9 | +The Spice runtime stores information about completed tasks in the `spice.runtime.task_history` table. A task is a single unit of execution within the runtime, such as a SQL query or an AI chat completion (see [Task Types](#task-types) below). Tasks can be nested, and the runtime will record the parent-child relationship between tasks. |
| 10 | + |
| 11 | +Each task executed has a row in this table, and by default the data is retained for 8 hours. Use a `SELECT` query to return information about each task as shown in this example: |
| 12 | + |
| 13 | +```sql |
| 14 | +SELECT |
| 15 | + * |
| 16 | +FROM |
| 17 | + spice.runtime.task_history |
| 18 | +LIMIT |
| 19 | + 100; |
| 20 | +``` |
| 21 | + |
| 22 | +Output: |
| 23 | + |
| 24 | +```console |
| 25 | ++----------------------------------+------------------+----------------+---------------------+----------------------------------------------+-----------------+----------------------------+----------------------------+-----------------------+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+ |
| 26 | +| trace_id | span_id | parent_span_id | task | input | captured_output | start_time | end_time | execution_duration_ms | error_message | labels | |
| 27 | ++----------------------------------+------------------+----------------+---------------------+----------------------------------------------+-----------------+----------------------------+----------------------------+-----------------------+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+ |
| 28 | +| f94dba6b89de98c6e54b074f2353a897 | 4eb243d9b5347762 | | accelerated_refresh | runtime.metrics | | 2024-09-23T23:17:39.907789 | 2024-09-23T23:17:39.917777 | 9.988 | | {sql: SELECT * FROM runtime.metrics} | |
| 29 | +| 1f1f8305520e15ea7ad9b0a43e5d2c7e | 6aadf7c91caea3c4 | | accelerated_refresh | runtime.task_history | | 2024-09-23T23:17:39.907873 | 2024-09-23T23:17:39.917797 | 9.924000000000001 | | {sql: SELECT * FROM runtime.task_history} | |
| 30 | +| 1432e30c5ed7764f4ef35f6508dfd56c | fbb31c60d41d8232 | | accelerated_refresh | logs_file | | 2024-09-23T23:17:40.143699 | 2024-09-23T23:17:40.271678 | 127.97900000000001 | | {sql: SELECT * FROM logs_file} | |
| 31 | +| fd0b909b789938384d99f0e4e6f4b68b | 624ea4751bb6727a | | accelerated_refresh | logs | | 2024-09-23T23:17:40.676838 | 2024-09-23T23:17:42.345932 | 1669.0939999999998 | | {sql: SELECT * FROM "logs"} | |
| 32 | +| 3db5488039408825ac0829a3feb49b05 | e3e5ac928b497eef | | accelerated_refresh | decimal | | 2024-09-23T23:17:41.592359 | 2024-09-23T23:17:43.781699 | 2189.34 | | {sql: SELECT * FROM "decimal"} | |
| 33 | +| 5c5ddd481d1e19df823da74fe33f261f | 6afcfd1e65385a16 | | sql_query | select * from runtime.task_history limit 100 | | 2024-09-23T23:17:48.305649 | 2024-09-23T23:17:48.307369 | 1.72 | | {runtime_query: true, query_execution_duration_ms: 1.429375, protocol: FlightSQL, datasets: runtime.task_history, rows_produced: 5} | |
| 34 | +| 4c3dd314b874aa63fcd15023e67fc645 | cab3cdc2d31c1b6a | | sql_query | select block_number from logs_file limit 5 | | 2024-09-23T23:18:00.267218 | 2024-09-23T23:18:00.269278 | 2.06 | | {datasets: logs_file, rows_produced: 5, query_execution_duration_ms: 1.940291, accelerated: true, protocol: FlightSQL} | |
| 35 | +| f135c00df3aecd68dfa4d2360eff78f5 | db3474855449715c | | sql_query | select * from foobar | | 2024-09-23T23:18:12.865122 | 2024-09-23T23:18:12.865196 | 0.074 | Error during planning: table 'spice.public.foobar' not found | {protocol: FlightSQL, error_code: QueryPlanningError, rows_produced: 0, query_execution_duration_ms: 0.126959, datasets: } | |
| 36 | ++----------------------------------+------------------+----------------+---------------------+----------------------------------------------+-----------------+----------------------------+----------------------------+-----------------------+--------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+ |
| 37 | +``` |
| 38 | + |
| 39 | +## Task Types |
| 40 | + |
| 41 | +The following top-level task types are currently recorded: |
| 42 | + |
| 43 | +| Task Type | Description | CLI Command | |
| 44 | +| --------------------- | ----------------------------- | -------------- | |
| 45 | +| `sql_query` | SQL Query | `spice sql` | |
| 46 | +| `nsql_query` | Natural Language to SQL Query | | |
| 47 | +| `ai_chat` | AI Chat Completion | `spice chat` | |
| 48 | +| `vector_search` | Vector Search | `spice search` | |
| 49 | +| `accelerated_refresh` | Accelerated Table Refresh | | |
| 50 | +| `text_embed` | Text Embedding | | |
| 51 | + |
| 52 | +## Configuration |
| 53 | + |
| 54 | +Set the following parameters in the `runtime.task_history` section of your `config.yaml` file to configure task history: |
| 55 | + |
| 56 | +- `enabled`: Enable or disable task history. Default: `true`. |
| 57 | +- `retention_period`: The duration for which task history data is retained. Default: `8h`. |
| 58 | +- `retention_check_interval`: The interval at which the task history retention is checked. Default: `1m`. |
| 59 | +- `captured_output`: The level of output captured for tasks. `none` or `truncated`. Default: `truncated`. |
| 60 | + |
| 61 | +### Examples |
| 62 | + |
| 63 | +Adjust the retention period for task history: |
| 64 | + |
| 65 | +```yaml |
| 66 | +runtime: |
| 67 | + task_history: |
| 68 | + retention_period: 1h # Keep tasks for 1 hour |
| 69 | + retention_check_interval: 1m # Check for expired tasks every minute |
| 70 | +``` |
| 71 | +
|
| 72 | +Disable task history: |
| 73 | +
|
| 74 | +```yaml |
| 75 | +runtime: |
| 76 | + task_history: |
| 77 | + enabled: false |
| 78 | +``` |
| 79 | +
|
| 80 | +Disable capturing output from tasks: |
| 81 | +
|
| 82 | +```yaml |
| 83 | +runtime: |
| 84 | + task_history: |
| 85 | + captured_output: none # none or truncated |
| 86 | +``` |
| 87 | +
|
| 88 | +## Table Schema |
| 89 | +
|
| 90 | +| Column Name | Data Type | Is Nullable | Description | |
| 91 | +|-----------------------|---------------------------|-------------|----------------------------------------------------------------------------------| |
| 92 | +| trace_id | Utf8 | NO | Unique identifier for the entire trace this task happened in | |
| 93 | +| span_id | Utf8 | NO | Unique identifier for this specific task within the trace | |
| 94 | +| parent_span_id | Utf8 | YES | Identifier of the parent task, if any | |
| 95 | +| task | Utf8 | NO | Name or description of the task being performed (e.g. `sql_query`) | |
| 96 | +| input | Utf8 | NO | Input data or parameters for the task | |
| 97 | +| captured_output | Utf8 | YES | Output or result of the task, if available | |
| 98 | +| start_time | Timestamp(Nanosecond, None) | NO | Time when the task started | |
| 99 | +| end_time | Timestamp(Nanosecond, None) | NO | Time when the task ended | |
| 100 | +| execution_duration_ms | Float64 | NO | Duration of the task execution in milliseconds | |
| 101 | +| error_message | Utf8 | YES | Error message if the task failed, otherwise null | |
| 102 | +| labels | Map(Utf8, Utf8) | NO | Key-value pairs for additional metadata or attributes associated with the task | |
0 commit comments