@parca/profile 0.16.430 → 0.16.431

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.16.431](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.430...@parca/profile@0.16.431) (2024-09-02)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
6
10
  ## [0.16.430](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.428...@parca/profile@0.16.430) (2024-09-02)
7
11
 
8
12
  **Note:** Version bump only for package @parca/profile
@@ -19,6 +19,7 @@ interface Props {
19
19
  width?: number;
20
20
  height?: number;
21
21
  margin?: number;
22
+ sumBy?: string[];
22
23
  }
23
24
  export interface HighlightedSeries {
24
25
  seriesIndex: number;
@@ -30,8 +31,8 @@ export interface HighlightedSeries {
30
31
  x: number;
31
32
  y: number;
32
33
  }
33
- declare const MetricsGraph: ({ data, from, to, profile, onSampleClick, addLabelMatcher, setTimeRange, sampleUnit, width, height, margin, }: Props) => JSX.Element;
34
+ declare const MetricsGraph: ({ data, from, to, profile, onSampleClick, addLabelMatcher, setTimeRange, sampleUnit, width, height, margin, sumBy, }: Props) => JSX.Element;
34
35
  export default MetricsGraph;
35
36
  export declare const parseValue: (value: string) => number | null;
36
- export declare const RawMetricsGraph: ({ data, from, to, profile, onSampleClick, addLabelMatcher, setTimeRange, width, height, margin, sampleUnit, }: Props) => JSX.Element;
37
+ export declare const RawMetricsGraph: ({ data, from, to, profile, onSampleClick, addLabelMatcher, setTimeRange, width, height, margin, sampleUnit, sumBy, }: Props) => JSX.Element;
37
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/MetricsGraph/index.tsx"],"names":[],"mappings":"AAoBA,OAAO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AAK,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAQD,QAAA,MAAM,YAAY,yHAaf,KAAK,KAAG,GAAG,CAAC,OA0Bd,CAAC;AAEF,eAAe,YAAY,CAAC;AAE5B,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAM,GAAG,IAKnD,CAAC;AAKF,eAAO,MAAM,eAAe,yHAazB,KAAK,KAAG,GAAG,CAAC,OA4ed,CAAC"}
@@ -23,9 +23,9 @@ import MetricsSeries from '../MetricsSeries';
23
23
  import MetricsContextMenu from './MetricsContextMenu';
24
24
  import MetricsInfoPanel from './MetricsInfoPanel';
25
25
  import MetricsTooltip from './MetricsTooltip';
26
- const MetricsGraph = ({ data, from, to, profile, onSampleClick, addLabelMatcher, setTimeRange, sampleUnit, width = 0, height = 0, margin = 0, }) => {
26
+ const MetricsGraph = ({ data, from, to, profile, onSampleClick, addLabelMatcher, setTimeRange, sampleUnit, width = 0, height = 0, margin = 0, sumBy, }) => {
27
27
  const [isInfoPanelOpen, setIsInfoPanelOpen] = useState(false);
28
- return (_jsxs("div", { className: "relative", onClick: () => isInfoPanelOpen && setIsInfoPanelOpen(false), children: [_jsx("div", { className: "absolute right-0 top-0", children: _jsx(MetricsInfoPanel, { isInfoPanelOpen: isInfoPanelOpen, onInfoIconClick: () => setIsInfoPanelOpen(true) }) }), _jsx(RawMetricsGraph, { data: data, from: from, to: to, profile: profile, onSampleClick: onSampleClick, addLabelMatcher: addLabelMatcher, setTimeRange: setTimeRange, sampleUnit: sampleUnit, width: width, height: height, margin: margin })] }));
28
+ return (_jsxs("div", { className: "relative", onClick: () => isInfoPanelOpen && setIsInfoPanelOpen(false), children: [_jsx("div", { className: "absolute right-0 top-0", children: _jsx(MetricsInfoPanel, { isInfoPanelOpen: isInfoPanelOpen, onInfoIconClick: () => setIsInfoPanelOpen(true) }) }), _jsx(RawMetricsGraph, { data: data, from: from, to: to, profile: profile, onSampleClick: onSampleClick, addLabelMatcher: addLabelMatcher, setTimeRange: setTimeRange, sampleUnit: sampleUnit, width: width, height: height, margin: margin, sumBy: sumBy })] }));
29
29
  };
30
30
  export default MetricsGraph;
31
31
  export const parseValue = (value) => {
@@ -36,7 +36,7 @@ export const parseValue = (value) => {
36
36
  };
37
37
  const lineStroke = '1px';
38
38
  const lineStrokeHover = '2px';
39
- export const RawMetricsGraph = ({ data, from, to, profile, onSampleClick, addLabelMatcher, setTimeRange, width, height = 50, margin = 0, sampleUnit, }) => {
39
+ export const RawMetricsGraph = ({ data, from, to, profile, onSampleClick, addLabelMatcher, setTimeRange, width, height = 50, margin = 0, sampleUnit, sumBy, }) => {
40
40
  const { timezone } = useParcaContext();
41
41
  const graph = useRef(null);
42
42
  const [dragging, setDragging] = useState(false);
@@ -190,15 +190,24 @@ export const RawMetricsGraph = ({ data, from, to, profile, onSampleClick, addLab
190
190
  }
191
191
  let s = null;
192
192
  let seriesIndex = -1;
193
+ // if there are both query matchers and also a sumby value, we need to check if the sumby value is part of the query matchers.
194
+ // if it is, then we should prioritize using the sumby label name and value to find the selected profile.
195
+ const useSumBy = sumBy !== undefined &&
196
+ sumBy.length > 0 &&
197
+ profile.query.matchers.length > 0 &&
198
+ profile.query.matchers.some(e => sumBy.includes(e.key));
199
+ // get only the sumby keys and values from the profile query matchers
200
+ const sumByMatchers = sumBy !== undefined ? profile.query.matchers.filter(e => sumBy.includes(e.key)) : [];
201
+ const keysToMatch = useSumBy ? sumByMatchers : profile.query.matchers;
193
202
  outer: for (let i = 0; i < series.length; i++) {
194
- const keys = profile.query.matchers.map(e => e.key);
203
+ const keys = keysToMatch.map(e => e.key);
195
204
  for (let j = 0; j < keys.length; j++) {
196
205
  const matcherKey = keys[j];
197
206
  const label = series[i].metric.find(e => e.name === matcherKey);
198
207
  if (label === undefined) {
199
208
  continue outer; // label doesn't exist to begin with
200
209
  }
201
- if (profile.query.matchers[j].value !== label.value) {
210
+ if (keysToMatch[j].value !== label.value) {
202
211
  continue outer; // label values don't match
203
212
  }
204
213
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileMetricsGraph/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAGlD,OAAO,EAAW,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAY,MAAM,eAAe,CAAC;AACjG,OAAO,EACL,aAAa,EAKd,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAyB,gBAAgB,EAAC,MAAM,IAAI,CAAC;AAK5D,UAAU,6BAA6B;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAaD,eAAO,MAAM,wBAAwB,gBAAe,6BAA6B,KAAG,GAAG,CAAC,OAMvF,CAAC;AAEF,UAAU,wBAAwB;IAChC,WAAW,EAAE,kBAAkB,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,eAAe,EAAE,CACf,MAAM,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAAG,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,KACvE,IAAI,CAAC;IACV,YAAY,EAAE,CACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,KAAK,EAAE,EACf,eAAe,EAAE,MAAM,EAC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AAM,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAAG,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,KACvE,IAAI,CAAC;IACV,YAAY,EAAE,CACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,KAAK,EAAE,EACf,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;IACV,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxB;AAYD,eAAO,MAAM,aAAa,WAChB,kBAAkB,mBACT,MAAM,SAChB,MAAM,OACR,MAAM,SACJ,MAAM,EAAE,qBAEd,gBA+CF,CAAC;AAEF,QAAA,MAAM,mBAAmB,sIAYtB,wBAAwB,KAAG,GAAG,CAAC,OAsFjC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -108,6 +108,6 @@ const ProfileMetricsGraph = ({ queryClient, queryExpression, profile, from, to,
108
108
  }
109
109
  return (_jsx(AnimatePresence, { children: _jsx(motion.div, { className: "h-full w-full relative", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: loading ? (_jsx(MetricsGraphSkeleton, { heightStyle: heightStyle, isDarkMode: isDarkMode })) : dataAvailable ? (_jsx(MetricsGraph, { data: series, from: from, to: to, profile: profile, setTimeRange: setTimeRange, onSampleClick: (timestamp, _value, labels, duration) => {
110
110
  onPointClick(timestamp, labels, queryExpression, duration);
111
- }, addLabelMatcher: addLabelMatcher, sampleUnit: sampleUnit, height: height, width: width, margin: margin })) : (_jsx(ProfileMetricsEmptyState, { message: "No data found. Try a different query." })) }, "metrics-graph-loaded") }));
111
+ }, addLabelMatcher: addLabelMatcher, sampleUnit: sampleUnit, height: height, width: width, margin: margin, sumBy: sumBy })) : (_jsx(ProfileMetricsEmptyState, { message: "No data found. Try a different query." })) }, "metrics-graph-loaded") }));
112
112
  };
113
113
  export default ProfileMetricsGraph;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.430",
3
+ "version": "0.16.431",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@headlessui/react": "^1.7.19",
@@ -73,5 +73,5 @@
73
73
  "access": "public",
74
74
  "registry": "https://registry.npmjs.org/"
75
75
  },
76
- "gitHead": "8b447aa4950ab74e48a3f03aa2c3d390567aee85"
76
+ "gitHead": "cbba8df3d109f9dee1245ea4f16ed5ebacdfe6c6"
77
77
  }
@@ -49,6 +49,7 @@ interface Props {
49
49
  width?: number;
50
50
  height?: number;
51
51
  margin?: number;
52
+ sumBy?: string[];
52
53
  }
53
54
 
54
55
  export interface HighlightedSeries {
@@ -80,6 +81,7 @@ const MetricsGraph = ({
80
81
  width = 0,
81
82
  height = 0,
82
83
  margin = 0,
84
+ sumBy,
83
85
  }: Props): JSX.Element => {
84
86
  const [isInfoPanelOpen, setIsInfoPanelOpen] = useState<boolean>(false);
85
87
  return (
@@ -102,6 +104,7 @@ const MetricsGraph = ({
102
104
  width={width}
103
105
  height={height}
104
106
  margin={margin}
107
+ sumBy={sumBy}
105
108
  />
106
109
  </div>
107
110
  );
@@ -131,6 +134,7 @@ export const RawMetricsGraph = ({
131
134
  height = 50,
132
135
  margin = 0,
133
136
  sampleUnit,
137
+ sumBy,
134
138
  }: Props): JSX.Element => {
135
139
  const {timezone} = useParcaContext();
136
140
  const graph = useRef(null);
@@ -331,15 +335,29 @@ export const RawMetricsGraph = ({
331
335
  let s: Series | null = null;
332
336
  let seriesIndex = -1;
333
337
 
338
+ // if there are both query matchers and also a sumby value, we need to check if the sumby value is part of the query matchers.
339
+ // if it is, then we should prioritize using the sumby label name and value to find the selected profile.
340
+ const useSumBy =
341
+ sumBy !== undefined &&
342
+ sumBy.length > 0 &&
343
+ profile.query.matchers.length > 0 &&
344
+ profile.query.matchers.some(e => sumBy.includes(e.key));
345
+
346
+ // get only the sumby keys and values from the profile query matchers
347
+ const sumByMatchers =
348
+ sumBy !== undefined ? profile.query.matchers.filter(e => sumBy.includes(e.key)) : [];
349
+
350
+ const keysToMatch = useSumBy ? sumByMatchers : profile.query.matchers;
351
+
334
352
  outer: for (let i = 0; i < series.length; i++) {
335
- const keys = profile.query.matchers.map(e => e.key);
353
+ const keys = keysToMatch.map(e => e.key);
336
354
  for (let j = 0; j < keys.length; j++) {
337
355
  const matcherKey = keys[j];
338
356
  const label = series[i].metric.find(e => e.name === matcherKey);
339
357
  if (label === undefined) {
340
358
  continue outer; // label doesn't exist to begin with
341
359
  }
342
- if (profile.query.matchers[j].value !== label.value) {
360
+ if (keysToMatch[j].value !== label.value) {
343
361
  continue outer; // label values don't match
344
362
  }
345
363
  }
@@ -238,6 +238,7 @@ const ProfileMetricsGraph = ({
238
238
  height={height}
239
239
  width={width}
240
240
  margin={margin}
241
+ sumBy={sumBy}
241
242
  />
242
243
  ) : (
243
244
  <ProfileMetricsEmptyState message="No data found. Try a different query." />