mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TEMPORARY: introduce a breaking change in @grafana/data
This commit is contained in:
parent
d82d88f840
commit
986ac9ab82
@ -3,12 +3,12 @@ import { Labels } from '../types/data';
|
||||
|
||||
describe('parseLabels()', () => {
|
||||
it('returns no labels on empty labels string', () => {
|
||||
expect(parseLabels('')).toEqual({});
|
||||
expect(parseLabels('{}')).toEqual({});
|
||||
expect(parseLabels('', 'Foo')).toEqual({});
|
||||
expect(parseLabels('{}', 'Foo')).toEqual({});
|
||||
});
|
||||
|
||||
it('returns labels on labels string', () => {
|
||||
expect(parseLabels('{foo="bar", baz="42"}')).toEqual({ foo: 'bar', baz: '42' });
|
||||
expect(parseLabels('{foo="bar", baz="42"}', 'Foo')).toEqual({ foo: 'bar', baz: '42' });
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -10,7 +10,9 @@ const labelRegexp = /\b(\w+)(!?=~?)"([^"\n]*?)"/g;
|
||||
*
|
||||
* Example: `parseLabels('{job="foo", instance="bar"}) // {job: "foo", instance: "bar"}`
|
||||
*/
|
||||
export function parseLabels(labels: string): Labels {
|
||||
export function parseLabels(labels: string, foo: string): Labels {
|
||||
console.log(foo);
|
||||
|
||||
const labelsByKey: Labels = {};
|
||||
labels.replace(labelRegexp, (_, key, operator, value) => {
|
||||
labelsByKey[key] = value;
|
||||
|
@ -32,7 +32,7 @@ export class LiveStreams {
|
||||
const data = new CircularDataFrame({ capacity: target.size });
|
||||
data.addField({ name: 'ts', type: FieldType.time, config: { displayName: 'Time' } });
|
||||
data.addField({ name: 'tsNs', type: FieldType.time, config: { displayName: 'Time ns' } });
|
||||
data.addField({ name: 'line', type: FieldType.string }).labels = parseLabels(target.query);
|
||||
data.addField({ name: 'line', type: FieldType.string }).labels = parseLabels(target.query, 'Foo');
|
||||
data.addField({ name: 'labels', type: FieldType.other }); // The labels for each line
|
||||
data.addField({ name: 'id', type: FieldType.string });
|
||||
data.meta = { ...data.meta, preferredVisualisationType: 'logs' };
|
||||
|
Loading…
Reference in New Issue
Block a user