-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add to turborepo in tools packages and validate data advanced …
…query
- Loading branch information
1 parent
4a2a310
commit 1796843
Showing
6 changed files
with
76 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0
tools/scripts/README.md → packages/tools/scripts/README.md
100644 → 100755
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
tools/scripts/package-lock.json → packages/tools/scripts/package-lock.json
100644 → 100755
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
0
tools/scripts/package.json → packages/tools/scripts/package.json
100644 → 100755
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const { createClient } = require('@clickhouse/client'); | ||
const dotenv = require('dotenv'); | ||
|
||
dotenv.config({ path: '../../../.env' }); | ||
|
||
const client = createClient({ | ||
host: process.env.CLICKHOUSE_ENDPOINT, | ||
database: process.env.CLICKHOUSE_DATABASE, | ||
username: process.env.CLICKHOUSE_USERNAME, | ||
password: process.env.CLICKHOUSE_PASSWORD | ||
}); | ||
|
||
async function validateDataStreaming() { | ||
console.log('Validating data streaming to ClickHouse...'); | ||
|
||
try { | ||
const countQuery = await client.query({ | ||
query: 'SELECT COUNT(*) as count FROM default.otel_traces', | ||
format: 'JSONEachRow' | ||
}); | ||
const countData = await countQuery.json(); | ||
console.log(`Found ${countData[0].count} records in ClickHouse.`); | ||
|
||
const latestDataQuery = await client.query({ | ||
query: 'SELECT MAX(Timestamp) as latest FROM default.otel_traces', | ||
format: 'JSONEachRow' | ||
}); | ||
const latestData = await latestDataQuery.json(); | ||
console.log(`Latest data received at ${new Date(latestData[0].latest).toLocaleString()}`); | ||
|
||
const spanNamesQuery = await client.query({ | ||
query: 'SELECT DISTINCT SpanName FROM default.otel_traces LIMIT 10', | ||
format: 'JSONEachRow' | ||
}); | ||
const spanNames = await spanNamesQuery.json(); | ||
console.log('Span names found:', spanNames.map(row => row.SpanName).join(', ')); | ||
|
||
const largePayloadQuery = await client.query({ | ||
query: 'SELECT COUNT(*) as count FROM default.otel_traces WHERE length(SpanAttributes) > 10', | ||
format: 'JSONEachRow' | ||
}); | ||
const largePayloadData = await largePayloadQuery.json(); | ||
console.log(`Number of spans with large payloads: ${largePayloadData[0].count}`); | ||
|
||
const sdkLanguageQuery = await client.query({ | ||
query: 'SELECT DISTINCT ResourceAttributes[\'telemetry.sdk.language\'] as sdk_language FROM default.otel_traces WHERE ResourceAttributes[\'telemetry.sdk.language\'] IS NOT NULL LIMIT 1', | ||
format: 'JSONEachRow' | ||
}); | ||
const sdkLanguageData = await sdkLanguageQuery.json(); | ||
console.log(`SDK Language: ${sdkLanguageData[0]?.sdk_language || 'Not found'}`); | ||
|
||
const exporterQuery = await client.query({ | ||
query: 'SELECT DISTINCT ResourceAttributes[\'telemetry.sdk.name\'] as sdk_name FROM default.otel_traces WHERE ResourceAttributes[\'telemetry.sdk.name\'] IS NOT NULL LIMIT 1', | ||
format: 'JSONEachRow' | ||
}); | ||
const exporterData = await exporterQuery.json(); | ||
console.log(`Exporter SDK: ${exporterData[0]?.sdk_name || 'Not found'}`); | ||
|
||
const avgDurationQuery = await client.query({ | ||
query: 'SELECT AVG(Duration) as avg_duration FROM default.otel_traces', | ||
format: 'JSONEachRow' | ||
}); | ||
const avgDurationData = await avgDurationQuery.json(); | ||
console.log(`Average span duration: ${avgDurationData[0].avg_duration} ns`); | ||
|
||
console.log('Data streaming validation completed successfully.'); | ||
} catch (error) { | ||
console.error('Error during data streaming validation:', error); | ||
} finally { | ||
await client.close(); | ||
} | ||
} | ||
|
||
validateDataStreaming(); |
This file was deleted.
Oops, something went wrong.