Merge pull request #48 from SigNoz/time-fixes-on-trace

Timestamp related fixes on trace
This commit is contained in:
Ankit Nayan 2021-04-30 22:55:08 +05:30 committed by GitHub
commit f32ece7788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 18 deletions

View File

@ -38,14 +38,14 @@ const _ServiceMetrics = (props: ServicesMetricsProps) => {
}, [props.globalTime, servicename]); }, [props.globalTime, servicename]);
const onTracePopupClick = (timestamp: number) => { const onTracePopupClick = (timestamp: number) => {
const tMinus15Min = timestamp / 1000000 - 15 * 60 * 1000;
const currentTime = timestamp / 1000000; const currentTime = timestamp / 1000000;
const tPlusOne = timestamp / 1000000 + 1 * 60 * 1000;
props.updateTimeInterval("custom", [tMinus15Min, currentTime]); // updateTimeInterval takes second range in ms -- give -5 min to selected time, props.updateTimeInterval("custom", [currentTime, tPlusOne]); // updateTimeInterval takes second range in ms -- give -5 min to selected time,
const urlParams = new URLSearchParams(); const urlParams = new URLSearchParams();
urlParams.set(METRICS_PAGE_QUERY_PARAM.startTime, tMinus15Min.toString()); urlParams.set(METRICS_PAGE_QUERY_PARAM.startTime, currentTime.toString());
urlParams.set(METRICS_PAGE_QUERY_PARAM.endTime, currentTime.toString()); urlParams.set(METRICS_PAGE_QUERY_PARAM.endTime, tPlusOne.toString());
if (servicename) { if (servicename) {
urlParams.set(METRICS_PAGE_QUERY_PARAM.service, servicename); urlParams.set(METRICS_PAGE_QUERY_PARAM.service, servicename);
} }

View File

@ -1,10 +1,17 @@
import React from "react"; import React from "react";
import { Card, Tag } from "antd"; import { Card, Tag as AntTag } from "antd";
import { connect } from "react-redux"; import { connect } from "react-redux";
import styled from "styled-components";
import { StoreState } from "../../reducers"; import { StoreState } from "../../reducers";
import { TagItem, TraceFilters, updateTraceFilters } from "../../actions"; import { TagItem, TraceFilters, updateTraceFilters } from "../../actions";
const Tag = styled(AntTag)`
.anticon {
position: relative;
top: -3px;
}
`;
interface FilterStateDisplayProps { interface FilterStateDisplayProps {
traceFilters: TraceFilters; traceFilters: TraceFilters;
updateTraceFilters: Function; updateTraceFilters: Function;

View File

@ -151,7 +151,6 @@ const _TraceCustomVisualizations = (props: TraceCustomVisualizationsProps) => {
<Card> <Card>
{/* <Space direction="vertical"> */} {/* <Space direction="vertical"> */}
<div>Custom Visualizations</div> <div>Custom Visualizations</div>
<Form <Form
form={form} form={form}
onFinish={handleFinish} onFinish={handleFinish}

View File

@ -46,14 +46,14 @@ const _TraceFilter = (props: TraceFilterProps) => {
const location = useLocation(); const location = useLocation();
const urlParams = new URLSearchParams(location.search.split("?")[1]); const urlParams = new URLSearchParams(location.search.split("?")[1]);
useEffect(()=>{ useEffect(() => {
handleApplyFilterForm({ handleApplyFilterForm({
service: "", service: "",
tags: [], tags: [],
operation: "", operation: "",
latency: { min: "", max: "" }, latency: { min: "", max: "" },
}) });
},[]) }, []);
useEffect(() => { useEffect(() => {
metricsAPI metricsAPI
@ -287,21 +287,21 @@ const _TraceFilter = (props: TraceFilterProps) => {
operation: values.operation, operation: values.operation,
latency: { latency: {
max: "", max: "",
min: "" min: "",
}, },
}); });
}; };
useEffect(()=>{ useEffect(() => {
return ()=>{ return () => {
props.updateTraceFilters({ props.updateTraceFilters({
service: "", service: "",
operation: "", operation: "",
tags: [], tags: [],
latency: { min: "", max: "" }, latency: { min: "", max: "" },
}); });
} };
},[]) }, []);
return ( return (
<div> <div>

View File

@ -6,7 +6,12 @@ import { Space, Table } from "antd";
import { traceResponseNew, fetchTraces, pushDStree } from "../../actions"; import { traceResponseNew, fetchTraces, pushDStree } from "../../actions";
import { StoreState } from "../../reducers"; import { StoreState } from "../../reducers";
import { isOnboardingSkipped } from "../../utils/app"; import { isOnboardingSkipped } from "../../utils/app";
import moment from "moment";
import styled from "styled-components";
const TraceHeader = styled.div`
margin: 16px 0;
`;
interface TraceListProps { interface TraceListProps {
traces: traceResponseNew; traces: traceResponseNew;
fetchTraces: Function; fetchTraces: Function;
@ -41,12 +46,12 @@ const _TraceList = (props: TraceListProps) => {
const columns: any = [ const columns: any = [
{ {
title: "Start Time (UTC Time)", title: "Start Time",
dataIndex: "startTime", dataIndex: "startTime",
key: "startTime", key: "startTime",
sorter: (a: any, b: any) => a.startTime - b.startTime, sorter: (a: any, b: any) => a.startTime - b.startTime,
sortDirections: ["descend", "ascend"], sortDirections: ["descend", "ascend"],
render: (value: number) => new Date(Math.round(value)).toUTCString(), render: (value: number) => moment(value).format("YYYY-MM-DD hh:mm:ss"),
// new Date() assumes input in milliseconds. Start Time stamp returned by druid api for span list is in ms // new Date() assumes input in milliseconds. Start Time stamp returned by druid api for span list is in ms
}, },
@ -130,7 +135,7 @@ const _TraceList = (props: TraceListProps) => {
return ( return (
<div> <div>
<div>List of traces with spanID</div> <TraceHeader>List of traces with spanID</TraceHeader>
<div>{renderTraces()}</div> <div>{renderTraces()}</div>
</div> </div>
); );

View File

@ -10,6 +10,8 @@ module.exports = {
historyApiFallback: true, historyApiFallback: true,
publicPath: "/", publicPath: "/",
transportMode: "ws", transportMode: "ws",
open: true,
openPage: "application",
contentBase: [resolve(__dirname, "./public")], contentBase: [resolve(__dirname, "./public")],
hot: true, hot: true,
liveReload: false, liveReload: false,