Skip to content

Commit

Permalink
Limits to required labels when querying for App (grafana/phlare#856)
Browse files Browse the repository at this point in the history
* Limits to required labels when querying for App

* yarn format

* Add back missing labels

* support old version
  • Loading branch information
cyriltovena authored Jul 13, 2023
1 parent 512de4f commit 68383b1
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions public/app/overrides/services/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ function removeDuplicateApps(app: App[]) {
export async function fetchApps(): Promise<
Result<App[], RequestError | ZodError>
> {
// TODO: is this the best query?
const response = await requestWithOrgID('/querier.v1.QuerierService/Series', {
let response = await requestWithOrgID('/querier.v1.QuerierService/Series', {
method: 'POST',
body: JSON.stringify({
matchers: [],
labelNames: [
PyroscopeAppLabel,
ServiceNameLabel,
'__profile_type__',
'__type__',
'__name__',
],
}),
headers: {
'content-type': 'application/json',
Expand All @@ -95,5 +101,19 @@ export async function fetchApps(): Promise<
return parseResponse(response, ListOfAppsSchema);
}

// try without labelNames in case of an error since this has been added in a later version
response = await requestWithOrgID('/querier.v1.QuerierService/Series', {
method: 'POST',
body: JSON.stringify({
matchers: [],
}),
headers: {
'content-type': 'application/json',
},
});
if (response.isOk) {
return parseResponse(response, ListOfAppsSchema);
}

return Result.err<App[], RequestError>(response.error);
}

0 comments on commit 68383b1

Please sign in to comment.