Skip to content

Commit

Permalink
Merge branch 'master' into dn-feat/better-css-parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin committed Apr 30, 2024
2 parents 4942a18 + 6876dd8 commit a756743
Show file tree
Hide file tree
Showing 16 changed files with 253 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ export const propertyFilterLogic = kea<propertyFilterLogicType>([
listeners(({ actions, props, values }) => ({
// Only send update if value is set to something
setFilter: async ({ property }) => {
if (props.sendAllKeyUpdates || property?.value || (property?.key && property.type === 'hogql')) {
if (
props.sendAllKeyUpdates ||
property?.value ||
('operator' in property &&
property?.operator &&
['is_set', 'is_not_set'].includes(property?.operator)) ||
(property?.key && property.type === 'hogql')
) {
actions.update()
}
},
Expand Down
72 changes: 70 additions & 2 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,10 @@
"FunnelsQueryResponse": {
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -2720,7 +2724,7 @@
"type": "array"
},
"error": {
"description": "Query error. Returned only if 'explain' is true. Throws an error otherwise.",
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"explain": {
Expand Down Expand Up @@ -3275,6 +3279,10 @@
"LifecycleQueryResponse": {
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -3574,6 +3582,10 @@
"PathsQueryResponse": {
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -3808,6 +3820,10 @@
"QueryResponse": {
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -4119,7 +4135,7 @@
"type": "array"
},
"error": {
"description": "Query error. Returned only if 'explain' is true. Throws an error otherwise.",
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"explain": {
Expand Down Expand Up @@ -4238,6 +4254,10 @@
{
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -4279,6 +4299,10 @@
"items": {},
"type": "array"
},
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hasMore": {
"type": "boolean"
},
Expand Down Expand Up @@ -4331,6 +4355,10 @@
"items": {},
"type": "array"
},
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -4370,6 +4398,10 @@
{
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -4404,6 +4436,10 @@
{
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -4438,6 +4474,10 @@
{
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -4472,6 +4512,10 @@
{
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -4871,6 +4915,10 @@
"RetentionQueryResponse": {
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -5268,6 +5316,10 @@
"StickinessQueryResponse": {
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -5605,6 +5657,10 @@
"TrendsQueryResponse": {
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -5790,6 +5846,10 @@
"WebOverviewQueryResponse": {
"additionalProperties": false,
"properties": {
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down Expand Up @@ -5905,6 +5965,10 @@
"items": {},
"type": "array"
},
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hasMore": {
"type": "boolean"
},
Expand Down Expand Up @@ -5995,6 +6059,10 @@
"items": {},
"type": "array"
},
"error": {
"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.",
"type": "string"
},
"hogql": {
"type": "string"
},
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export interface HogQLQueryResponse {
clickhouse?: string
/** Query results */
results?: any[]
/** Query error. Returned only if 'explain' is true. Throws an error otherwise. */
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string
/** Returned columns */
columns?: any[]
Expand Down Expand Up @@ -896,6 +896,8 @@ export interface QueryResponse {
results: unknown
timings?: QueryTiming[]
hogql?: string
/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */
error?: string
is_cached?: boolean
last_refresh?: string
next_allowed_client_refresh?: string
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/debug/DebugScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ export function DebugScene(): JSX.Element {
/>
<div className="flex gap-2">
<div className="flex-1 w-1/2">
<DebugSceneQuery query={query1} setQuery={setQuery1} queryKey="hogql-debug-1" />
<DebugSceneQuery query={query1} setQuery={setQuery1} queryKey="new-hogql-debug-1" />
</div>
{query2 ? (
<div className="flex-1 w-1/2">
<DebugSceneQuery query={query2} setQuery={setQuery2} queryKey="hogql-debug-2" />
<DebugSceneQuery query={query2} setQuery={setQuery2} queryKey="new-hogql-debug-2" />
</div>
) : null}
</div>
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/scenes/debug/DebugSceneQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import { Modifiers } from 'scenes/debug/Modifiers'
import { QueryTabs } from 'scenes/debug/QueryTabs'

import { dataNodeLogic, DataNodeLogicProps } from '~/queries/nodes/DataNode/dataNodeLogic'
import { insightVizDataNodeKey } from '~/queries/nodes/InsightViz/InsightViz'
import { QueryEditor } from '~/queries/QueryEditor/QueryEditor'
import { DataNode, HogQLQuery, Node } from '~/queries/schema'
import { isDataTableNode, isInsightVizNode } from '~/queries/utils'

interface DebugSceneQueryProps {
queryKey: string
queryKey: `new-${string}`
query: string
setQuery: (query: string) => void
}

export function DebugSceneQuery({ query, setQuery, queryKey }: DebugSceneQueryProps): JSX.Element {
let parsed: Record<string, any> | null = null
try {
Expand All @@ -23,9 +25,10 @@ export function DebugSceneQuery({ query, setQuery, queryKey }: DebugSceneQueryPr
const dataNode =
parsed && (isInsightVizNode(parsed as Node) || isDataTableNode(parsed as Node)) ? parsed.source : parsed

const dataNodeKey = insightVizDataNodeKey({ dashboardItemId: queryKey })
const dataNodeLogicProps: DataNodeLogicProps = {
query: dataNode as DataNode,
key: queryKey,
key: dataNodeKey,
dataNodeCollectionId: queryKey,
modifiers: { debug: true },
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/debug/HogQLDebug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DataNode, HogQLQuery, HogQLQueryResponse } from '~/queries/schema'
import { QueryTabs } from './QueryTabs'

interface HogQLDebugProps {
queryKey: string
queryKey: `new-${string}`
query: HogQLQuery
setQuery: (query: DataNode) => void
}
Expand Down
18 changes: 16 additions & 2 deletions frontend/src/scenes/debug/QueryTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function toColumn(hogql: string, position: number): number {
}
interface QueryTabsProps {
query: Node
queryKey: string
queryKey: `new-${string}`
response?: Record<string, any> | null
setQuery: (query: DataNode) => void
}
Expand All @@ -62,7 +62,21 @@ export function QueryTabs({ query, queryKey, setQuery, response }: QueryTabsProp
isInsightVizNode(query) && {
key: 'viz',
label: 'Visualization',
content: <Query uniqueKey={queryKey} query={query} setQuery={(query) => setQuery(query)} />,
content: (
<Query
uniqueKey={queryKey}
query={query}
setQuery={(query) => setQuery(query)}
context={{
insightProps: {
dashboardItemId: queryKey,
query,
setQuery: (query) => setQuery(query),
dataNodeCollectionId: queryKey,
},
}}
/>
),
},
isInsightQueryNode(query) && {
key: 'insight',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export class SessionRecordingIngester {
})
await runInstrumentedFunction({
statsKey: `recordingingester.handleEachBatch`,
logExecutionTime: true,
sendTimeoutGuardToSentry: false,
func: async () => {
histogramKafkaBatchSize.observe(messages.length)
histogramKafkaBatchSizeKb.observe(messages.reduce((acc, m) => (m.value?.length ?? 0) + acc, 0) / 1024)
Expand Down Expand Up @@ -646,7 +646,6 @@ export class SessionRecordingIngester {
const startTime = Date.now()
await runInstrumentedFunction({
statsKey: `recordingingester.onRevokePartitions.revokeSessions`,
logExecutionTime: true,
timeout: SHUTDOWN_FLUSH_TIMEOUT_MS, // same as the partition lock
func: async () => {
if (this.config.SESSION_RECORDING_PARTITION_REVOKE_OPTIMIZATION) {
Expand Down
9 changes: 8 additions & 1 deletion plugin-server/src/main/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface FunctionInstrumentation<T> {
timeoutContext?: () => Record<string, any>
teamId?: number
logExecutionTime?: boolean
sendTimeoutGuardToSentry?: boolean
}

const logTime = (startTime: number, statsKey: string, error?: any) => {
Expand All @@ -30,8 +31,14 @@ export async function runInstrumentedFunction<T>({
statsKey,
teamId,
logExecutionTime = false,
sendTimeoutGuardToSentry = true,
}: FunctionInstrumentation<T>): Promise<T> {
const t = timeoutGuard(timeoutMessage ?? `Timeout warning for '${statsKey}'!`, timeoutContext, timeout)
const t = timeoutGuard(
timeoutMessage ?? `Timeout warning for '${statsKey}'!`,
timeoutContext,
timeout,
sendTimeoutGuardToSentry
)
const startTime = performance.now()
const end = instrumentedFunctionDuration.startTimer({
function: statsKey,
Expand Down
Loading

0 comments on commit a756743

Please sign in to comment.