Using OpenTelemetry Collector to collect traces to send to AppInsights

How to push trace events to Azure Application Insights, using the OpenTelemetry Collector.

Dapr integrates with 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.

必备条件

A installation of Dapr on Kubernetes.

How to configure distributed tracing with Application Insights

Setup Application Insights

  1. First, you’ll need an Azure account. See instructions here to apply for a free Azure account.
  2. Follow instructions here to create a new Application Insights resource.
  3. Get the Application Insights Intrumentation key from your Application Insights page.

Run OpenTelemetry Collector to push to your Application Insights instance

Install the OpenTelemetry Collector to your Kubernetes cluster to push events to your Application Insights instance

  1. Check out the file open-telemetry-collector-appinsights.yaml and replace the <INSTRUMENTATION-KEY> placeholder with your Application Insights Instrumentation Key.

  2. Apply the configuration with kubectl apply -f open-telemetry-collector-appinsights.yaml.

Next, set up both a Dapr configuration file to turn on tracing and deploy a tracing exporter component that uses the OpenTelemetry Collector.

  1. 创建具有此内容的 collector-config.yaml 文件

  2. 使用 kubectl apply -f collector-config.yaml来应用配置

部署你的应用,并启用应用痕迹跟踪功能

When running in Kubernetes mode, 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:

apiVersion: apps/v1
kind: Deployment
metadata:
  ...
spec:
  ...
  template:
    metadata:
      ...
      annotations:
        dapr.io/enabled: "true"
        dapr.io/app-id: "MyApp"
        dapr.io/app-port: "8080"
        dapr.io/config: "appconfig"

Some of the quickstarts such as distributed calculator already configure these settings, so if you are using those no additional settings are needed.

That’s it! There’s no need include any SDKs or instrument your application code. Dapr automatically handles the distributed tracing for you.

备注: 您可以同时注册多个的应用痕迹跟踪导出器,并且跟踪日志转发到所有已注册的导出器中。

Deploy and run some applications. After a few minutes, you should see tracing logs appearing in your Application Insights resource. You can also use the Application Map to examine the topology of your services, as shown below:

Application map

NOTE: Only operations going through Dapr API exposed by Dapr sidecar (e.g. service invocation or event publishing) are displayed in Application Map topology.

相关链接

Last modified January 1, 0001