Troubleshooting Chatbot API Traces on Azure with LangChain
Hi team need a help . My chatbot is hosted on Azure and we have API to access the chatbot, so if we use post request with question I get an answer. I tried to collect traces of this by manually forcing tracer, tracing are coming as empty . I have pasted sample code from typing import Dict, Any from langchain_core.runnables import RunnableSerializable from pydantic import Field import json import requests class RequestsChain(RunnableSerializable): endpoint: str = Field(..., description="API endpoint for chatbot requests") def invoke(self, input: Dict[str, Any], config: Dict[str, Any] = {}) -> Dict[str, Any]: try: response = requests.post(self.endpoint, data=json.dumps(input), headers={"Content-Type": "application/json"}) response.raise_for_status() return response.json() except Exception as e: return {"error": str(e), "input": input} session = px.launch_app() tracer_provider = register() LangChainInstrumentor(tracer_provider=tracer_provider).instrument(skip_dep_check=True) API_URL = "chatbot.com" chain = RequestsChain(endpoint=API_URL) chain_type = "stuff" with tracer_provider.get_tracer("langchain").start_as_current_span("manual_request_trace"): span.set_attribute("input_question", question) result = chain.invoke({"ques_text": "What is wind velocity"}) print(result)
