()
| 5 | const DATASET = isProd ? 'codebuff_data' : 'codebuff_data_dev' |
| 6 | |
| 7 | async function printRecentTraces() { |
| 8 | try { |
| 9 | // Setup BigQuery client |
| 10 | setupBigQuery({ logger: console }) |
| 11 | .catch((err) => { |
| 12 | console.error( |
| 13 | { |
| 14 | error: err, |
| 15 | stack: err.stack, |
| 16 | message: err.message, |
| 17 | name: err.name, |
| 18 | code: err.code, |
| 19 | details: err.details, |
| 20 | }, |
| 21 | 'Failed to initialize BigQuery client', |
| 22 | ) |
| 23 | }) |
| 24 | .finally(() => { |
| 25 | console.debug('BigQuery initialization completed') |
| 26 | }) |
| 27 | |
| 28 | // Use the BigQuery client to get recent traces |
| 29 | const traces = await getRecentTraces(10, DATASET) |
| 30 | |
| 31 | console.log('\nLast 10 traces by timestamp:') |
| 32 | console.log('--------------------------------') |
| 33 | console.log(`Using dataset: ${DATASET}`) |
| 34 | console.log('--------------------------------') |
| 35 | |
| 36 | traces.forEach((trace) => { |
| 37 | console.log(` |
| 38 | ID: ${trace.id} |
| 39 | User ID: ${trace.user_id} |
| 40 | Agent Step ID: ${trace.agent_step_id} |
| 41 | Type: ${trace.type} |
| 42 | Created at: ${JSON.stringify(trace.created_at)} |
| 43 | Payload: ${JSON.stringify(trace.payload, null, 2).slice(0, 100)}... |
| 44 | --------------------------------`) |
| 45 | }) |
| 46 | } catch (error) { |
| 47 | console.error('Error fetching traces:', error) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // Run the function |
| 52 | printRecentTraces() |
no test coverage detected