Skip to content

Commit be43d05

Browse files
committed
StatsHouse UI: update raw tag and add raw_kind int64
1 parent 0bcf2d0 commit be43d05

File tree

8 files changed

+387
-203
lines changed

8 files changed

+387
-203
lines changed

statshouse-ui/src/admin/api/saveMetric.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function saveMetric(metric: IMetric) {
2020
tags: metric.tags.map((tag) => ({
2121
name: tag.name,
2222
description: tag.alias,
23-
raw: tag.isRaw || false,
23+
raw: tag.raw_kind != null,
2424
raw_kind: tag.raw_kind,
2525
value_comments:
2626
tag.customMapping.length > 0

statshouse-ui/src/admin/models/metric.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// License, v. 2.0. If a copy of the MPL was not distributed with this
55
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
66

7-
import { RawValueKind } from '../../view/api';
7+
import { RawValueKind } from '@/view/api';
88

99
export interface IShortMetric {
1010
readonly name: string;
@@ -13,6 +13,9 @@ export interface IShortMetric {
1313
export interface ITag {
1414
readonly name: string;
1515
readonly description?: string;
16+
/**
17+
* @deprecated
18+
*/
1619
readonly raw?: boolean;
1720
readonly raw_kind?: RawValueKind;
1821
readonly value_comments?: Readonly<Record<string, string>>;

statshouse-ui/src/admin/pages/FormPage.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function FormPage(props: { yAxisSize: number; adminMode: boolean }) {
6363
to,
6464
}))
6565
: [],
66-
isRaw: tag.raw,
66+
isRaw: tag.raw || tag.raw_kind != null,
6767
raw_kind: tag.raw_kind,
6868
})),
6969
tags_draft,
@@ -74,6 +74,9 @@ export function FormPage(props: { yAxisSize: number; adminMode: boolean }) {
7474
version: metric.version,
7575
group_id: metric.group_id,
7676
fair_key_tag_ids: metric.fair_key_tag_ids,
77+
skip_max_host: !!metric.skip_max_host,
78+
skip_min_host: !!metric.skip_min_host,
79+
skip_sum_square: !!metric.skip_sum_square,
7780
});
7881
});
7982
}, [metricName]);
@@ -712,7 +715,12 @@ function AliasField(props: {
712715
className="form-check-input"
713716
type="checkbox"
714717
disabled={tagNumber <= 0 || disabled}
715-
onChange={(e) => onChange({ isRaw: e.target.checked })}
718+
onChange={(e) =>
719+
onChange({
720+
isRaw: e.target.checked,
721+
raw_kind: e.target.checked ? (value.raw_kind ?? 'int') : undefined,
722+
})
723+
}
716724
/>
717725
<label className="form-check-label" htmlFor={`roSelect_${tagNumber}`}>
718726
Raw
@@ -722,10 +730,10 @@ function AliasField(props: {
722730
{!!value.isRaw && (
723731
<select
724732
className="form-control form-select"
725-
value={value.raw_kind ?? ''}
726-
onChange={(e) => onChange({raw_kind: e.target.value as RawValueKind})}
733+
value={value.raw_kind ?? 'int'}
734+
onChange={(e) => onChange({ raw_kind: e.target.value as RawValueKind })}
727735
>
728-
<option value="">int</option>
736+
<option value="int">int</option>
729737
<option value="uint">uint</option>
730738
<option value="hex">hex</option>
731739
<option value="hex_bswap">hex_bswap</option>
@@ -736,6 +744,8 @@ function AliasField(props: {
736744
<option value="lexenc_float">lexenc_float</option>
737745
<option value="int64">int64</option>
738746
<option value="uint64">uint64</option>
747+
<option value="hex64">hex64</option>
748+
<option value="hex64_bswap">hex64_bswap</option>
739749
</select>
740750
)}
741751
</div>

statshouse-ui/src/api/metric.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export type MetricMetaValue = {
6060
export type MetricMetaTag = {
6161
name?: string;
6262
description?: string;
63+
/**
64+
* @deprecated
65+
*/
6366
raw?: boolean;
6467
raw_kind?: MetricMetaTagRawKind;
6568
id2value?: Record<number, string>;

statshouse-ui/src/components2/Plot/PlotControl/PlotControlFilterTag.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ export const PlotControlFilterTag = memo(function PlotControlFilterTag({
162162

163163
const customValue = useMemo(
164164
() =>
165-
tagList?.more &&
165+
(!tagList?.list?.length || tagList?.more) &&
166166
((v: string): SelectOptionProps => {
167167
const value = getTagValue(meta, tagKey, v);
168168
const tagMeta = meta?.tags?.[+tagKey];
169169
const name = formatTagValue(value, tagMeta?.value_comments?.[value], tagMeta?.raw, tagMeta?.raw_kind);
170170
return { value, name };
171171
}),
172-
[meta, tagKey, tagList?.more]
172+
[meta, tagKey, tagList?.list?.length, tagList?.more]
173173
);
174174

175175
return (

statshouse-ui/src/view/api.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ export function formatTagValue(value: string, comment?: string, raw?: boolean, k
118118
if (value.length < 1 || value[0] !== ' ') {
119119
return value;
120120
}
121-
if (raw && kind) {
122-
return `⚡ ${convert(kind, parseInt(value))}`;
121+
raw = raw || kind != null; // fix raw deprecated
122+
if (raw || kind != null) {
123+
return `⚡ ${convert(kind, value)}`;
123124
}
124125
const i = parseInt(value.substring(1));
125126
if (i === 0 && !raw) {
@@ -522,9 +523,10 @@ export type metricKind = 'counter' | 'value' | 'value_p' | 'unique' | 'mixed' |
522523
* hex_bswap: same as hex, but do bswap after interpreting number bits as uint32
523524
* timestamp: UNIX timestamp, show as is (in GMT)
524525
* timestamp_local: UNIX timestamp, show local time for this TS
525-
* EMPTY: decimal number, can be negative
526+
* '', EMPTY: default int32 decimal number, can be negative
526527
*/
527528
export type RawValueKind =
529+
| 'int'
528530
| 'uint'
529531
| 'hex'
530532
| 'hex_bswap'
@@ -533,6 +535,10 @@ export type RawValueKind =
533535
| 'ip'
534536
| 'ip_bswap'
535537
| 'lexenc_float'
538+
| 'int64'
539+
| 'uint64'
540+
| 'hex64'
541+
| 'hex64_bswap'
536542
/** @deprecated 'float' raw value kind */
537543
| 'float';
538544

0 commit comments

Comments
 (0)