This commit is contained in:
Young Bu Park 2020-03-13 09:32:58 -07:00
parent 5ac90c94c3
commit 0be7f06ee1
1 changed files with 47 additions and 12 deletions

View File

@ -2,6 +2,8 @@
Dapr integrates with Application Insights through OpenTelemetry's default exporter along with a dedicated agent known as [Local Forwarder](https://docs.microsoft.com/en-us/azure/azure-monitor/app/opencensus-local-forwarder).
> Note: Local forwarder is still under preview, but being deprecated. Application insights team recommends to use [Opentelemetry collector](https://github.com/open-telemetry/opentelemetry-collector) (which is in alpha state) for the future so that we're working on moving from local forwarder to [Opentelemetry collector](https://github.com/open-telemetry/opentelemetry-collector).
## How to configure distributed tracing wit Application insights
The following steps will show you how to configure Dapr to send distributed tracing data to Application insights.
@ -23,10 +25,52 @@ The following steps will show you how to configure Dapr to send distributed trac
#### Local environment
1. Run localfowarder
```bash
docker run -e APPINSIGHTS_INSTRUMENTATIONKEY=<Your Instrumentation Key> -e APPINSIGHTS_LIVEMETRICSSTREAMAUTHENTICATIONAPIKEY=<Your API Key> -d -p 50001:50001 daprio/dapr-localforwarder:0.1-beta1
```
> Note: dapr-localforwarder is created by using [0.1-beta1 release](https://github.com/microsoft/ApplicationInsights-LocalForwarder/releases/tag/v0.1-beta1). If you want to create your own image, please use [this dockerfile](./localforwarder/Dockerfile).
1. Copy *tracing.yaml* to a *components* folder under the same folder where you run you application.
* native.yaml
```yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: native
spec:
type: exporters.native
metadata:
- name: enabled
value: "true"
- name: agentEndpoint
value: "localhost:5001"
```
* tracing.yaml
```yaml
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
name: tracing
spec:
tracing:
enabled: true
expandParams: true
includeBody: true
```
3. When running in the local mode, you need to launch Dapr with the `--config` parameter:
```bash
dapr run --app-id mynode --app-port 3000 --config ./tracing.yaml node app.js
```
#### Kubernetes environment
1. Download [dapr-localforwarder.yaml](./localforwarder/dapr-localforwarder.yaml)
@ -45,11 +89,7 @@ docker run -e APPINSIGHTS_INSTRUMENTATIONKEY=<Your Instrumentation Key> -e APPIN
kubectl apply -f ./dapr-localforwarder.yaml
```
### How to configure distributed tracing with Application insights
You'll need two YAML files - a Dapr configuration file that enables tracing, and a native export configuration file that configures the native exporter.
1. Create the following YAML files
4. Create the following YAML files
* native.yaml
@ -81,19 +121,14 @@ spec:
includeBody: true
```
2. When running under local mode, copy *tracing.yaml* to a *components* folder under the same folder where you run you application. When running under Kubernetes model, use kubectl to apply the above CRD files:
5. Use kubectl to apply the above CRD files:
```bash
kubectl apply -f tracing.yaml
kubectl apply -f native.yaml
```
3. When running in the local mode, you need to launch Dapr with the `--config` parameter:
```bash
dapr run --app-id mynode --app-port 3000 --config ./tracing.yaml node app.js
```
6. Deploy your app with tracing
When running in the Kubernetes model, you need to add a `dapr.io/config` annotation to your container that you want to participate in the distributed tracing, as shown in the following example:
```yaml