Skip to content

Commit

Permalink
Merge pull request #99816 from cockroachdb/blathers/backport-release-…
Browse files Browse the repository at this point in the history
…23.1-99712

release-23.1: ui: connect metrics provider to metrics timescale object
  • Loading branch information
dhartunian committed Mar 29, 2023
2 parents b15bd6f + f99bf9d commit 4f301fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions pkg/ui/workspaces/db-console/src/redux/timeScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ export const selectTimeScale = createSelector(
timeScaleState => timeScaleState.scale,
);

export const selectMetricsTime = (state: AdminUIState) =>
state.timeScale.metricsTime;

export type AdjustTimeScaleReturnType = {
timeScale: TimeScale;
adjustmentReason?: "low_resolution_period" | "deleted_data_period";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
requestMetrics as requestMetricsAction,
} from "src/redux/metrics";
import { AdminUIState } from "src/redux/state";
import { toDateRange, util } from "@cockroachlabs/cluster-ui";
import { util } from "@cockroachlabs/cluster-ui";
import { findChildrenOfType } from "src/util/find";
import {
Metric,
Expand All @@ -37,7 +37,7 @@ import {
} from "@cockroachlabs/cluster-ui";
import { History } from "history";
import { refreshSettings } from "src/redux/apiReducers";
import { selectTimeScale, adjustTimeScale } from "src/redux/timeScale";
import { adjustTimeScale, selectMetricsTime } from "src/redux/timeScale";
import {
selectResolution10sStorageTTL,
selectResolution30mStorageTTL,
Expand Down Expand Up @@ -255,12 +255,12 @@ class MetricsDataProvider extends React.Component<
const timeInfoSelector = createSelector(
selectResolution10sStorageTTL,
selectResolution30mStorageTTL,
selectTimeScale,
(sTTL, mTTL, scale) => {
if (!_.isObject(scale)) {
selectMetricsTime,
(sTTL, mTTL, metricsTime) => {
if (!_.isObject(metricsTime.currentWindow)) {
return null;
}
const [startMoment, endMoment] = toDateRange(scale);
const { start: startMoment, end: endMoment } = metricsTime.currentWindow;
const start = startMoment.valueOf();
const end = endMoment.valueOf();
const syncedScale = findClosestTimeScale(
Expand Down

0 comments on commit 4f301fe

Please sign in to comment.