Azure Application Insights fixes (#4660)

Signed-off-by: Alice Gibbons <alice@diagrid.io>
This commit is contained in:
Alice Gibbons 2025-06-03 15:58:08 +02:00 committed by GitHub
parent 4638f8f3fa
commit 9faf5aedae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 35 additions and 26 deletions

View File

@ -6,42 +6,42 @@ weight: 1000
description: "How to push trace events to Azure Application Insights, using the OpenTelemetry Collector."
---
Dapr integrates with [OpenTelemetry (OTEL) Collector](https://github.com/open-telemetry/opentelemetry-collector) using the Zipkin API. This guide walks through an example using Dapr to push trace events to Azure Application Insights, using the OpenTelemetry Collector.
Dapr integrates with [OpenTelemetry (OTEL) Collector](https://github.com/open-telemetry/opentelemetry-collector) using the OpenTelemetry protocol (OTLP). This guide walks through an example using Dapr to push traces to Azure Application Insights, using the OpenTelemetry Collector.
## Prerequisites
- [Install Dapr on Kubernetes]({{< ref kubernetes >}})
- [Set up an App Insights resource](https://docs.microsoft.com/azure/azure-monitor/app/create-new-resource) and make note of your App Insights connection string.
- [Create an Application Insights resource](https://learn.microsoft.com/azure/azure-monitor/app/create-workspace-resource) and make note of your Application Insights connection string.
## Set up OTEL Collector to push to your App Insights instance
To push events to your App Insights instance, install the OTEL Collector to your Kubernetes cluster.
To push traces to your Application Insights instance, install the OpenTelemetry Collector on your Kubernetes cluster.
1. Check out the [`open-telemetry-collector-appinsights.yaml`](/docs/open-telemetry-collector/open-telemetry-collector-appinsights.yaml) file.
1. Download and inspect the [`open-telemetry-collector-appinsights.yaml`](/docs/open-telemetry-collector/open-telemetry-collector-appinsights.yaml) file.
1. Replace the `<CONNECTION_STRING>` placeholder with your App Insights connection string.
1. Apply the configuration with:
1. Deploy the OpenTelemetry Collector into the same namespace where your Dapr-enabled applications are running:
```sh
```sh
kubectl apply -f open-telemetry-collector-appinsights.yaml
```
## Set up Dapr to send trace to OTEL Collector
## Set up Dapr to send traces to the OpenTelemetry Collector
Set up a Dapr configuration file to turn on tracing and deploy a tracing exporter component that uses the OpenTelemetry Collector.
Create a Dapr configuration file to enable tracing and send traces to the OpenTelemetry Collector via [OTLP](https://opentelemetry.io/docs/specs/otel/protocol/).
1. Use this [`collector-config.yaml`](/docs/open-telemetry-collector/collector-config.yaml) file to create your own configuration.
1. Download and inspect the [`collector-config-otel.yaml`](/docs/open-telemetry-collector/collector-config-otel.yaml). Update the `namespace` and `otel.endpointAddress` values to align with the namespace where your Dapr-enabled applications and OpenTelemetry Collector are deployed.
1. Apply the configuration with:
1. Apply the configuration with:
```sh
kubectl apply -f collector-config.yaml
kubectl apply -f collector-config-otel.yaml
```
## Deploy your app with tracing
Apply the `appconfig` configuration by adding a `dapr.io/config` annotation to the container that you want to participate in the distributed tracing, as shown in the following example:
Apply the `tracing` configuration by adding a `dapr.io/config` annotation to the Dapr applications that you want to include in distributed tracing, as shown in the following example:
```yaml
apiVersion: apps/v1
@ -57,18 +57,18 @@ spec:
dapr.io/enabled: "true"
dapr.io/app-id: "MyApp"
dapr.io/app-port: "8080"
dapr.io/config: "appconfig"
dapr.io/config: "tracing"
```
{{% alert title="Note" color="primary" %}}
If you are using one of the Dapr tutorials, such as [distributed calculator](https://github.com/dapr/quickstarts/tree/master/tutorials/distributed-calculator), the `appconfig` configuration is already configured, so no additional settings are needed.
If you are using one of the Dapr tutorials, such as [distributed calculator](https://github.com/dapr/quickstarts/tree/master/tutorials/distributed-calculator), you will need to update the `appconfig` configuration to `tracing`.
{{% /alert %}}
You can register multiple tracing exporters at the same time, and the tracing logs are forwarded to all registered exporters.
That's it! There's no need to include any SDKs or instrument your application code. Dapr automatically handles the distributed tracing for you.
## View traces
## View traces
Deploy and run some applications. After a few minutes, you should see tracing logs appearing in your App Insights resource. You can also use the **Application Map** to examine the topology of your services, as shown below:

View File

@ -2,7 +2,7 @@ apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: appconfig
namespace: default
namespace: default # Your app namespace
spec:
tracing:
samplingRate: "1"

View File

@ -8,10 +8,13 @@ metadata:
data:
otel-collector-config: |
receivers:
zipkin:
endpoint: 0.0.0.0:9411
otlp:
protocols:
grpc:
endpoint: ${env:MY_POD_IP}:4317
extensions:
health_check:
endpoint: :13133
pprof:
endpoint: :1888
zpages:
@ -31,7 +34,7 @@ data:
extensions: [pprof, zpages, health_check]
pipelines:
traces:
receivers: [zipkin]
receivers: [otlp]
exporters: [azuremonitor,debug]
---
apiVersion: v1
@ -43,10 +46,10 @@ metadata:
component: otel-collector
spec:
ports:
- name: zipkin # Default endpoint for Zipkin receiver.
port: 9411
- name: otel # Default endpoint for OTEL receiver.
port: 4317
protocol: TCP
targetPort: 9411
targetPort: 4317
selector:
component: otel-collector
---
@ -70,7 +73,7 @@ spec:
spec:
containers:
- name: otel-collector
image: otel/opentelemetry-collector-contrib:0.101.0
image: otel/opentelemetry-collector-contrib:0.127.0
command:
- "/otelcol-contrib"
- "--config=/conf/otel-collector-config.yaml"
@ -82,7 +85,13 @@ spec:
cpu: 200m
memory: 400Mi
ports:
- containerPort: 9411 # Default endpoint for Zipkin receiver.
- containerPort: 4317 # Default endpoint for OTEL receiver.
env:
- name: MY_POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
volumeMounts:
- name: otel-collector-config-vol
mountPath: /conf

View File

@ -75,7 +75,7 @@ spec:
spec:
containers:
- name: otel-collector
image: otel/opentelemetry-collector-contrib-dev:latest
image: otel/opentelemetry-collector-contrib:0.127.0
command:
- "/otelcontribcol"
- "--config=/conf/otel-collector-config.yaml"

View File

@ -78,7 +78,7 @@ spec:
spec:
containers:
- name: otel-collector
image: otel/opentelemetry-collector-contrib-dev:latest
image: otel/opentelemetry-collector-contrib:0.127.0
command:
- "/otelcontribcol"
- "--config=/conf/otel-collector-config.yaml"