mirror of
https://github.com/grafana/grafana.git
synced 2025-01-02 12:17:01 -06:00
Tempo: Remove kind=server from metrics summary (#89419)
* Update query / messaging * Update field * Update test
This commit is contained in:
parent
5f44c97e5f
commit
76c1750d38
@ -71,10 +71,7 @@ export const GroupByField = (props: Props) => {
|
||||
const scopeOptions = Object.values(TraceqlSearchScope).map((t) => ({ label: t, value: t }));
|
||||
|
||||
return (
|
||||
<InlineSearchField
|
||||
label="Aggregate by"
|
||||
tooltip="Select one or more tags to see the metrics summary. Note: the metrics summary API only considers spans of kind = server."
|
||||
>
|
||||
<InlineSearchField label="Aggregate by" tooltip="Select one or more tags to see the metrics summary.">
|
||||
<>
|
||||
{query.groupBy?.map((f, i) => {
|
||||
const tags = getTags(f)
|
||||
|
@ -536,9 +536,7 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
|
||||
if (!response.data.summaries) {
|
||||
return {
|
||||
error: {
|
||||
message: getErrorMessage(
|
||||
`No summary data for '${groupBy}'. Note: the metrics summary API only considers spans of kind = server. You can check if the attributes exist by running a TraceQL query like { attr_key = attr_value && kind = server }`
|
||||
),
|
||||
message: getErrorMessage(`No summary data for '${groupBy}'.`),
|
||||
},
|
||||
data: emptyResponse,
|
||||
};
|
||||
|
@ -58,7 +58,7 @@ describe('MetricsSummary', () => {
|
||||
"datasourceName": "tempo",
|
||||
"datasourceUid": "gdev-tempo",
|
||||
"query": {
|
||||
"query": "{name="HTTP POST - post" && span.http.status_code=\${__data.fields["span.http.status_code"]} && temperature=\${__data.fields["temperature"]} && kind=server} | by(resource.service.name)",
|
||||
"query": "{name="HTTP POST - post" && span.http.status_code=\${__data.fields["span.http.status_code"]} && temperature=\${__data.fields["temperature"]}} | by(resource.service.name)",
|
||||
"queryType": "traceql",
|
||||
},
|
||||
},
|
||||
@ -83,7 +83,7 @@ describe('MetricsSummary', () => {
|
||||
"datasourceName": "tempo",
|
||||
"datasourceUid": "gdev-tempo",
|
||||
"query": {
|
||||
"query": "{name="HTTP POST - post" && span.http.status_code=\${__data.fields["span.http.status_code"]} && temperature=\${__data.fields["temperature"]} && kind=server} | by(resource.service.name)",
|
||||
"query": "{name="HTTP POST - post" && span.http.status_code=\${__data.fields["span.http.status_code"]} && temperature=\${__data.fields["temperature"]}} | by(resource.service.name)",
|
||||
"queryType": "traceql",
|
||||
},
|
||||
},
|
||||
@ -99,19 +99,6 @@ describe('MetricsSummary', () => {
|
||||
38.1,
|
||||
],
|
||||
},
|
||||
{
|
||||
"config": {
|
||||
"custom": {
|
||||
"width": 150,
|
||||
},
|
||||
"displayNameFromDS": "Kind",
|
||||
},
|
||||
"name": "kind",
|
||||
"type": "string",
|
||||
"values": [
|
||||
"server",
|
||||
],
|
||||
},
|
||||
{
|
||||
"config": {
|
||||
"custom": {
|
||||
@ -222,7 +209,6 @@ describe('MetricsSummary', () => {
|
||||
{
|
||||
"contains_sink": "true",
|
||||
"errorPercentage": 10,
|
||||
"kind": "server",
|
||||
"p50": 1,
|
||||
"p90": 2,
|
||||
"p95": 3,
|
||||
@ -241,21 +227,21 @@ describe('MetricsSummary', () => {
|
||||
it('getConfigQuery should return correctly for empty target query', () => {
|
||||
const result = getConfigQuery(series, '{}');
|
||||
expect(result).toEqual(
|
||||
'{span.http.status_code=${__data.fields["span.http.status_code"]} && temperature=${__data.fields["temperature"]} && room="${__data.fields["room"]}" && contains_sink="${__data.fields["contains_sink"]}" && window_open="${__data.fields["window_open"]}" && spanStatus=${__data.fields["spanStatus"]} && spanKind=${__data.fields["spanKind"]} && kind=server}'
|
||||
'{span.http.status_code=${__data.fields["span.http.status_code"]} && temperature=${__data.fields["temperature"]} && room="${__data.fields["room"]}" && contains_sink="${__data.fields["contains_sink"]}" && window_open="${__data.fields["window_open"]}" && spanStatus=${__data.fields["spanStatus"]} && spanKind=${__data.fields["spanKind"]}}'
|
||||
);
|
||||
});
|
||||
|
||||
it('getConfigQuery should return correctly for target query', () => {
|
||||
const result = getConfigQuery(series, '{name="HTTP POST - post"} | by(resource.service.name)');
|
||||
expect(result).toEqual(
|
||||
'{name="HTTP POST - post" && span.http.status_code=${__data.fields["span.http.status_code"]} && temperature=${__data.fields["temperature"]} && room="${__data.fields["room"]}" && contains_sink="${__data.fields["contains_sink"]}" && window_open="${__data.fields["window_open"]}" && spanStatus=${__data.fields["spanStatus"]} && spanKind=${__data.fields["spanKind"]} && kind=server} | by(resource.service.name)'
|
||||
'{name="HTTP POST - post" && span.http.status_code=${__data.fields["span.http.status_code"]} && temperature=${__data.fields["temperature"]} && room="${__data.fields["room"]}" && contains_sink="${__data.fields["contains_sink"]}" && window_open="${__data.fields["window_open"]}" && spanStatus=${__data.fields["spanStatus"]} && spanKind=${__data.fields["spanKind"]}} | by(resource.service.name)'
|
||||
);
|
||||
});
|
||||
|
||||
it('getConfigQuery should return correctly for target query without brackets', () => {
|
||||
const result = getConfigQuery(series, 'by(resource.service.name)');
|
||||
expect(result).toEqual(
|
||||
'{span.http.status_code=${__data.fields["span.http.status_code"]} && temperature=${__data.fields["temperature"]} && room="${__data.fields["room"]}" && contains_sink="${__data.fields["contains_sink"]}" && window_open="${__data.fields["window_open"]}" && spanStatus=${__data.fields["spanStatus"]} && spanKind=${__data.fields["spanKind"]} && kind=server} | by(resource.service.name)'
|
||||
'{span.http.status_code=${__data.fields["span.http.status_code"]} && temperature=${__data.fields["temperature"]} && room="${__data.fields["room"]}" && contains_sink="${__data.fields["contains_sink"]}" && window_open="${__data.fields["window_open"]}" && spanStatus=${__data.fields["spanStatus"]} && spanKind=${__data.fields["spanKind"]}} | by(resource.service.name)'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -70,11 +70,6 @@ export function createTableFrameFromMetricsSummaryQuery(
|
||||
refId: 'metrics-summary',
|
||||
fields: [
|
||||
...Object.values(dynamicMetrics).sort((a, b) => a.name.localeCompare(b.name)),
|
||||
{
|
||||
name: 'kind',
|
||||
type: FieldType.string,
|
||||
config: { displayNameFromDS: 'Kind', custom: { width: 150 } },
|
||||
},
|
||||
{
|
||||
name: 'spanCount',
|
||||
type: FieldType.number,
|
||||
@ -113,7 +108,6 @@ export const transformToMetricsData = (data: MetricsSummary) => {
|
||||
: '0%';
|
||||
|
||||
const metricsData: MetricsData = {
|
||||
kind: 'server', // so the user knows all results are of kind = server
|
||||
spanCount: getNumberForMetric(data.spanCount),
|
||||
errorPercentage,
|
||||
p50: getNumberForMetric(data.p50),
|
||||
@ -145,12 +139,12 @@ export const getConfigQuery = (series: Series[], targetQuery: string) => {
|
||||
configQuery = targetQuery.substring(0, closingBracketIndex);
|
||||
if (queryParts.length > 0) {
|
||||
configQuery += targetQuery.replace(/\s/g, '').includes('{}') ? '' : ' && ';
|
||||
configQuery += `${queryParts.join(' && ')} && kind=server`;
|
||||
configQuery += `${queryParts.join(' && ')}`;
|
||||
configQuery += `}`;
|
||||
}
|
||||
configQuery += `${queryAfterClosingBracket}`;
|
||||
} else {
|
||||
configQuery = `{${queryParts.join(' && ')} && kind=server} | ${targetQuery}`;
|
||||
configQuery = `{${queryParts.join(' && ')}} | ${targetQuery}`;
|
||||
}
|
||||
|
||||
return configQuery;
|
||||
|
Loading…
Reference in New Issue
Block a user