From ae261f335ee20d57ac64aee0a4b6cd39b78f4a19 Mon Sep 17 00:00:00 2001 From: Ogi <86684834+obostjancic@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:54:43 +0200 Subject: [PATCH 1/2] feat(trace-view): format dollars --- static/app/views/insights/types.tsx | 3 +++ .../details/span/eapSections/attributes.tsx | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/static/app/views/insights/types.tsx b/static/app/views/insights/types.tsx index e5793897408eda..f7347412380d4a 100644 --- a/static/app/views/insights/types.tsx +++ b/static/app/views/insights/types.tsx @@ -96,6 +96,9 @@ export enum SpanFields { GEN_AI_REQUEST_MODEL = 'gen_ai.request.model', GEN_AI_RESPONSE_MODEL = 'gen_ai.response.model', GEN_AI_TOOL_NAME = 'gen_ai.tool.name', + GEN_AI_COST_INPUT_TOKENS = 'gen_ai.cost.input_tokens', + GEN_AI_COST_OUTPUT_TOKENS = 'gen_ai.cost.output_tokens', + GEN_AI_COST_TOTAL_TOKENS = 'gen_ai.cost.total_tokens', GEN_AI_USAGE_INPUT_TOKENS = 'gen_ai.usage.input_tokens', GEN_AI_USAGE_INPUT_TOKENS_CACHED = 'gen_ai.usage.input_tokens.cached', GEN_AI_USAGE_OUTPUT_TOKENS = 'gen_ai.usage.output_tokens', diff --git a/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/attributes.tsx b/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/attributes.tsx index e83d9bfa78727e..c4ff17c0f43ece 100644 --- a/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/attributes.tsx +++ b/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/attributes.tsx @@ -1,4 +1,4 @@ -import {useMemo, useState} from 'react'; +import {Fragment, useMemo, useState} from 'react'; import type {Theme} from '@emotion/react'; import styled from '@emotion/styled'; import type {Location, LocationDescriptorObject} from 'history'; @@ -13,6 +13,7 @@ import type {Project} from 'sentry/types/project'; import {trackAnalytics} from 'sentry/utils/analytics'; import type {RenderFunctionBaggage} from 'sentry/utils/discover/fieldRenderers'; import {FieldKey} from 'sentry/utils/fields'; +import {formatDollars} from 'sentry/utils/formatters'; import {generateProfileFlamechartRoute} from 'sentry/utils/profiling/routes'; import {ellipsize} from 'sentry/utils/string/ellipsize'; import {looksLikeAJSONArray} from 'sentry/utils/string/looksLikeAJSONArray'; @@ -20,6 +21,7 @@ import {looksLikeAJSONObject} from 'sentry/utils/string/looksLikeAJSONObject'; import type {AttributesFieldRendererProps} from 'sentry/views/explore/components/traceItemAttributes/attributesTree'; import {AttributesTree} from 'sentry/views/explore/components/traceItemAttributes/attributesTree'; import type {TraceItemResponseAttribute} from 'sentry/views/explore/hooks/useTraceItemDetails'; +import {SpanFields} from 'sentry/views/insights/types'; import {SectionKey} from 'sentry/views/issueDetails/streamline/context'; import {FoldSection} from 'sentry/views/issueDetails/streamline/foldSection'; import {TraceDrawerComponents} from 'sentry/views/performance/newTraceDetails/traceDrawer/details/styles'; @@ -165,6 +167,18 @@ export function Attributes({ }; return {props.item.value}; }, + [SpanFields.GEN_AI_COST_INPUT_TOKENS]: (props: CustomRenderersProps) => { + return formatDollars(+Number(props.item.value).toFixed(10)); + }, + [SpanFields.GEN_AI_COST_OUTPUT_TOKENS]: (props: CustomRenderersProps) => { + return formatDollars(+Number(props.item.value).toFixed(10)); + }, + [SpanFields.GEN_AI_COST_TOTAL_TOKENS]: (props: CustomRenderersProps) => { + return formatDollars(+Number(props.item.value).toFixed(10)); + }, + [SpanFields.GEN_AI_USAGE_TOTAL_COST]: (props: CustomRenderersProps) => { + return formatDollars(+Number(props.item.value).toFixed(10)); + }, }; // Some attributes (semantic or otherwise) look like they contain JSON-encoded From 19fbec31cca93a8b193730d42b38127d241f7a8b Mon Sep 17 00:00:00 2001 From: Ogi <86684834+obostjancic@users.noreply.github.com> Date: Tue, 14 Oct 2025 11:56:39 +0200 Subject: [PATCH 2/2] fix --- .../traceDrawer/details/span/eapSections/attributes.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/attributes.tsx b/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/attributes.tsx index c4ff17c0f43ece..cab79de36f05e0 100644 --- a/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/attributes.tsx +++ b/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/attributes.tsx @@ -1,4 +1,4 @@ -import {Fragment, useMemo, useState} from 'react'; +import {useMemo, useState} from 'react'; import type {Theme} from '@emotion/react'; import styled from '@emotion/styled'; import type {Location, LocationDescriptorObject} from 'history';