feat: Add telemetry ping task to celery worker and main.py (#2494)

This pull request adds a new telemetry ping task to the celery worker
and main.py files. The ping task sends a ping message to the telemetry
system.
This commit is contained in:
Stan Girard 2024-04-25 07:22:13 -07:00 committed by GitHub
parent 55b456bfe1
commit 2a25f442e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View File

@ -20,6 +20,7 @@ from modules.onboarding.service.onboarding_service import OnboardingService
from packages.files.crawl.crawler import CrawlWebsite
from packages.files.parsers.github import process_github
from packages.files.processors import filter_file
from packages.utils.telemetry import maybe_send_telemetry
logger = get_logger(__name__)
@ -181,6 +182,11 @@ def process_integration_brain_sync_user_brain(brain_id, user_id):
notion_connector.poll()
@celery.task
def ping_telemetry():
maybe_send_telemetry("ping", {"ping": "pong"})
@celery.task
def process_integration_brain_sync():
integration = IntegrationBrain()
@ -213,4 +219,8 @@ celery.conf.beat_schedule = {
"task": f"{__name__}.process_integration_brain_sync",
"schedule": crontab(minute="*/5", hour="*"),
},
"ping_telemetry": {
"task": f"{__name__}.ping_telemetry",
"schedule": crontab(minute="*/30", hour="*"),
},
}

View File

@ -108,6 +108,7 @@ if os.getenv("TELEMETRY_ENABLED") == "true":
"To disable telemetry, set the TELEMETRY_ENABLED environment variable to false."
)
maybe_send_telemetry("booting", {"status": "ok"})
maybe_send_telemetry("ping", {"ping": "pong"})
if __name__ == "__main__":

View File

@ -142,7 +142,7 @@ def generate_replies(
test_groundtruths = test_data.ground_truth.tolist()
for question in test_questions:
response = brain_chain.invoke({"question": question})
response = brain_chain.invoke({"question": question, "chat_history": []})
answers.append(response["answer"].content)
contexts.append([context.page_content for context in response["docs"]])