Python sdk
Troubleshooting

Troubleshooting

Azure Function not sending telemetry data

If you are using Azure function and not able to see logs data coming to Agiflow. We need to make some code changes as Azure Function has its own implementation of telemtry.

1. Update host.json

Inside host.json, update logLevel to enable Tracing as below:

{
  ...
  "logging": {
    "logLevel": {
      "Worker": "Trace",
      "Function": "Trace"
    }
  }
}

2. Add environment settings

AZURE_SDK_TRACING_IMPLEMENTATION=opentelemetry

This option signal Azure function to use opentelemtry as default telemetry method.

PYTHON_ISOLATE_WORKER_DEPENDENCIES=1

Priority your own dependencies to be loaded rather than Azure's default one.

3. Code changes

We need to replace OpenTelemetry sampler and trace processor with agiflow implementation to ensure LLM traces are always sent for feedback as below:

from agiflow import Agiflow
from agiflow.opentelemetry import ThreadPoolSpanProcessor, NoSampler
 
Agiflow.init(
  app_name="<YOUR APP NAME>",
  Processor=ThreadPoolSpanProcessor,
  sample=NoSampler(),
)