Use OpenTelemetry with Azure Functions
Export telemetry from Azure Function to any OTLP-compatible endpoint
As modern applications increasingly adopt distributed architectures, observability becomes essential for understanding system behavior.
OpenTelemetry provides a vendor-agnostic way to collect traces, metrics, and logs from your application. It is an industry standard for instrumenting applications and transmitting telemetry. Read more about this technology here: OpenTelemetry Explained
By default, Azure Functions emit telemetry from both the host process and the language-specific worker, and this data is typically sent to Application Insights via its SDK.
With this update, you can now export the same telemetry (structured traces and logs), to any OTLP-compatible backend in a few easy steps.
First, let us take a sample OLTP endpoint to send our telemetry data to. In this case, I am using an observability platform for the test: honeycomb.io. I first created an account with them and obtained some config details which you can find in their docs:
Pick your API key from the section shown below:
Now, we can begin to configure our sample azure function in order to be able to send telemetry data to the public endpoint obtained above.
Enable OpenTelemetry in the Functions host
Configure application settings
PS; Make sure you replace the <your-api-key> with the API key copied from honeycomb site.
Enable OpenTelemetry in your app
This involved installing the packages, I have more here because I planned to send to Application Insights as well. If you only want to send to the OLTP endpoint, then you don’t need to have as many. Check the Microsoft docs to confirm which packages you need.
4. In your program.cs:
Final step is to send logs from your function:
When you run and post to this function, you find telemetry data in your honeycomb’s dataset:
General trace:
Custom Data Sent:
Official Microsoft Documentation: Use OpenTelemetry with Azure Functions
That’s all for today.
See you in the next one.