Share via

How to Add Custom Properties to Durable Functions Request Telemetry in Application Insights (Python / Durable Functions)

Burg, van der (Tommy) 0 Reputation points
2026-04-02T13:24:46.32+00:00

Hi all,

I’m working with Azure Function Apps (Python) using Durable Functions, and I’m sending telemetry to a Storage Account via Application Insights Diagnostic Settings.

For each Durable Functions activity/orchestrator execution, Application Insights automatically logs an AppRequests entry — including the standard durabletask.* properties such as:

"durabletask.type": "activity","durabletask.task.name": "process_reasons", "durabletask.task.instance_id": "<PII Removed>",

I would like to enrich these automatically‑generated Request telemetry items with custom properties (e.g. business identifiers, execution context, environment, tenant, correlation values, etc.).

✅ What I am trying to do

I want to do something like:

  • Add custom attributes (e.g. "tenantId", "caseId", "businessStep")
  • Ensure they appear under Custom Properties in the Request telemetry
  • Specifically for telemetry generated by Durable Functions (activities & orchestrators)

✅ What I have already tried

I looked at and attempted the guidance from:

However, these options don’t seem to apply to the automatically generated Durable Functions request logs. I haven’t found a working way (in Python) to hook into or extend the durabletask telemetry.

✅ My question

Is it possible (and if so, how) to add custom properties to the automatically logged Durable Functions Request telemetry in Application Insights when using Python Durable Functions?

More specifically:

  • Can I register a Telemetry Processor / Telemetry Initializer for Durable Functions in Python?
  • Is there a supported way to attach additional custom properties to those activity/orchestrator traces?

Any examples or documentation would be greatly appreciated!

Thanks in advance 🙏

Azure Monitor
Azure Monitor

An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.


2 answers

Sort by: Most helpful
  1. Bharath Y P 9,720 Reputation points Microsoft External Staff Moderator
    2026-04-02T15:28:47.4433333+00:00

    Hello Burg, van der (Tommy), We understand that you are using Azure Durable Functions (Python) with Application Insights. The Durable Task framework automatically logs AppRequests telemetry for orchestrator and activity executions, including properties like durabletask.type, durabletask.task.name, and durabletask.task.instance_id. You want to enrich these automatically generated telemetry items with custom properties (e.g., tenantId, caseId, businessStep).

    The telemetry for orchestrators/activities is generated internally by the Durable Task framework. Unlike .NET, the Python SDK does not expose Telemetry Initializers or Processors for Durable Functions. You can enrich spans/events you create, but not those automatically created by Durable Functions.

    This is why your attempts with Telemetry Initializers or Diagnostic Settings didn’t affect the durabletask telemetry.

     Yes, it is not possible to directly modify the auto‑generated Durable Functions Request telemetry items in Application Insights when using Python. The Durable Task framework emits those entries internally, and the Python SDK does not expose a Telemetry Initializer/Processor hook like .NET does.

    What you can do is enrich the current distributed tracing span that Durable Functions creates when you enable distributed tracing. Application Insights will then record your custom attributes as customDimensions alongside the durabletask properties. What you can try is you can enable Durable Functions Distributed Tracing (V2) in host.json and then enrich the active OpenTelemetry span inside your Python orchestrators and activities using trace.get_current_span().set_attribute(...). The Functions host creates the span for each Durable execution and propagates the trace context to the Python worker, allowing your code to attach business metadata such as tenantId, caseId, or workflowStep. Application Insights captures these attributes as customDimensions on worker-emitted span/trace telemetry, and because they share the same operation_Id as the Durable Request telemetry, they are automatically correlated in end-to-end traces and can be queried together, even though the host-generated Request record itself is not modified.

    Hope this helps. and please feel free to reach out if you have any further questions. Thanks

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-04-02T13:25:06.17+00:00

    For Durable Functions, the automatically generated telemetry (including the durabletask.* attributes) is produced by the Durable Task SDK and exported via OpenTelemetry. Custom properties can be added by enriching spans before they’re exported to Application Insights.

    For Python, the supported way to add custom properties is to use a custom span processor that modifies spans (requests/dependencies/traces) and adds attributes, which then appear as customDimensions in Application Insights.

    Key points from the provided documentation:

    1. Durable Functions tracing is OpenTelemetry-based
      Durable Functions uses Durable Task Scheduler tracing. Enabling distributed tracing and sending it to Application Insights is done via OpenTelemetry. The spans include attributes such as durabletask.type, durabletask.task.name, and durabletask.task.instance_id.
    2. Custom attributes on spans become custom properties in Application Insights
      The OpenTelemetry guidance states that any attributes added to spans are exported as custom properties and populate the customDimensions field in the Application Insights tables (requests, dependencies, traces, exceptions):

      Any attributes you add to spans are exported as custom properties. They populate the customDimensions field in the requests, dependencies, traces, or exceptions table.

    3. Python: use a custom processor to modify spans
      For Python, the documented pattern to modify telemetry is to implement a custom span processor that runs on each span and adds attributes. The same mechanism can be used to enrich Durable Functions spans (including the ones that map to Request telemetry):
      • Create a custom processor (for example, SpanEnrichingProcessor) that inspects each span.
      • In on_end(span), check for Durable Task spans (for example, by span.name or durabletask.* attributes) and then set additional attributes such as tenantId, caseId, or businessStep.
      • Register this processor in the OpenTelemetry pipeline before the Azure Monitor exporter.
      The documentation shows this pattern for Python when setting attributes like http.client_ip via a custom processor:
         # Set the `http.client_ip` attribute of the span to the specified IP address.
         span._attributes["http.client_ip"] = "<IP Address>"
      
      The same approach applies to any custom attributes, for example:
         span._attributes["tenantId"] = "<tenant>"
         span._attributes["caseId"] = "<case>"
         span._attributes["businessStep"] = "<step>"
      
      These attributes will then appear as custom properties in the corresponding Application Insights telemetry rows.
    4. Supported custom telemetry types for Python
      The OpenTelemetry API for Python supports custom attributes on spans that map to Requests, Dependencies, Traces, and Exceptions. The table confirms that for Python, OpenTelemetry spans are exported to Application Insights as Requests/Dependencies/Exceptions, and attributes become customDimensions.
    5. Durable Functions–specific behavior
      The Durable Task tracing documentation lists the span types (create_orchestration, orchestration, activity:<name>, sub_orchestration:<name>, timer) and notes that each span includes durabletask.* attributes. A custom processor can read these attributes and add business-specific ones. There is no separate Durable Functions–specific “telemetry initializer” API in Python; the supported mechanism is OpenTelemetry span enrichment.

    Summary:

    • Yes, it is possible to add custom properties to Durable Functions telemetry that appears as Request items in Application Insights when using Python.
    • The supported way is to configure OpenTelemetry for the Function App and register a custom span processor that:
      • Identifies Durable Task spans (for orchestrations/activities).
      • Adds custom attributes (tenant, case, business step, etc.).
    • These attributes are exported to Application Insights as customDimensions on the corresponding Request/Dependency/Trace records.

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.