laitimes

.NET Framework services implement best practices for monitoring observability

author:Observe clouds

Environmental information

  • System Environment: Windows Server
  • 开发语言:.NET Framework >= 4.6.1
  • APM探针包:ddtrace

Preparation

Install Datakit

Host Deployment: https://docs.guance.com/datakit/datakit-install/

Open the Capture APM Collector

Windows host configuration

# 到如下路径,把ddtrace.conf.sample 拷贝一份命名为ddtrace.conf即可
C:\Program Files\datakit\conf.d\ddtrace
           

Access scheme

Modify local environment variables

Click on the computer right-click - Properties - Advanced System Settings - Environment Variables, create a new system variable, and enter the following:

DD_TRACE_AGENT_URL=http://localhost:9529    (必填)
DD_SERVICE=myapp   # 举例 myappname          (必填)
DD_ENV=test   # 举例 test                    (可选)
DD_VERSION=1.0   #举例 1.0                   /(可选)
DD_TRACE_SERVICE_MAPPING=  # 举例 mysql:main-mysql-db    (可选)
DD_LOGS_INJECTION=true    # 开启注入ddtrace日志(可选)
SET DD_RUNTIME_METRICS_ENABLED=true  # runtime 指标(可选)
           
  • TRACE_AGENT_URL: The IP address and port of data upload must be set to http://localhost:9529, and the actual port of DatKit must be entered
  • ENV: The system environment, which can be set to pro or test or other content according to your needs
  • SERVICE: the name of the application displayed on the platform, which can be set to the name of the specific service
  • VERSION: the version number, which can be set as needed
  • TRACE_SERVICE_MAPPING: Use the configuration to rename the service to distinguish it from other components called by other business systems on the observation cloud platform. Accept the mapping of the service name key to be renamed, and the name you want to use, in the format [from-key]:[to-name]Note: [from-key] content is a standard field, e.g. mysql, redis, mongodb, oracle, do not make custom changes Example: TRACE_SERVICE_MAPPING=mysql:main-mysql-db,TRACE_SERVICE_ MAPPING=mongodb:offsite-mongodb-service

As shown in the figure below, pay attention to the variables and variable values here, such as the above configuration of the equal sign is the key on the left and the value on the right.

.NET Framework services implement best practices for monitoring observability

Download Probes (Recommended Version 2.4.3)

  • x64 architecture: https://github.com/DataDog/dd-trace-dotnet/releases/download/v2.4.3/datadog-dotnet-apm-2.4.3-x64.msi
  • x86 architecture: https://github.com/DataDog/dd-trace-dotnet/releases/download/v2.4.3/datadog-dotnet-apm-2.4.3-x86.msi

Run the probe with administrator privileges

You must have administrator privileges to run the dotnet-agent installation package, click Next until the installation is successful.

.NET Framework services implement best practices for monitoring observability

Restart the IIS service for the configuration to take effect

Run the following command in PowerShell to restart iis:

net stop /y was
net start w3svc
           

DataKit machine

输入:datakit monitor

.NET Framework services implement best practices for monitoring observability

Practical effects

.NET Framework services implement best practices for monitoring observability
.NET Framework services implement best practices for monitoring observability

Read on