Commit 27dcd0ed by Ryan McKinley Committed by Torkel Ödegaard

TestData: add log level in dummy message (#16815)

parent 4beed358
......@@ -8,6 +8,7 @@ import {
DataStreamObserver,
DataStreamState,
LoadingState,
LogLevel,
} from '@grafana/ui';
import { TestDataQuery, StreamingQuery } from './types';
......@@ -218,21 +219,44 @@ export class LogsWorker extends StreamWorker {
}, 10);
}
getRandomLogLevel(): LogLevel {
const v = Math.random();
if (v > 0.9) {
return LogLevel.critical;
}
if (v > 0.8) {
return LogLevel.error;
}
if (v > 0.7) {
return LogLevel.warning;
}
if (v > 0.4) {
return LogLevel.info;
}
if (v > 0.3) {
return LogLevel.debug;
}
if (v > 0.1) {
return LogLevel.trace;
}
return LogLevel.unknown;
}
getNextWord() {
this.index = (this.index + Math.floor(Math.random() * 5)) % words.length;
return words[this.index];
}
getRandomLine() {
getRandomLine(length = 60) {
let line = this.getNextWord();
while (line.length < 80) {
while (line.length < length) {
line += ' ' + this.getNextWord();
}
return line;
}
nextRow = (time: number) => {
return [time, this.getRandomLine()];
return [time, '[' + this.getRandomLogLevel() + '] ' + this.getRandomLine()];
};
initBuffer(refId: string): SeriesData {
......@@ -270,9 +294,10 @@ export class LogsWorker extends StreamWorker {
if (query.speed < 5) {
query.speed = 5;
}
const variance = query.speed * 0.2 * (Math.random() - 0.5); // +-10%
this.appendRows([this.nextRow(Date.now())]);
this.timeoutId = window.setTimeout(this.looper, query.speed);
this.timeoutId = window.setTimeout(this.looper, query.speed + variance);
};
}
......
......@@ -58,7 +58,7 @@
step="10"
ng-change="ctrl.streamChanged()" />
</div>
<div class="gf-form">
<div class="gf-form" ng-if="ctrl.target.stream.type === 'signal'">
<label class="gf-form-label query-keyword">Spread</label>
<input type="number"
class="gf-form-input width-5"
......@@ -68,7 +68,7 @@
step="0.1"
ng-change="ctrl.streamChanged()" />
</div>
<div class="gf-form">
<div class="gf-form" ng-if="ctrl.target.stream.type === 'signal'">
<label class="gf-form-label query-keyword">Noise</label>
<input type="number"
class="gf-form-input width-5"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment