microsoft / mlops-promptflow-prompt

MLOps for PromptFlow SDK
MIT License
32 stars 2 forks source link

Add telemtry for az functions #78

Closed joshuaphelpsms closed 5 months ago

joshuaphelpsms commented 5 months ago

Description

This enables metrics, logs and traces for Azure Functions through the Azure Monitor OpenTelemetry library. Telemetry is sent directly to AppInsights by setting the environment variable APPLICATIONINSIGHTS_CONNECTION_STRING

What this adds

  1. Updates the azure functions to programming model v2. See here for a comparison. The main driver behind making this change is that it provides a single location to set up telemetry in function_app.py.
  2. Adds promptflow's @trace annotation to the class based flex flow
  3. Adds context propagation to each function. Incoming requests are not automatically correlated with telemetry being tracked in it. To correlate incoming requests with the function telemetry, we must manually propagate the context. See documentation. If using a flex consumption plan, richer traces and logs be emitted by setting "telemetryMode": "openTelemetry" in host.json. See docs

With context propagation: Screenshot 2024-05-30 at 4 31 07 PM

Without context propagation: Screenshot 2024-05-31 at 8 55 31 AM

  1. Turns off the AppInsights native logging. Logs are controlled by configure_azure_monitor. See docs