mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Traces: Do not use red in span colors as this looks like an error (#50074)
* Do not allow red in span colors * Added test
This commit is contained in:
parent
d20608ab84
commit
56eb131715
@ -37,3 +37,13 @@ it('should clear cache', () => {
|
|||||||
const colorTwo = getColorByKey('serviceB', createTheme());
|
const colorTwo = getColorByKey('serviceB', createTheme());
|
||||||
expect(colorOne).toBe(colorTwo);
|
expect(colorOne).toBe(colorTwo);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not allow red', () => {
|
||||||
|
clear();
|
||||||
|
getColorByKey('serviceA', createTheme());
|
||||||
|
getColorByKey('serviceB', createTheme());
|
||||||
|
getColorByKey('serviceC', createTheme());
|
||||||
|
getColorByKey('serviceD', createTheme());
|
||||||
|
const colorFive = getColorByKey('serviceE', createTheme());
|
||||||
|
expect(colorFive).not.toBe('#E24D42');
|
||||||
|
});
|
||||||
|
@ -44,9 +44,10 @@ class ColorGenerator {
|
|||||||
_getColorIndex(key: string): number {
|
_getColorIndex(key: string): number {
|
||||||
let i = this.cache.get(key);
|
let i = this.cache.get(key);
|
||||||
if (i == null) {
|
if (i == null) {
|
||||||
i = this.currentIdx;
|
// colors[4] is red (which we want to disallow as a span color because it looks like an error)
|
||||||
this.cache.set(key, this.currentIdx);
|
i = this.currentIdx !== 4 ? this.currentIdx : this.currentIdx + 1;
|
||||||
this.currentIdx = ++this.currentIdx % this.colorsHex.length;
|
this.cache.set(key, i);
|
||||||
|
this.currentIdx = (i + 1) % this.colorsHex.length;
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user