SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
chore: remove last min trim logic in uplotScaleBuilder (#12627)
Gaurav Tewari4d69e3f9e529
diff --git a/frontend/src/lib/uPlotV2/config/UPlotScaleBuilder.ts b/frontend/src/lib/uPlotV2/config/UPlotScaleBuilder.tsindex 5c064623fd..0eaf79b1f9 100644--- a/frontend/src/lib/uPlotV2/config/UPlotScaleBuilder.ts+++ b/frontend/src/lib/uPlotV2/config/UPlotScaleBuilder.ts@@ -56,17 +56,6 @@ export class UPlotScaleBuilder extends ConfigBuilder<maxTime = fallbackMax;}- // Align max time to "endTime - 1 minute", rounded down to minute precision- // This matches legacy getXAxisScale behavior and avoids empty space at the right edge- const oneMinuteAgoTimestamp = (maxTime - 60) * 1000;- const currentDate = new Date(oneMinuteAgoTimestamp);-- currentDate.setSeconds(0);- currentDate.setMilliseconds(0);-- const unixTimestampSeconds = Math.floor(currentDate.getTime() / 1000);- maxTime = unixTimestampSeconds;-return {[scaleKey]: {time: true,diff --git a/frontend/src/lib/uPlotV2/config/__tests__/UPlotScaleBuilder.test.ts b/frontend/src/lib/uPlotV2/config/__tests__/UPlotScaleBuilder.test.tsindex c24d69c655..53059cbf52 100644--- a/frontend/src/lib/uPlotV2/config/__tests__/UPlotScaleBuilder.test.ts+++ b/frontend/src/lib/uPlotV2/config/__tests__/UPlotScaleBuilder.test.ts@@ -44,7 +44,7 @@ describe('UPlotScaleBuilder', () => {expect(adjustSpy).toHaveBeenCalledWith(null, null, undefined, undefined);});- it('handles time scales using explicit min/max and rounds max down to the previous minute', () => {+ it('handles time scales using explicit min/max', () => {const min = 1_700_000_000; // secondsconst max = 1_700_000_600; // seconds@@ -62,21 +62,25 @@ describe('UPlotScaleBuilder', () => {expect(xScale.time).toBe(true);expect(xScale.auto).toBe(false);- expect(Array.isArray(xScale.range)).toBe(true);+ expect(xScale.range).toStrictEqual([min, max]);+ });- const [resolvedMin, resolvedMax] = xScale.range as [number, number];+ it('keeps short time windows intact', () => {+ const min = 1_786_527_160;+ const max = 1_786_527_183;- // min is passed through- expect(resolvedMin).toBe(min);+ const builder = new UPlotScaleBuilder(+ createScaleProps({+ scaleKey: 'x',+ time: true,+ min,+ max,+ }),+ );- // max is coerced to "endTime - 1 minute" and rounded down to minute precision- const oneMinuteAgoTimestamp = (max - 60) * 1000;- const currentDate = new Date(oneMinuteAgoTimestamp);- currentDate.setSeconds(0);- currentDate.setMilliseconds(0);- const expectedMax = Math.floor(currentDate.getTime() / 1000);+ const config = builder.getConfig();- expect(resolvedMax).toBe(expectedMax);+ expect(config.x.range).toStrictEqual([min, max]);});it('falls back to getFallbackMinMaxTimeStamp when time scale has no min/max', () => {@@ -99,9 +103,7 @@ describe('UPlotScaleBuilder', () => {expect(getFallbackMinMaxSpy).toHaveBeenCalled();expect(resolvedMin).toBe(100);- // max is aligned to "fallbackMax - 60 seconds" minute boundary- expect(resolvedMax).toBeLessThanOrEqual(200);- expect(resolvedMax).toBeGreaterThan(100);+ expect(resolvedMax).toBe(200);});it('pipes limits through soft-limit adjustment and log-scale normalization before range config', () => {