Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc477ed1

Browse files
committed
add safeguard to unrecoverable analytics
1 parent5c1b2d3 commitc477ed1

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

‎peer/proto‎

‎peer/src/google/protobuf/timestamp.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//@ts-nocheck
2+
//@ts-nocheck
3+
//@ts-nocheck
24
//@generated by protobuf-ts 2.9.4 with parameter client_generic
35
//@generated from protobuf file "google/protobuf/timestamp.proto" (package "google.protobuf", syntax proto3)
46
// tslint:disable

‎peer/src/peer.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ import {
1515
import{asleep,retry}from"./util.ts";
1616
import{jwtDecode}from"jwt-decode";
1717
import{calculateWebRTCQuality,collectWebRTCStats}from"./quality.ts";
18-
import{Timestamp}from"./google/protobuf/timestamp.ts";
1918

2019
exporttype{PeerInfo}from"./signaling.ts";
2120

22-
constANALYTICS_POLL_INTERVAL_MS=5_000;
21+
constANALYTICS_POLL_INTERVAL_MS=60_000;
2322

2423
/**
2524
* Streamline real-time application development.`@pulsebeam/peer` abstracts
@@ -327,12 +326,12 @@ export class Peer {
327326
constevents:AnalyticsEvent[]=[];
328327
for(constsessofthis.sessions){
329328
constrawStats=awaitsess.getStats();
330-
constat=Timestamp.now();
329+
constat=Date.now()*1_000;
331330
conststats=collectWebRTCStats(rawStats);
332331
constquality=calculateWebRTCQuality(stats);
333332

334333
events.push({
335-
timestamp:at,
334+
timestampUs:BigInt(at),
336335
tags:{
337336
src:this.transport.info,
338337
dst:sess.other,

‎peer/src/quality.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ export function calculateWebRTCQuality(stats: WebRTCStats): number {
9292
};
9393

9494
constaggregateAndScore=(channelStats:ChannelStats[]):number=>{
95-
if(channelStats.length===0)return100;
95+
// no data, we assume not connecting
96+
if(channelStats.length===0)return0;
9697

9798
constaggregated=aggregateChannelStats(channelStats);
9899

‎peer/src/signaling.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// tslint:disable
44
import{ServiceType}from"@protobuf-ts/runtime-rpc";
55
import{MessageType}from"@protobuf-ts/runtime";
6-
import{Timestamp}from"./google/protobuf/timestamp.ts";
76
/**
87
*@generated from protobuf message pulsebeam.v1.PrepareReq
98
*/
@@ -326,9 +325,9 @@ export interface AnalyticsReportReq {
326325
*/
327326
exportinterfaceAnalyticsEvent{
328327
/**
329-
*@generated from protobuf field:google.protobuf.Timestamp timestamp = 1;
328+
*@generated from protobuf field:sint64 timestamp_us = 1;
330329
*/
331-
timestamp?:Timestamp;
330+
timestampUs:bigint;
332331
/**
333332
*@generated from protobuf field: pulsebeam.v1.AnalyticsTags tags = 2;
334333
*/
@@ -688,7 +687,7 @@ export const AnalyticsReportReq = new AnalyticsReportReq$Type();
688687
classAnalyticsEvent$TypeextendsMessageType<AnalyticsEvent>{
689688
constructor(){
690689
super("pulsebeam.v1.AnalyticsEvent",[
691-
{no:1,name:"timestamp",kind:"message",T:()=>Timestamp},
690+
{no:1,name:"timestamp_us",kind:"scalar",T:18/*ScalarType.SINT64*/,L:0/*LongType.BIGINT*/},
692691
{no:2,name:"tags",kind:"message",T:()=>AnalyticsTags},
693692
{no:3,name:"metrics",kind:"message",T:()=>AnalyticsMetrics}
694693
]);

‎peer/src/transport.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ const POLL_TIMEOUT_MS = 900000;
1515
constPOLL_RETRY_BASE_DELAY_MS=50;
1616
constPOLL_RETRY_MAX_DELAY_MS=1000;
1717

18+
constANALYTICS_POLL_RETRY_BASE_DELAY_MS=1000;
19+
constANALYTICS_POLL_RETRY_MAX_DELAY_MS=4000;
20+
1821
exportenumReservedConnId{
1922
Discovery=0,
2023
Max=16,
@@ -339,9 +342,9 @@ export class Transport {
339342
timeout:POLL_TIMEOUT_MS,
340343
};
341344
constretryOpt:RetryOptions={
342-
baseDelay:POLL_RETRY_BASE_DELAY_MS,
343-
maxDelay:POLL_RETRY_MAX_DELAY_MS,
344-
maxRetries:-1,
345+
baseDelay:ANALYTICS_POLL_RETRY_BASE_DELAY_MS,
346+
maxDelay:ANALYTICS_POLL_RETRY_MAX_DELAY_MS,
347+
maxRetries:3,
345348
abortSignal:this.abort.signal,
346349
isRecoverable:this.isRecoverable,
347350
};
@@ -360,8 +363,10 @@ export class Transport {
360363

361364
return;
362365
}catch(err){
363-
this.logger.error("unrecoverable error, force closing",{ err});
364-
this.close();
366+
this.logger.error(
367+
"analytics backend is in unrecoverable state, dropping analytics event",
368+
{ err},
369+
);
365370
return;
366371
}
367372
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp