Skip to content

Commit

Permalink
fix: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sumimakito committed Dec 3, 2024
1 parent a27493f commit 3f286a8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
10 changes: 4 additions & 6 deletions packages/core/tracing/sandbox/pages/TraceViewerPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@close="slideoutVisible = false"
>
<template #title>
<template v-if="skeleton">
<template v-if="showSkeleton">
<KSkeletonBox
height="2"
width="50"
Expand All @@ -39,7 +39,7 @@
<TraceViewer
:config="config"
:root-span="spanRoots[0]"
:skeleton="skeleton"
:show-skeleton="showSkeleton"
:url="url"
/>
</KSlideout>
Expand All @@ -49,7 +49,7 @@
title="Controls"
>
<KInputSwitch
v-model="skeleton"
v-model="showSkeleton"
label="Skeleton"
/>
</KCard>
Expand All @@ -65,7 +65,7 @@ const controlPlaneId = import.meta.env.VITE_KONNECT_CONTROL_PLANE_ID || ''
const spanRoots = computed(() => buildSpanTrees(rawSpans))
// const spanRoots = computed(() => buildSpanTrees(mergeSpansInTraceBatches(traceBatches)))
const skeleton = ref(false)
const showSkeleton = ref(false)
const slideoutVisible = ref(false)
const config: TraceViewerConfig = {
Expand Down Expand Up @@ -117,9 +117,7 @@ const url = `https://example.com${path}`
}
}
}
</style>
<style lang="scss" scoped>
.controls {
z-index: 10000;
bottom: 16px;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/tracing/sandbox/pages/WaterfallPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
title="Controls"
>
<KInputSwitch
v-model="skeleton"
v-model="showSkeleton"
label="Skeleton"
/>
</KCard>
Expand All @@ -13,7 +13,7 @@
v-for="(root, i) in spanRoots"
:key="i"
:root-span="root"
:skeleton="skeleton"
:show-skeleton="showSkeleton"
/>
</template>

Expand All @@ -22,7 +22,7 @@ import { computed, ref } from 'vue'
import { buildSpanTrees, WaterfallView } from '../../src'
import rawSpans from '../fixtures/spans.json'
const skeleton = ref(false)
const showSkeleton = ref(false)
const spanRoots = computed(() => buildSpanTrees(rawSpans))
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
min-size="20"
>
<div class="above-waterfall">
<template v-if="skeleton">
<template v-if="showSkeleton">
<KSkeletonBox
height="2"
width="25"
Expand Down Expand Up @@ -43,7 +43,7 @@
<div class="waterfall-wrapper">
<WaterfallView
:root-span="props.rootSpan"
:skeleton="props.skeleton"
:show-skeleton="props.showSkeleton"
@update:selected-span="handleUpdateSelectedSpan"
/>
</div>
Expand All @@ -53,7 +53,7 @@
class="detail-pane"
size="50"
>
<template v-if="skeleton">
<template v-if="showSkeleton">
<KSkeleton
:table-columns="2"
:table-rows="8"
Expand Down Expand Up @@ -107,7 +107,7 @@ const props = defineProps<{
config: TraceViewerConfig
rootSpan?: SpanNode
url?: string
skeleton?: boolean
showSkeleton?: boolean
}>()
// Provide the config to all children components
Expand Down
22 changes: 8 additions & 14 deletions packages/core/tracing/src/components/waterfall/WaterfallView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div
v-if="skeleton"
v-if="showSkeleton"
class="waterfall-skeleton"
>
<KSkeleton
Expand Down Expand Up @@ -87,11 +87,11 @@
// RESERVED: Only used when zooming is enabled
// import { useWheel } from '@vueuse/gesture'
import { AddIcon, RemoveIcon } from '@kong/icons'
import { provide, reactive, ref, useTemplateRef, watch, type PropType, type Ref } from 'vue'
import { computed, provide, reactive, ref, toRef, useTemplateRef, watch, type PropType, type Ref } from 'vue'
import composables from '../../composables'
import { WATERFALL_ROW_COLUMN_GAP, WATERFALL_ROW_LABEL_WIDTH, WATERFALL_ROW_PADDING_X, WATERFALL_SPAN_BAR_FADING_WIDTH } from '../../constants'
import { WATERFALL_CONFIG, WATERFALL_ROWS_STATE, WaterfallRowsState } from '../../constants/waterfall'
import { type SpanNode, type WaterfallConfig } from '../../types'
import { type MarkReactiveInputRefs, type SpanNode, type WaterfallConfig } from '../../types'
import WaterfallScale from './WaterfallScale.vue'
import WaterfallSpanRow from './WaterfallSpanRow.vue'
Expand All @@ -107,7 +107,7 @@ const props = defineProps({
type: Object as PropType<SpanNode>,
default: () => undefined,
},
skeleton: {
showSkeleton: {
type: Boolean,
default: false,
},
Expand All @@ -124,10 +124,10 @@ const spanBarMeasurementRef = useTemplateRef<HTMLElement>('spanBarMeasurement')
const interaction = ref<'scroll' | 'zoom'>('scroll')
const rowsAreaGuideX = ref<number | undefined>(undefined)
const config = reactive<WaterfallConfig>({
ticks: props.ticks,
totalDurationNano: props.rootSpan?.durationNano ?? 0,
startTimeUnixNano: props.rootSpan ? BigInt(props.rootSpan.span.startTimeUnixNano) : 0n,
const config = reactive<MarkReactiveInputRefs<WaterfallConfig, 'ticks' | 'totalDurationNano' | 'startTimeUnixNano'>>({
ticks: toRef(props, 'ticks'), // This will be unwrapped
totalDurationNano: computed(() => props.rootSpan?.durationNano ?? 0), // This will be unwrapped
startTimeUnixNano: computed(() => props.rootSpan ? BigInt(props.rootSpan.span.startTimeUnixNano) : 0n), // This will be unwrapped
zoom: 1,
viewportShift: 0,
viewport: { left: 0, right: 0 },
Expand Down Expand Up @@ -156,14 +156,8 @@ const handleRowsAreaLeave = () => {
rowsAreaGuideX.value = undefined
}
watch(() => props.ticks, (ticks) => {
config.ticks = ticks
}, { immediate: true })
watch(() => props.rootSpan, (rootSpan) => {
config.selectedSpan = rootSpan
config.totalDurationNano = rootSpan?.durationNano ?? 0,
config.startTimeUnixNano = rootSpan ? BigInt(rootSpan.span.startTimeUnixNano) : 0n
}, { immediate: true })
watch(() => config.selectedSpan, (span) => {
Expand Down
1 change: 1 addition & 0 deletions packages/core/tracing/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export * from './otlp'
export * from './spans'
export * from './trace-viewer'
export * from './trace'
export * from './utils'
export * from './waterfall'
8 changes: 8 additions & 0 deletions packages/core/tracing/src/types/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Ref } from 'vue'

/**
* MarkReactiveInputRefs is a utility type that selectively wraps some properties in U of T with
* `Ref<...>` to make `reactive(...)` accept refs for those properties, without modifying the original
* shape.
*/
export type MarkReactiveInputRefs<T, U extends keyof T> = { [P in U]: Ref<T[P]> } & Omit<T, U>

0 comments on commit 3f286a8

Please sign in to comment.