Mods to Event Generator and limit provider

- Changed SEVERE to use `is-event--purple` style.
- Mods to EventTelemetryProvider.js:
  - Adds a more random start time to each event.
  - Reduces frequency at which a severity is applied to events.
This commit is contained in:
Charles Hacskaylo 2024-12-17 16:27:45 -08:00
parent b865d8c038
commit 27af030566
2 changed files with 12 additions and 5 deletions

View File

@ -25,7 +25,7 @@ export const SEVERITY_CSS = {
WARNING: 'is-event--yellow',
DISTRESS: 'is-event--red',
CRITICAL: 'is-event--red',
SEVERE: 'is-event--red'
SEVERE: 'is-event--purple'
};
const NOMINAL_SEVERITY = {

View File

@ -27,6 +27,8 @@
import { SEVERITY_CSS } from './EventLimitProvider.js';
import messages from './transcript.json';
const DUR_MIN = 1000;
const DUR_MAX = 10000;
class EventTelemetryProvider {
constructor() {
this.defaultSize = 25;
@ -34,12 +36,17 @@ class EventTelemetryProvider {
generateData(firstObservedTime, count, startTime, duration, name) {
const millisecondsSinceStart = startTime - firstObservedTime;
const utc = startTime + count * duration;
const randStartDelay = Math.max(DUR_MIN, Math.random() * DUR_MAX);
const utc = startTime + randStartDelay + count * duration;
const ind = count % messages.length;
const message = messages[ind] + ' - [' + millisecondsSinceStart + ']';
// pick a random severity level + 1 for an undefined level so we can do nominal
const severity =
Object.keys(SEVERITY_CSS)[Math.floor(Math.random() * Object.keys(SEVERITY_CSS).length + 1)];
Math.random() > 0.4
? Object.keys(SEVERITY_CSS)[
Math.floor(Math.random() * Object.keys(SEVERITY_CSS).length + 1)
]
: undefined;
return {
name,
@ -58,7 +65,7 @@ class EventTelemetryProvider {
}
subscribe(domainObject, callback) {
const duration = domainObject.telemetry.duration * 1000;
const duration = domainObject.telemetry.duration * DUR_MIN;
const firstObservedTime = Date.now();
let count = 0;
@ -83,7 +90,7 @@ class EventTelemetryProvider {
request(domainObject, options) {
let start = options.start;
const end = Math.min(Date.now(), options.end); // no future values
const duration = domainObject.telemetry.duration * 1000;
const duration = domainObject.telemetry.duration * DUR_MIN;
const size = options.size ? options.size : this.defaultSize;
const data = [];
const firstObservedTime = options.start;