mirror of
https://github.com/waku-org/waku-lab.git
synced 2025-01-22 05:39:44 +00:00
feat: record light push errors in dogfooding (#79)
This commit is contained in:
parent
2e55c4c548
commit
67fe074471
@ -11,13 +11,15 @@ import {
|
|||||||
import { Type, Field } from "protobufjs";
|
import { Type, Field } from "protobufjs";
|
||||||
import {
|
import {
|
||||||
TelemetryClient,
|
TelemetryClient,
|
||||||
|
TelemetryPushError,
|
||||||
TelemetryPushFilter,
|
TelemetryPushFilter,
|
||||||
TelemetryType,
|
TelemetryType,
|
||||||
} from "./telemetry_client";
|
} from "./telemetry_client";
|
||||||
import { generateRandomNumber, hashNumber } from "./util";
|
import { generateRandomNumber, hashNumber } from "./util";
|
||||||
|
|
||||||
const DEFAULT_CONTENT_TOPIC = "/js-waku-examples/1/message-ratio/utf8";
|
const DEFAULT_CONTENT_TOPIC = "/js-waku-examples/1/message-ratio/utf8";
|
||||||
const TELEMETRY_URL = process.env.TELEMETRY_URL || "http://localhost:8080/waku-metrics";
|
const TELEMETRY_URL =
|
||||||
|
process.env.TELEMETRY_URL || "http://localhost:8080/waku-metrics";
|
||||||
|
|
||||||
const ProtoSequencedMessage = new Type("SequencedMessage")
|
const ProtoSequencedMessage = new Type("SequencedMessage")
|
||||||
.add(new Field("hash", 1, "string"))
|
.add(new Field("hash", 1, "string"))
|
||||||
@ -42,9 +44,13 @@ export async function app(telemetryClient: TelemetryClient) {
|
|||||||
// TODO: https://github.com/waku-org/js-waku/issues/2079
|
// TODO: https://github.com/waku-org/js-waku/issues/2079
|
||||||
// Dialing bootstrap peers right on start in order to have Filter subscription initiated properly
|
// Dialing bootstrap peers right on start in order to have Filter subscription initiated properly
|
||||||
await node.dial("/dns4/node-01.do-ams3.waku.test.status.im/tcp/8000/wss");
|
await node.dial("/dns4/node-01.do-ams3.waku.test.status.im/tcp/8000/wss");
|
||||||
await node.dial("/dns4/node-01.ac-cn-hongkong-c.waku.test.status.im/tcp/8000/wss");
|
await node.dial(
|
||||||
await node.dial("/dns4/node-01.gc-us-central1-a.waku.test.status.im/tcp/8000/wss");
|
"/dns4/node-01.ac-cn-hongkong-c.waku.test.status.im/tcp/8000/wss"
|
||||||
|
);
|
||||||
|
await node.dial(
|
||||||
|
"/dns4/node-01.gc-us-central1-a.waku.test.status.im/tcp/8000/wss"
|
||||||
|
);
|
||||||
|
|
||||||
await waitForRemotePeer(node);
|
await waitForRemotePeer(node);
|
||||||
|
|
||||||
const peerId = node.libp2p.peerId.toString();
|
const peerId = node.libp2p.peerId.toString();
|
||||||
@ -107,7 +113,17 @@ export async function app(telemetryClient: TelemetryClient) {
|
|||||||
sequenceIndex++;
|
sequenceIndex++;
|
||||||
}
|
}
|
||||||
if (result.failures.length > 0) {
|
if (result.failures.length > 0) {
|
||||||
console.error("Failed to send message", result.failures);
|
telemetryClient.push<TelemetryPushError>(
|
||||||
|
result.failures.map((failure) => ({
|
||||||
|
messageType: TelemetryType.LIGHT_PUSH_ERROR,
|
||||||
|
timestamp: Math.floor(new Date().getTime() / 1000),
|
||||||
|
peerId: peerId,
|
||||||
|
peerIdRemote: failure.peerId?.toString(),
|
||||||
|
errorMessage: failure.error.toString(),
|
||||||
|
contentTopic: DEFAULT_CONTENT_TOPIC,
|
||||||
|
pubsubTopic: DefaultPubsubTopic,
|
||||||
|
}))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (sequenceIndex < sequenceTotal) {
|
if (sequenceIndex < sequenceTotal) {
|
||||||
setTimeout(sendMessage, period); // Schedule the next send
|
setTimeout(sendMessage, period); // Schedule the next send
|
||||||
@ -166,10 +182,7 @@ export async function app(telemetryClient: TelemetryClient) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const telemetryClient = new TelemetryClient(
|
const telemetryClient = new TelemetryClient(TELEMETRY_URL, 5000);
|
||||||
TELEMETRY_URL,
|
|
||||||
5000
|
|
||||||
);
|
|
||||||
const { node, startLightPushSequence, startFilterSubscription } = await app(
|
const { node, startLightPushSequence, startFilterSubscription } = await app(
|
||||||
telemetryClient
|
telemetryClient
|
||||||
);
|
);
|
||||||
@ -198,4 +211,4 @@ export async function app(telemetryClient: TelemetryClient) {
|
|||||||
|
|
||||||
document.addEventListener(sequenceCompletedEvent.type, () => startSequence());
|
document.addEventListener(sequenceCompletedEvent.type, () => startSequence());
|
||||||
startSequence();
|
startSequence();
|
||||||
})();
|
})();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
export enum TelemetryType {
|
export enum TelemetryType {
|
||||||
LIGHT_PUSH_FILTER = "LightPushFilter",
|
LIGHT_PUSH_FILTER = "LightPushFilter",
|
||||||
|
LIGHT_PUSH_ERROR = "LightPushError",
|
||||||
|
GENERIC = "Generic"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top level structure of a telemetry request
|
// Top level structure of a telemetry request
|
||||||
@ -25,6 +27,23 @@ export interface TelemetryPushFilter extends TelemetryMessage {
|
|||||||
pubsubTopic: string;
|
pubsubTopic: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TelemetryPushError extends TelemetryMessage {
|
||||||
|
peerId: string;
|
||||||
|
errorMessage: string;
|
||||||
|
peerIdRemote?: string;
|
||||||
|
contentTopic?: string;
|
||||||
|
pubsubTopic?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TelemetryGeneric extends TelemetryMessage {
|
||||||
|
peerId: string;
|
||||||
|
metricType: string;
|
||||||
|
contentTopic?: string;
|
||||||
|
pubsubTopic?: string;
|
||||||
|
genericData?: string;
|
||||||
|
errorMessage?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export class TelemetryClient {
|
export class TelemetryClient {
|
||||||
constructor(
|
constructor(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user