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

Can't see the workflow trace #1994

Open
eric-easyhealth opened this issue Sep 18, 2024 Discussed in #1804 · 4 comments
Open

Can't see the workflow trace #1994

eric-easyhealth opened this issue Sep 18, 2024 Discussed in #1804 · 4 comments
Labels
question Further information is requested

Comments

@eric-easyhealth
Copy link

Discussed in #1804

Originally posted by eric-easyhealth August 6, 2024
I'm using Haystack2 with latest trackloop 0.26.4, followed the offical guidance to init the traceloop by following code:

Traceloop.init(app_name="app_name", api_key="apikey")

it works perfect and shown me the openai track as following, but how can i enable the workflow track like what is suggested in the quick start document?
PS: i'm using a pipeline in a python class, dummy code as below:

from haystack import Pipeline
from haystack.components.generators.chat import OpenAIChatGenerator

class ChatPipelineViaRAG:
    def __init__(self, api_key:str = '')
        self.retrieve_pipeline = Pipeline()
        self.generator = OpenAIChatGenerator()
        ......
    
    def run(self, messages: List[ChatMessage]) -> dict[str, Any]:
        retrieved_documents = self.retrieve_pipeline.run(parameters...)
        self.messages = process_documents(messages, retrieved_documents)
        return self.generator.run(self.messages)
        
image image
Copy link

dosubot bot commented Sep 18, 2024

Hey, @eric-easyhealth! I'm here to help you with any bugs, questions, or contributions you have. Let's squash those bugs together!

I found a similar unsolved discussion where a user faced a similar issue with workflow trace visibility while using Haystack2 with Traceloop 0.26.4. You can check it out here [1].

To enable workflow tracking in Traceloop 0.26.4 when using a pipeline in a Python class with the OpenAIChatGenerator, follow these steps:

  1. Install the Traceloop SDK:

    pip install traceloop-sdk
  2. Initialize the Traceloop tracer:

    from traceloop.sdk import Traceloop
    
    Traceloop.init(app_name="app_name", api_key="apikey")
  3. Annotate your workflows:
    Use the @workflow and @task decorators to enable workflow tracking for your functions. Here is an example:

    from haystack import Pipeline
    from haystack.components.generators.chat import OpenAIChatGenerator
    from traceloop.sdk.decorators import workflow, task
    
    class ChatPipelineViaRAG:
        def __init__(self, api_key: str = ''):
            self.retrieve_pipeline = Pipeline()
            self.generator = OpenAIChatGenerator()
    
        @workflow(name="chat_pipeline_workflow")
        def run(self, messages: List[ChatMessage]) -> dict[str, Any]:
            retrieved_documents = self.retrieve_pipeline.run(parameters...)
            self.messages = self.process_documents(messages, retrieved_documents)
            return self.generator.run(self.messages)
    
        @task(name="process_documents_task")
        def process_documents(self, messages, retrieved_documents):
            # Your document processing logic here
            return processed_messages
  4. Configure trace exporting:
    Set the environment variables TRACELOOP_API_KEY and TRACELOOP_BASE_URL:

    export TRACELOOP_API_KEY=your_api_key

By following these steps, you should be able to enable workflow tracking for your pipeline using Traceloop [2][3][4].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the question Further information is requested label Sep 18, 2024
@eric-easyhealth
Copy link
Author

this doesn't resolve my questions, this workflow should be automatically identfied according to the documentation if i used haystack.

Copy link

dosubot bot commented Sep 18, 2024

To enable automatic workflow tracking in Traceloop 0.26.4 when using Haystack2, you do not need to add any annotations to your code. Traceloop will automatically handle the annotations for you if you are using an LLM framework like Haystack.

Here's how you can initialize Traceloop:

from traceloop.sdk import Traceloop

Traceloop.init(app_name="app_name", api_key="apikey")

If you’re running this locally and want to see the traces immediately, you can disable batch sending:

Traceloop.init(app_name="app_name", api_key="apikey", disable_batch=True)

This setup should enable automatic workflow tracking in Traceloop when using Haystack2 [1].

To continue talking to Dosu, mention @dosu.

@nirga
Copy link
Member

nirga commented Sep 18, 2024

Sorry about the bot @eric-easyhealth, we're trying something new 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants