// Copyright 2022 The Parca Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. import React from 'react'; import {Icon} from '@iconify/react'; import {Table} from '@uwdata/flechette'; import {useParcaContext} from '@parca/components'; import {ProfileType} from '@parca/parser'; import {formatDateTimeDownToMS, getLastItem} from '@parca/utilities'; import {getLabelPairs} from '../ProfileFlameGraph/FlameGraphArrow/utils'; import {hexifyAddress, truncateString, truncateStringReverse} from '../utils'; import {ExpandOnHover} from './ExpandOnHoverValue'; import {gpuFrameInfosFromLabels, type GpuFrameInfo} from './gpuFrameDescriptions'; import {openInNewTab} from './openInNewTab'; import {useGraphTooltip} from './useGraphTooltip'; import {useGraphTooltipMetaInfo} from './useGraphTooltipMetaInfo'; interface GraphTooltipArrowContentProps { table: Table; profileType?: ProfileType; unit?: string; total: bigint; totalUnfiltered: bigint; row: number | null; isFixed: boolean; compareAbsolute: boolean; frozen?: boolean; } const NoData = (): React.JSX.Element => { return Not available; }; const GraphTooltipArrowContent = ({ table, profileType, unit, total, totalUnfiltered, row, isFixed, compareAbsolute, frozen = false, }: GraphTooltipArrowContentProps): React.JSX.Element => { const graphTooltipData = useGraphTooltip({ table, profileType, unit, total, totalUnfiltered, row, compareAbsolute, }); if (graphTooltipData === null) { return <>>; } const { name, locationAddress, cumulativeText, flatText, diffText, diff, row: rowNumber, } = graphTooltipData; const gpuInfos = gpuFrameInfosFromLabels(getLabelPairs(table, rowNumber)); // Outer card gains a subtle ring when frozen, matching the design's // `.is-frozen` treatment. const cardClassName = [ 'flex w-auto max-w-[600px] min-w-[300px] flex-col justify-start rounded-lg border bg-gray-50 p-3 shadow-lg dark:bg-gray-900', frozen ? 'border-indigo-400/60 ring-2 ring-indigo-400/20 dark:border-indigo-400/40' : 'border-gray-300 dark:border-gray-500', ].join(' '); return (
root
) : ({name !== '' ? name : locationAddress !== 0n ? hexifyAddress(locationAddress) : 'unknown'}
)}| Cumulative |
{cumulativeText} |
| Flat |
{flatText} |
| Diff |
{diffText} |
{description}