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

Add Azure integration #2

Merged
merged 33 commits into from
Nov 30, 2023
Merged

Add Azure integration #2

merged 33 commits into from
Nov 30, 2023

Conversation

aavetis
Copy link
Contributor

@aavetis aavetis commented Nov 1, 2023

note! did not test / compile docs locally; did the entire change in browser - please verify

@nirga
Copy link
Member

nirga commented Nov 1, 2023

Thanks @aavetis! I've added some 2 missing references (and also updated the README so people will know how to test it locally).

Reg the docs specifically - I'm not sure why you need all the code you wrote. Specifically around manually creating spans, and re-defining the span processor. This should also work:

from traceloop.sdk import Traceloop
from traceloop.sdk.decorators import workflow
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter

import openai  # Ensure you have the openai library installed

# Configure the tracer provider to export traces to Azure Application Insights
exporter = AzureMonitorTraceExporter(connection_string="INSERT_CONNECTION_STRING_HERE")
Traceloop.init(app_name="your_app_name", exporter=exporter)


@workflow(name="llm_execution")
def execute_llm():
        # Replace with your actual OpenAI API call
        response = openai.ChatCompletion.create(
            model="gpt-3.5-turbo",
            messages=[{"role": "user", "content": "Hello world"}],
            max_tokens=60
        )

        return response['choices'][0]['message']['content']

if __name__ == "__main__":
    execute_llm()

If I'm right, then I'd try to keep this simple and just mention how to initialize the Azure exporter and pass it to the Traceloop.init call:

exporter = AzureMonitorTraceExporter(connection_string="INSERT_CONNECTION_STRING_HERE")
Traceloop.init(app_name="your_app_name", exporter=exporter)

@nirga
Copy link
Member

nirga commented Nov 13, 2023

@aavetis do you plan to continue working on that?

@aavetis
Copy link
Contributor Author

aavetis commented Nov 30, 2023

apologies for the delay

@nirga
Copy link
Member

nirga commented Nov 30, 2023

Thanks @aavetis! :) Mind rebasing so I can merge this?

@nirga nirga merged commit d2f8a24 into traceloop:main Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants