0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 00:46:45 +01:00

fix: Added a bunch of logs to see whats up (#25365)

This commit is contained in:
Ben White 2024-10-03 21:22:09 +08:00 committed by GitHub
parent fa152e882c
commit 6faef7e7c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -43,6 +43,7 @@ export class Celery {
const body = [args, kwargs, { callbacks: null, errbacks: null, chain: null, chord: null }] const body = [args, kwargs, { callbacks: null, errbacks: null, chain: null, chord: null }]
/** A base64-encoded JSON representation of the body tuple. */ /** A base64-encoded JSON representation of the body tuple. */
const bodySerialized = Buffer.from(JSON.stringify(body)).toString('base64') const bodySerialized = Buffer.from(JSON.stringify(body)).toString('base64')
await this.redisLPush(CELERY_DEFAULT_QUEUE, { await this.redisLPush(CELERY_DEFAULT_QUEUE, {
body: bodySerialized, body: bodySerialized,
'content-encoding': 'utf-8', 'content-encoding': 'utf-8',

View File

@ -2,11 +2,14 @@ from typing import Optional
from celery import shared_task from celery import shared_task
from django.conf import settings from django.conf import settings
import posthoganalytics import posthoganalytics
from structlog import get_logger
from posthog.event_usage import report_team_action from posthog.event_usage import report_team_action
from posthog.tasks.email import send_hog_function_disabled, send_fatal_plugin_error from posthog.tasks.email import send_hog_function_disabled, send_fatal_plugin_error
from posthog.tasks.utils import CeleryQueue from posthog.tasks.utils import CeleryQueue
logger = get_logger(__name__)
# IMPORTANT - Do not modify this without also modifying plugin-server/../celery.ts # IMPORTANT - Do not modify this without also modifying plugin-server/../celery.ts
# Same goes for this file path and the task names # Same goes for this file path and the task names
queue = CeleryQueue.DEFAULT.value queue = CeleryQueue.DEFAULT.value
@ -28,9 +31,12 @@ def fatal_plugin_error(
def hog_function_state_transition(hog_function_id: str, state: int) -> None: def hog_function_state_transition(hog_function_id: str, state: int) -> None:
from posthog.models.hog_functions.hog_function import HogFunction from posthog.models.hog_functions.hog_function import HogFunction
logger.info("hog_function_state_transition", hog_function_id=hog_function_id, state=state)
hog_function = HogFunction.objects.get(id=hog_function_id) hog_function = HogFunction.objects.get(id=hog_function_id)
if not hog_function: if not hog_function:
logger.warning("hog_function_state_transition: hog_function not found", hog_function_id=hog_function_id)
return return
report_team_action( report_team_action(
@ -44,7 +50,11 @@ def hog_function_state_transition(hog_function_id: str, state: int) -> None:
) )
# TRICKY: It seems like without this call the events don't get flushed, possibly due to celery worker threads exiting... # TRICKY: It seems like without this call the events don't get flushed, possibly due to celery worker threads exiting...
logger.info("hog_function_state_transition: Flushing posthoganalytics")
posthoganalytics.flush() posthoganalytics.flush()
if state >= 2: # 2 and 3 are disabled if state >= 2: # 2 and 3 are disabled
logger.info("hog_function_state_transition: sending hog_function_disabled email")
send_hog_function_disabled.delay(hog_function_id) send_hog_function_disabled.delay(hog_function_id)
logger.info("hog_function_state_transition: done")