Skip to content

ref(trace-items): Pull useGetTraceItemAttributeKeys into hook #93739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Zylphrex
Copy link
Member

We'll need the useGetTraceItemAttributeKeys hook in other places so refactoring it so that it can exported.

@Zylphrex Zylphrex requested review from a team as code owners June 17, 2025 18:51
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 17, 2025
Copy link

codecov bot commented Jun 17, 2025

❌ 4 Tests Failed:

Tests completed Failed Passed Skipped
10595 4 10591 9
View the top 3 failed test(s) by shortest run time
EAPField should call onChange with the new aggregate string when switching aggregates
Stack Traces | 0.021s run time
Error: expect(jest.fn()).toHaveBeenCalledWith(...expected)

Expected: ".../org-slug/trace-items/attributes/", ObjectContaining {"query": ObjectContaining {"attributeType": "string"}}
Received: ".../org-slug/trace-items/attributes/", {"error": [Function error], "method": "GET", "query": {"attributeType": "number", "itemType": "spans", "statsPeriod": "14d"}, "success": [Function success]}

Number of calls: 1
    at Object.<anonymous> (.../rules/metric/eapField.spec.tsx:119:24)
    at Promise.then.completed (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/utils.js:231:10)
    at _callCircusTest (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at _runTest (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:121:9)
    at run (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (.../sentry/node_modules/.pnpm/jest-runner@29.7..../jest-runner/build/runTest.js:367:16)
    at runTest (.../sentry/node_modules/.pnpm/jest-runner@29.7..../jest-runner/build/runTest.js:444:34)
    at Object.worker (.../sentry/node_modules/.pnpm/jest-runner@29.7..../jest-runner/build/testWorker.js:106:12)
EAPField renders failure_rate with argument disabled
Stack Traces | 0.023s run time
Error: expect(jest.fn()).toHaveBeenCalledWith(...expected)

Expected: ".../org-slug/trace-items/attributes/", ObjectContaining {"query": ObjectContaining {"attributeType": "string"}}
Received: ".../org-slug/trace-items/attributes/", {"error": [Function error], "method": "GET", "query": {"attributeType": "number", "itemType": "spans", "statsPeriod": "14d"}, "success": [Function success]}

Number of calls: 1
    at Object.<anonymous> (.../rules/metric/eapField.spec.tsx:90:24)
    at Promise.then.completed (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/utils.js:231:10)
    at _callCircusTest (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at _runTest (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:121:9)
    at run (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (.../sentry/node_modules/.pnpm/jest-runner@29.7..../jest-runner/build/runTest.js:367:16)
    at runTest (.../sentry/node_modules/.pnpm/jest-runner@29.7..../jest-runner/build/runTest.js:444:34)
    at Object.worker (.../sentry/node_modules/.pnpm/jest-runner@29.7..../jest-runner/build/testWorker.js:106:12)
EAPField renders epm with argument disabled
Stack Traces | 0.034s run time
Error: expect(jest.fn()).toHaveBeenCalledWith(...expected)

Expected: ".../org-slug/trace-items/attributes/", ObjectContaining {"query": ObjectContaining {"attributeType": "string"}}
Received: ".../org-slug/trace-items/attributes/", {"error": [Function error], "method": "GET", "query": {"attributeType": "number", "itemType": "spans", "statsPeriod": "14d"}, "success": [Function success]}

Number of calls: 1
    at Object.<anonymous> (.../rules/metric/eapField.spec.tsx:62:24)
    at Promise.then.completed (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/utils.js:231:10)
    at _callCircusTest (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at _runTest (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:121:9)
    at run (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (.../sentry/node_modules/.pnpm/jest-circus@29.7.0_babel-plugin-macros@3.1..../build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (.../sentry/node_modules/.pnpm/jest-runner@29.7..../jest-runner/build/runTest.js:367:16)
    at runTest (.../sentry/node_modules/.pnpm/jest-runner@29.7..../jest-runner/build/runTest.js:444:34)
    at Object.worker (.../sentry/node_modules/.pnpm/jest-runner@29.7..../jest-runner/build/testWorker.js:106:12)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@Zylphrex Zylphrex marked this pull request as draft June 17, 2025 19:06
@Zylphrex Zylphrex marked this pull request as ready for review June 18, 2025 21:00
Comment on lines +20 to +28
type TraceItemAttributeKeyOptions = Pick<
ReturnType<typeof normalizeDateTimeParams>,
'end' | 'start' | 'statsPeriod' | 'utc'
> & {
attributeType: 'string' | 'number';
itemType: TraceItemDataset;
project?: string[];
substringMatch?: string;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something like this

Suggested change
type TraceItemAttributeKeyOptions = Pick<
ReturnType<typeof normalizeDateTimeParams>,
'end' | 'start' | 'statsPeriod' | 'utc'
> & {
attributeType: 'string' | 'number';
itemType: TraceItemDataset;
project?: string[];
substringMatch?: string;
};
type TraceItemAttributeKeyOptions = {
attributeType: 'string' | 'number';
itemType: TraceItemDataset;
project?: string[];
substringMatch?: string;
dateTime: Pick<
ReturnType<typeof normalizeDateTimeParams>,
'end' | 'start' | 'statsPeriod' | 'utc'
>
};

This would allow you to preserve the boundary between the dateTime and the trace item specific options (which seems like two different concepts anyways), at a small cost of the extra key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't actually do that, this is actually the type of the query string. And since the api is expecting all these keys at the top level, it needs to be like this.

@Zylphrex Zylphrex merged commit 9f84049 into master Jun 20, 2025
46 checks passed
@Zylphrex Zylphrex deleted the txiao/ref/pull-use-get-trace-item-attribute-keys-into-hook branch June 20, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants