PostHog / posthog

đŸĻ” PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
21.23k stars 1.26k forks source link

feat(queries): Store query calculation trigger in cache payload to get metrics #23477

Closed webjunkie closed 2 months ago

webjunkie commented 3 months ago

Problem

We have a cache warming system (InsightCacheState tasks) but we don't actually know if it's useful.

Changes

Add the trigger of a calculation to what is cached. Then add this trigger string to the cache hit metric. This way we can graph cache hits by what filled the cache in the first place. If the cache warming is efficient, it should show up somewhat.

How did you test this code?

tbd

sentry-io[bot] commented 3 months ago

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: posthog/clickhouse/client/execute_async.py

Function Unhandled Issue
execute_process_query ValidationError: 1 validation error for QuerySchemaRoot posthog.tasks.tasks.process_que...
Event Count: 2
execute_process_query QueryNotFoundError: Query 97859889-eb0a-4af3-87f1-63fc37dac285 not found for team 7139 ...
Event Count: 1
📄 File: posthog/hogql_queries/query_runner.py (Click to Expand) | Function | Unhandled Issue | | :------- | :----- | | **`run`** | [**IndexError: list index out of range**](https://posthog.sentry.io/issues/5482508134/?referrer=github-open-pr-bot) posthog.tasks...
`Event Count:` **88** | | **`run`** | [**ValidationError: 1 validation error for HogQLQueryResponse**](https://posthog.sentry.io/issues/5485263394/?referrer=github-open-pr-bot) posthog.tasks.tasks.process_...
`Event Count:` **25** | | **`run`** | [**TypeError: Dict key must be str**](https://posthog.sentry.io/issues/5475988112/?referrer=github-open-pr-bot) posthog.tasks.tas...
`Event Count:` **14** | | **`run`** | [**ValidationError: ["Filter parameter funnel_to_step can only be one of 1 for time to convert!"]**](https://posthog.sentry.io/issues/5543459615/?referrer=github-open-pr-bot) ...
`Event Count:` **11** |

Did you find this useful? React with a 👍 or 👎

github-actions[bot] commented 3 months ago

Size Change: 0 B

Total Size: 1.07 MB

ℹī¸ View Unchanged | Filename | Size | | :--- | :---: | | `frontend/dist/toolbar.js` | 1.07 MB |

compressed-size-action

posthog-bot commented 2 months ago

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot commented 2 months ago

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

Triggered by this commit.

👉 Review this PR's diff of snapshots.