-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
feat(logs): Add view samples button in logs #98133
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c4432c4
feat(logs): Add view samples button in logs
Zylphrex 169caf6
Merge branch 'master' into txiao/feat/add-view-samples-button-in-logs
Zylphrex fccaff4
clean up
Zylphrex c84c1ce
fix tests
Zylphrex a64604b
Merge branch 'master' into txiao/feat/add-view-samples-button-in-logs
Zylphrex 77c447b
add top events indicator
Zylphrex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import type {ReactNode} from 'react'; | ||
import * as Sentry from '@sentry/react'; | ||
import type {Location} from 'history'; | ||
import * as qs from 'query-string'; | ||
|
||
import type {ApiResult} from 'sentry/api'; | ||
import {t} from 'sentry/locale'; | ||
import type {PageFilters} from 'sentry/types/core'; | ||
import type {TagCollection} from 'sentry/types/group'; | ||
import type {Organization} from 'sentry/types/organization'; | ||
import type {Project} from 'sentry/types/project'; | ||
import {defined} from 'sentry/utils'; | ||
import type {EventsMetaType} from 'sentry/utils/discover/eventView'; | ||
import { | ||
|
@@ -26,6 +28,7 @@ import { | |
LOGS_FIELDS_KEY, | ||
LOGS_GROUP_BY_KEY, | ||
LOGS_QUERY_KEY, | ||
setLogsPageParams, | ||
} from 'sentry/views/explore/contexts/logs/logsPageParams'; | ||
import {LOGS_SORT_BYS_KEY} from 'sentry/views/explore/contexts/logs/sortBys'; | ||
import {Mode} from 'sentry/views/explore/contexts/pageParamsContext/mode'; | ||
|
@@ -49,8 +52,11 @@ import { | |
type OurLogsResponseItem, | ||
} from 'sentry/views/explore/logs/types'; | ||
import type {GroupBy} from 'sentry/views/explore/queryParams/groupBy'; | ||
import type {BaseVisualize} from 'sentry/views/explore/queryParams/visualize'; | ||
import type {PickableDays} from 'sentry/views/explore/utils'; | ||
import { | ||
type BaseVisualize, | ||
type Visualize, | ||
} from 'sentry/views/explore/queryParams/visualize'; | ||
import {generateTargetQuery, type PickableDays} from 'sentry/views/explore/utils'; | ||
import type {useSortedTimeSeries} from 'sentry/views/insights/common/queries/useSortedTimeSeries'; | ||
|
||
const {warn, fmt} = Sentry.logger; | ||
|
@@ -503,6 +509,49 @@ export function ourlogToJson(ourlog: TraceItemDetailsResponse | undefined): stri | |
return JSON.stringify(copy, null, 2); | ||
} | ||
|
||
export function viewLogsSamplesTarget({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we maybe reuse There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we'll think about how to consolidate more of these ways to link to logs |
||
location, | ||
search, | ||
fields, | ||
groupBys, | ||
visualizes, | ||
sorts, | ||
row, | ||
projects, | ||
}: { | ||
fields: string[]; | ||
groupBys: readonly string[]; | ||
location: Location; | ||
// needed to generate targets when `project` is in the group by | ||
projects: Project[]; | ||
row: Record<string, any>; | ||
search: MutableSearch; | ||
sorts: Sort[]; | ||
visualizes: readonly Visualize[]; | ||
}) { | ||
const { | ||
fields: newFields, | ||
search: newSearch, | ||
sortBys: newSortBys, | ||
} = generateTargetQuery({ | ||
fields, | ||
groupBys: groupBys.slice(), | ||
location, | ||
projects, | ||
search, | ||
row, | ||
sorts, | ||
yAxes: visualizes.map(visualize => visualize.yAxis), | ||
}); | ||
|
||
return setLogsPageParams(location, { | ||
mode: Mode.SAMPLES, | ||
fields: newFields, | ||
search: newSearch, | ||
sortBys: newSortBys, | ||
}); | ||
} | ||
|
||
export const logOnceFactory = (logSeverity: 'info' | 'warn') => { | ||
let fired = false; | ||
return (...args: Parameters<(typeof Sentry.logger)[typeof logSeverity]>) => { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Palette Initialization Causes Out-of-Bounds Errors
The
palette
is initialized withnumberOfRowsNeedingColor - 1
elements. This can lead totheme.chart.getColorPalette
being called with a negative argument (-1
) whennumberOfRowsNeedingColor
is 0. Additionally, whennumberOfRowsNeedingColor
equalstopEventsLimit
, the palette is one element too small, causing an out-of-bounds access whenpalette[rowIndex]!
is used for the lastrowIndex
.