Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8/new telemetry (QuestDB implementation) #3424

Open
wants to merge 24 commits into
base: release/v8.0.0-beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@
"telemetry": {
"enabled": true,
"implementation": {
"ot-telemetry": {
"quest-telemetry": {
"enabled": true,
"package": "./telemetry/implementation/ot-telemetry.js",
"package": "./telemetry/implementation/quest-telemetry.js",
"config": {
"sendTelemetryData": false,
"signalingServerUrl": "null"
}
"ip_endpoint": "http::addr=localhost:10000",
"sendTelemetryData": false
}
}
}
}
Expand Down Expand Up @@ -319,13 +319,13 @@
"telemetry": {
"enabled": true,
"implementation": {
"ot-telemetry": {
"quest-telemetry": {
"enabled": true,
"package": "./telemetry/implementation/ot-telemetry.js",
"package": "./telemetry/implementation/quest-telemetry.js",
"config": {
"sendTelemetryData": false,
"signalingServerUrl": "null"
}
"ip_endpoint": "http::addr=localhost:10000",
"sendTelemetryData": false
}
}
}
}
Expand Down Expand Up @@ -487,13 +487,13 @@
"telemetry": {
"enabled": true,
"implementation": {
"ot-telemetry": {
"quest-telemetry": {
"enabled": true,
"package": "./telemetry/implementation/ot-telemetry.js",
"package": "./telemetry/implementation/quest-telemetry.js",
"config": {
"sendTelemetryData": true,
"signalingServerUrl": "https://v8-testnet-signaling.origin-trail.network/signal"
}
"ip_endpoint": "http::addr=localhost:10000",
"sendTelemetryData": false
}
}
}
}
Expand Down Expand Up @@ -654,13 +654,13 @@
"telemetry": {
"enabled": true,
"implementation": {
"ot-telemetry": {
"quest-telemetry": {
"enabled": true,
"package": "./telemetry/implementation/ot-telemetry.js",
"package": "./telemetry/implementation/quest-telemetry.js",
"config": {
"sendTelemetryData": true,
"signalingServerUrl": "https://devnet-signaling.origin-trail.network/signal"
}
"ip_endpoint": "http::addr=localhost:10000",
"sendTelemetryData": false
}
}
}
}
Expand Down Expand Up @@ -844,13 +844,13 @@
"telemetry": {
"enabled": true,
"implementation": {
"ot-telemetry": {
"quest-telemetry": {
"enabled": true,
"package": "./telemetry/implementation/ot-telemetry.js",
"package": "./telemetry/implementation/quest-telemetry.js",
"config": {
"sendTelemetryData": true,
"signalingServerUrl": "https://mainnet-signaling.origin-trail.network/signal"
}
"ip_endpoint": "http::addr=localhost:10000",
"sendTelemetryData": false
}
}
}
}
Expand Down
17 changes: 0 additions & 17 deletions ot-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class OTNode {

await this.initializeRouters();
await this.startNetworkModule();
this.startTelemetryModule();
this.resumeCommandExecutor();
this.logger.info('Node is up and running!');

Expand Down Expand Up @@ -348,22 +347,6 @@ class OTNode {
await networkModuleManager.start();
}

startTelemetryModule() {
const telemetryModuleManager = this.container.resolve('telemetryModuleManager');
const repositoryModuleManager = this.container.resolve('repositoryModuleManager');
telemetryModuleManager.listenOnEvents((eventData) => {
repositoryModuleManager.createEventRecord(
eventData.operationId,
eventData.blockchainId,
eventData.lastEvent,
eventData.timestamp,
eventData.value1,
eventData.value2,
eventData.value3,
);
});
}

async initializeShardingTableService() {
try {
const shardingTableService = this.container.resolve('shardingTableService');
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/hash": "^5.7.0",
"@ethersproject/wallet": "^5.7.0",
"@questdb/nodejs-client": "^3.0.0",
"@polkadot/api": "^9.3.2",
"@polkadot/keyring": "^10.1.7",
"@polkadot/util": "^10.1.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,6 @@ class EventRepository {
this.model = models.event;
}

async createEventRecord(operationId, blockchainId, name, timestamp, value1, value2, value3) {
return this.model.create({
operationId,
blockchainId,
name,
timestamp,
value1,
value2,
value3,
});
}

async getUnpublishedEvents() {
// events without COMPLETE/FAILED status which are older than 30min
// are also considered finished
Expand Down
20 changes: 0 additions & 20 deletions src/modules/repository/repository-module-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,26 +208,6 @@ class RepositoryModuleManager extends BaseModuleManager {
return this.getRepository('shard').cleanShardingTable(blockchainId);
}

async createEventRecord(
operationId,
blockchainId,
name,
timestamp,
value1 = null,
value2 = null,
value3 = null,
) {
return this.getRepository('event').createEventRecord(
operationId,
blockchainId,
name,
timestamp,
value1,
value2,
value3,
);
}

async getUnpublishedEvents() {
return this.getRepository('event').getUnpublishedEvents();
}
Expand Down
29 changes: 0 additions & 29 deletions src/modules/telemetry/implementation/ot-telemetry.js

This file was deleted.

45 changes: 45 additions & 0 deletions src/modules/telemetry/implementation/quest-telemetry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Sender } from '@questdb/nodejs-client';

class QuestTelemetry {
async initialize(config, logger) {
this.config = config;
this.logger = logger;
this.sender = Sender.fromConfig(this.config.ip_endpoint);
}

listenOnEvents(eventEmitter, onEventReceived) {
return eventEmitter.on('operation_status_changed', onEventReceived);
}

async sendTelemetryData(
operationId,
timestamp,
blockchainId = '',
name = '',
value1 = null,
value2 = null,
value3 = null,
) {
try {
const table = this.sender.table('event');

table.symbol('operationId', operationId || 'NULL');
table.symbol('blockchainId', blockchainId || 'NULL');
table.symbol('name', name || 'NULL');
if (value1 !== null) table.symbol('value1', value1);
if (value2 !== null) table.symbol('value2', value2);
if (value3 !== null) table.symbol('value3', value3);
table.timestampColumn('timestamp', timestamp * 1000);

await table.at(Date.now(), 'ms');
await this.sender.flush();
await this.sender.close();

this.logger.info('Event telemetry successfully sent to QuestDB');
} catch (err) {
this.logger.error(`Error sending telemetry to QuestDB: ${err.message}`);
}
}
}

export default QuestTelemetry;
30 changes: 27 additions & 3 deletions src/modules/telemetry/telemetry-module-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ class TelemetryModuleManager extends BaseModuleManager {
return 'telemetry';
}

async initialize() {
await super.initialize();

this.listenOnEvents((eventData) => {
this.sendTelemetryData(
eventData.operationId,
eventData.timestamp,
eventData.blockchainId,
eventData.lastEvent,
eventData.value1,
eventData.value2,
eventData.value3,
);
});
}

listenOnEvents(onEventReceived) {
if (this.config.modules.telemetry.enabled && this.initialized) {
return this.getImplementation().module.listenOnEvents(
Expand All @@ -19,9 +35,17 @@ class TelemetryModuleManager extends BaseModuleManager {
}
}

async sendTelemetryData(nodeData, events) {
if (this.initialized) {
return this.getImplementation().module.sendTelemetryData(nodeData, events);
async sendTelemetryData(operationId, timestamp, blockchainId, name, value1, value2, value3) {
if (this.getImplementation().config.sendTelemetryData && this.initialized) {
return this.getImplementation().module.sendTelemetryData(
operationId,
timestamp,
blockchainId,
name,
value1,
value2,
value3,
);
}
}
}
Expand Down