Debugging Phoenix Instrumentation with Azure Functions and Traces Issues
Hello! I am trying to run Pheonix Instrumentation for an Azure Function that calls an AzureOpenAI LLM accessed via the openai library. However, when I tried to run Azure Function locally via Visual Studio Code (i.e. func host start), the Pheonix server does not receive any traces. Interestingly, when I tried to run the code outside of the Azure Function (i.e. outside the http_trigger that has @app.route decorator), traces are being sent to Pheonix server. I have even stripped down the code to only the following, but still same behavior. Is this behavior expected? I have a feeling the Azure Function wrapper is stopping the telemetry requests, but I couldnt find anything online. Any help appreciated! I also noticed that sampling_result in trace/__init__.py is False when executed inside Azure Function, but True outside. Not sure why
from opentelemetry import trace as trace_api
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk import trace as trace_sdk
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from openinference.instrumentation.openai import OpenAIInstrumentor
import azure.functions as func
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION)
@app.route(route="http_trigger")
def http_trigger(req: func.HttpRequest):
endpoint = "http://localhost:6006/v1/traces"
tracer_provider = trace_sdk.TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))
trace_api.set_tracer_provider(tracer_provider)
trace_api.get_tracer(__name__).start_span("test12321985").end()
return func.HttpResponse(
'hi',
status_code=200,
)
