Skip to content

Commit fc52ce4

Browse files
Merge pull request #270700 from jeremydvoss/python-functions
Fix azure function app insights docs to point to otel
2 parents cd9f9ea + e4cae90 commit fc52ce4

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

articles/azure-monitor/app/codeless-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Links are provided to more information for each supported scenario.
3636
|Azure App Service on Windows - Publish as Docker | [ :white_check_mark: :link: ](https://azure.github.io/AppService/2022/04/11/windows-containers-app-insights-preview.html) ² | [ :white_check_mark: :link: ](https://azure.github.io/AppService/2022/04/11/windows-containers-app-insights-preview.html) ² | [ :white_check_mark: :link: ](https://azure.github.io/AppService/2022/04/11/windows-containers-app-insights-preview.html) ² | [ :white_check_mark: :link: ](https://techcommunity.microsoft.com/t5/apps-on-azure-blog/public-preview-application-insights-auto-instrumentation-for/ba-p/3947971) ² | :x: |
3737
|Azure App Service on Linux - Publish as Code | :x: | [ :white_check_mark: :link: ](azure-web-apps-net-core.md?tabs=linux) ¹ | [ :white_check_mark: :link: ](azure-web-apps-java.md) ¹ | [ :white_check_mark: :link: ](azure-web-apps-nodejs.md?tabs=linux) | [ :white_check_mark: :link: ](azure-web-apps-python.md?tabs=linux) ² |
3838
|Azure App Service on Linux - Publish as Docker | :x: | [ :white_check_mark: :link: ](azure-web-apps-net-core.md?tabs=linux) | [ :white_check_mark: :link: ](azure-web-apps-java.md) | [ :white_check_mark: :link: ](azure-web-apps-nodejs.md?tabs=linux) | :x: |
39-
|Azure Functions - basic | [ :white_check_mark: :link: ](monitor-functions.md) ¹ | [ :white_check_mark: :link: ](monitor-functions.md) ¹ | [ :white_check_mark: :link: ](monitor-functions.md) ¹ | [ :white_check_mark: :link: ](monitor-functions.md) ¹ | [ :white_check_mark: :link: ](monitor-functions.md) ¹ |
40-
|Azure Functions - dependencies | :x: | :x: | [ :white_check_mark: :link: ](monitor-functions.md) | :x: | [ :white_check_mark: :link: ](monitor-functions.md#distributed-tracing-for-python-function-apps) |
39+
|Azure Functions - basic | [ :white_check_mark: :link: ](monitor-functions.md) ¹ | [ :white_check_mark: :link: ](monitor-functions.md) ¹ | [ :white_check_mark: :link: ](monitor-functions.md) ¹ | [ :white_check_mark: :link: ](monitor-functions.md) ¹ | [ :white_check_mark: :link: ](monitor-functions.md#distributed-tracing-for-python-function-apps) ¹ |
40+
|Azure Functions - dependencies | :x: | :x: | [ :white_check_mark: :link: ](monitor-functions.md) | :x: | :x: |
4141
|Azure Spring Apps | :x: | :x: | [ :white_check_mark: :link: ](../../spring-apps/enterprise/how-to-application-insights.md) | :x: | :x: |
4242
|Azure Kubernetes Service (AKS) | :x: | :x: | [ :white_check_mark: :link: ](opentelemetry-enable.md?tabs=java) | :x: | :x: |
4343
|Azure VMs Windows | [ :white_check_mark: :link: ](azure-vm-vmss-apps.md) ² ³ | [ :white_check_mark: :link: ](azure-vm-vmss-apps.md) ² ³ | [ :white_check_mark: :link: ](opentelemetry-enable.md?tabs=java) | :x: | :x: |

articles/azure-monitor/app/monitor-functions.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,35 @@ To view more data from your Node Azure Functions applications than is [collected
146146

147147
## Distributed tracing for Python function apps
148148

149-
To collect custom telemetry from services such as Redis, Memcached, and MongoDB, use the [OpenCensus Python extension](https://github.com/census-ecosystem/opencensus-python-extensions-azure) and [log your telemetry](../../azure-functions/functions-reference-python.md?tabs=azurecli-linux%2capplication-level#log-custom-telemetry). You can find the list of supported services in this [GitHub folder](https://github.com/census-instrumentation/opencensus-python/tree/master/contrib).
149+
To collect telemetry from services such as Requests, urllib3, httpx, PsycoPG2, and more, use the [Azure Monitor OpenTelemetry Distro](./opentelemetry-enable.md?tabs=python). Tracked incoming requests coming into your Python application hosted in Azure Functions will not be automatically correlated with telemetry being tracked within it. You can manually achieve trace correlation by extract the TraceContext directly as shown below:
150+
151+
<!-- TODO: Remove after Azure Functions implements this automatically -->
152+
153+
```python
154+
import azure.functions as func
155+
156+
from azure.monitor.opentelemetry import configure_azure_monitor
157+
from opentelemetry import trace
158+
from opentelemetry.propagate import extract
159+
160+
# Configure Azure monitor collection telemetry pipeline
161+
configure_azure_monitor()
162+
163+
def main(req: func.HttpRequest, context) -> func.HttpResponse:
164+
...
165+
# Store current TraceContext in dictionary format
166+
carrier = {
167+
"traceparent": context.trace_context.Traceparent,
168+
"tracestate": context.trace_context.Tracestate,
169+
}
170+
tracer = trace.get_tracer(__name__)
171+
# Start a span using the current context
172+
with tracer.start_as_current_span(
173+
"http_trigger_span",
174+
context=extract(carrier),
175+
):
176+
...
177+
```
150178

151179
## Next steps
152180

0 commit comments

Comments
 (0)