Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 152 additions & 44 deletions src/components/RecentActivity/LiveView/LiveView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,158 @@ export const WithData: Story = {
}
};

export const WithLowLatencyData: Story = {
args: {
data: {
liveDataRecords: [
{
duration: {
value: 0.13508,
unit: "ms",
raw: 135084
},
dateTime: "2023-06-30T10:30:18.9634654Z"
}
],
durationData: {
percentiles: [
{
percentile: 0.5,
currentDuration: {
value: 0.13508,
unit: "ms",
raw: 135084
},
previousDuration: null,
changeVerified: null
},
{
percentile: 0.95,
currentDuration: {
value: 0.13508,
unit: "ms",
raw: 135084
},
previousDuration: null,
changeVerified: null
}
],
codeObjectId:
"method:org.springframework.samples.petclinic.sample.SampleInsightsController$_$method1",
displayName: "SampleInsightsController.method1"
}
}
}
};

export const WithDataOutsideOfTheArea: Story = {
args: {
data: {
liveDataRecords: [
{
duration: {
value: 1.92,
unit: "ms",
raw: 1921300
},
dateTime: "2023-07-04T13:52:49.3801706Z"
},
{
duration: {
value: 2.16,
unit: "ms",
raw: 2158300
},
dateTime: "2023-07-04T13:52:59.9520074Z"
},
{
duration: {
value: 5.33,
unit: "ms",
raw: 5333600
},
dateTime: "2023-07-04T13:53:04.5185513Z"
},
{
duration: {
value: 5.86,
unit: "ms",
raw: 5855900
},
dateTime: "2023-07-04T13:53:14.8785927Z"
},
{
duration: {
value: 5.24,
unit: "ms",
raw: 5238100
},
dateTime: "2023-07-04T13:53:25.2289013Z"
},
{
duration: {
value: 7.34,
unit: "ms",
raw: 7343000
},
dateTime: "2023-07-04T13:53:35.6438918Z"
},
{
duration: {
value: 190.23,
unit: "ms",
raw: 190230600
},
dateTime: "2023-07-04T13:54:05.783907Z"
},
{
duration: {
value: 2.15,
unit: "ms",
raw: 2147000
},
dateTime: "2023-07-04T13:54:34.390596Z"
}
],
durationData: {
percentiles: [
{
percentile: 0.5,
currentDuration: {
value: 247.68,
unit: "ms",
raw: 247684600
},
previousDuration: {
value: 685.83,
unit: "ms",
raw: 685825500
},
changeVerified: false
},
{
percentile: 0.95,
currentDuration: {
value: 6.28,
unit: "sec",
raw: 6284576400
},
previousDuration: {
value: 7.25,
unit: "sec",
raw: 7247733745
},
changeVerified: true
}
],
codeObjectId:
"method:Digma.PluginBackend.Controllers.CodeAnalyticsController$_$GetInsightsOfMethods(InsightOfMethodsRequest)",
displayName: "HTTP POST CodeAnalytics/codeObjects/insights_of_methods"
}
}
}
};

export const WithSlowdown: Story = {
args: {
data: {
Expand Down Expand Up @@ -119,47 +271,3 @@ export const WithEvaluating: Story = {
}
}
};

export const WithLowLatencyData: Story = {
args: {
data: {
liveDataRecords: [
{
duration: {
value: 0.13508,
unit: "ms",
raw: 135084
},
dateTime: "2023-06-30T10:30:18.9634654Z"
}
],
durationData: {
percentiles: [
{
percentile: 0.5,
currentDuration: {
value: 0.13508,
unit: "ms",
raw: 135084
},
previousDuration: null,
changeVerified: null
},
{
percentile: 0.95,
currentDuration: {
value: 0.13508,
unit: "ms",
raw: 135084
},
previousDuration: null,
changeVerified: null
}
],
codeObjectId:
"method:org.springframework.samples.petclinic.sample.SampleInsightsController$_$method1",
displayName: "SampleInsightsController.method1"
}
}
}
};
28 changes: 25 additions & 3 deletions src/components/RecentActivity/LiveView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const convertTo = (nanoseconds: number, unit: string) => {
}
};

const getMaxDuration = (
const getMaxDurationRecord = (
records: ExtendedLiveDataRecord[]
): ExtendedLiveDataRecord | undefined =>
records.reduce(
Expand Down Expand Up @@ -319,7 +319,29 @@ export const LiveView = (props: LiveViewProps) => {
})
);

const maxDuration = getMaxDuration(data)?.duration;
// Add P50 and P95 values to build the correct scale for Y axis
const YAxisData = data.concat([
...(p50
? [
{
dateTime: new Date(0).toISOString(),
duration: p50?.duration,
dateTimeValue: 0
}
]
: []),
...(p95
? [
{
dateTime: new Date(0).toISOString(),
duration: p95?.duration,
dateTimeValue: 0
}
]
: [])
]);

const maxDuration = getMaxDurationRecord(YAxisData)?.duration;
const maxDurationUnit = maxDuration?.unit || "ns";
const YAxisTickInterval = roundToNonZeroDecimals(
convertTo(maxDuration?.raw || 0 / Y_AXIS_TICK_COUNT, maxDurationUnit),
Expand Down Expand Up @@ -419,7 +441,7 @@ export const LiveView = (props: LiveViewProps) => {
>
<ResponsiveContainer width={"100%"} height={"100%"}>
<ComposedChart
data={data}
data={YAxisData}
margin={{
bottom: 34
}}
Expand Down