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..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 @@ -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