一、项目中导入包“SkyAPM.Agent.AspNetCore”
二、在服务中找到“Properties”,点开“launchSettings.json”文件,并在“environmentVariables”属性中添加
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "SkyAPM.Agent.AspNetCore", //必须配置
三、找到项目中的skyapm.json文件
skyapm配置文件夹中,将ServiceName属性的值更改为服务的名称
如果是配置在“environmentVariables”属性中,就应该是配置在“SKYWALKING__SERVICENAME”属性中:
"SKYWALKING__SERVICENAME": "RManagement.API" // 必须配置,在skywalking做标识,服务名称
完整的配置应该是:
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:25417",
"sslPort": 44337
}
},
"profiles": {
"RManagement.API": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "SkyAPM.Agent.AspNetCore", //必须配置
"SKYWALKING__SERVICENAME": "RManagement.API" // 必须配置,在skywalking做标识,服务名称
},
//"applicationUrl": "http://localhost:9915;http://localhost:9914",
"dotnetRunMessages": true
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "SkyAPM.Agent.AspNetCore"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/weatherforecast",
"publishAllPorts": true,
"useSSL": true
}
}
}