Skip to content
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

Avoid traceloop to be called multiple times! #20

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions celery_app/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import os

from celery import Celery
from dotenv import load_dotenv
from traceloop.sdk import Traceloop
from utils.credentials import load_rabbitmq_credentials

rabbit_creds = load_rabbitmq_credentials()
Expand All @@ -7,5 +11,9 @@
host = rabbit_creds["host"]
port = rabbit_creds["port"]

load_dotenv()
otel_endpoint = os.getenv("TRACELOOP_BASE_URL")
Traceloop.init(api_endpoint=otel_endpoint, app_name="hivemind-server")

app = Celery("celery_app/tasks", broker=f"pyamqp://{user}:{password}@{host}:{port}//")
app.autodiscover_tasks(["celery_app"])
7 changes: 0 additions & 7 deletions celery_app/tasks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import json
import logging
import os
from typing import Any

from celery_app.server import app
from celery_app.utils.fire_event import job_send
from dotenv import load_dotenv
from subquery import query_multiple_source
from tc_messageBroker.rabbit_mq.event import Event
from tc_messageBroker.rabbit_mq.payload.discord_bot.base_types.interaction_callback_data import (
Expand All @@ -16,7 +14,6 @@
)
from tc_messageBroker.rabbit_mq.payload.payload import Payload
from tc_messageBroker.rabbit_mq.queue import Queue
from traceloop.sdk import Traceloop


@app.task
Expand All @@ -43,10 +40,6 @@ def ask_question_auto_search(
- `date`
- `content`: which is the `ChatInputCommandInteraction` as a dictionary
"""
load_dotenv()
otel_endpoint = os.getenv("TRACELOOP_BASE_URL")
Traceloop.init(api_endpoint=otel_endpoint, app_name="Hivemind-server")

prefix = f"COMMUNITY_ID: {community_id} | "
logging.info(f"{prefix}Processing question!")

Expand Down