Skip to content

Commit

Permalink
Pass match strings to LabelNames API
Browse files Browse the repository at this point in the history
This will then only select label names for the correct profileType and label matchers
  • Loading branch information
metalmatze committed Sep 17, 2024
1 parent bc3b5dc commit 62d76fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/parcacol/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ func (q *Querier) Labels(
filterExpr := []logicalplan.Expr{}

if profileType != "" {
_, selectorExprs, err := QueryToFilterExprs(profileType + "{}")
matchers := strings.Join(match, ",")
_, selectorExprs, err := QueryToFilterExprs(profileType + "{" + matchers + "}")
if err != nil {
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions ui/packages/shared/profile/src/MatchersInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ export const useLabelNames = (
client: QueryServiceClient,
profileType: string,
start?: number,
end?: number
end?: number,
match?: string[],
): UseLabelNames => {
const metadata = useGrpcMetadata();

const {data, isLoading, error} = useGrpcQuery<LabelsResponse>({
key: ['labelNames', profileType],
key: ['labelNames', profileType, match?.join(',')],
queryFn: async () => {
const request: LabelsRequest = {match: []};
const request: LabelsRequest = {match: match !== undefined ? match : []};
if (start !== undefined && end !== undefined) {
request.start = millisToProtoTimestamp(start);
request.end = millisToProtoTimestamp(end);
Expand Down
10 changes: 8 additions & 2 deletions ui/packages/shared/profile/src/ProfileViewWithData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {saveAsBlob} from '@parca/utilities';

import {useLabelNames} from './MatchersInput';
import {FIELD_FUNCTION_NAME} from './ProfileIcicleGraph/IcicleGraphArrow';
import {ProfileSource} from './ProfileSource';
import {MergedProfileSource, ProfileSource} from './ProfileSource';
import {ProfileView} from './ProfileView';
import {useQuery} from './useQuery';
import {downloadPprof} from './utils';
Expand Down Expand Up @@ -77,9 +77,15 @@ export const ProfileViewWithData = ({
binaryFrameFilter,
});

const mergedProfileSource = profileSource as MergedProfileSource;
const matchers = mergedProfileSource.query.matchers.map(m => `${m.key}${m.matcherType}"${m.value}"`);

const {result: profileLabelsResponse} = useLabelNames(
queryClient,
profileSource.ProfileType().toString()
profileSource.ProfileType().toString(),
undefined,
undefined,
matchers,
);

const {isLoading: profilemetadataLoading, response: profilemetadataResponse} = useQuery(
Expand Down

0 comments on commit 62d76fa

Please sign in to comment.