Commit b0d5a562 authored by Savorboard's avatar Savorboard Committed by Lemon

Add supports for CAP (#33)

* Remove unwanted package references.

* Add cap example configuration to sample project.

* Remove unwanted package references.

* Add supports project for CAP.

* Update samples.

* Removed unused tags label.

* Upgrade CAP nuget package to 2.2.2

* Remove unused tags config from processors.
parent 68b5c358
...@@ -14,7 +14,7 @@ namespace SkyWalking.Sample.Backend.Controllers ...@@ -14,7 +14,7 @@ namespace SkyWalking.Sample.Backend.Controllers
[HttpGet] [HttpGet]
public IEnumerable<string> Get() public IEnumerable<string> Get()
{ {
return new string[] {"value1", "value2"}; return new string[] { "value1", "value2" };
} }
// GET api/values/5 // GET api/values/5
...@@ -24,23 +24,5 @@ namespace SkyWalking.Sample.Backend.Controllers ...@@ -24,23 +24,5 @@ namespace SkyWalking.Sample.Backend.Controllers
var httpClient = new HttpClient(); var httpClient = new HttpClient();
return await httpClient.GetStringAsync("http://www.baidu.com"); return await httpClient.GetStringAsync("http://www.baidu.com");
} }
// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
} }
} }
\ No newline at end of file
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5002/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"SkyWalking.Sample.Backend": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5002/"
}
}
}
\ No newline at end of file
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" /> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
</ItemGroup> </ItemGroup>
......
using System; using Microsoft.AspNetCore.Builder;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using SkyWalking.AspNetCore; using SkyWalking.AspNetCore;
using SkyWalking.Diagnostics.CAP;
namespace SkyWalking.Sample.Backend namespace SkyWalking.Sample.Backend
{ {
...@@ -26,11 +21,17 @@ namespace SkyWalking.Sample.Backend ...@@ -26,11 +21,17 @@ namespace SkyWalking.Sample.Backend
{ {
services.AddMvc(); services.AddMvc();
//services.AddCap(x =>
//{
// x.UseKafka("192.168.10.110:9092");
// x.UseMySql("Server=192.168.10.110;Database=testcap;UserId=root;Password=123123;");
//});
services.AddSkyWalking(option => services.AddSkyWalking(option =>
{ {
option.DirectServers = "localhost:11800"; option.DirectServers = "localhost:11800";
option.ApplicationCode = "asp-net-core-backend"; option.ApplicationCode = "asp-net-core-backend";
}); });//.AddCap();
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...@@ -42,6 +43,8 @@ namespace SkyWalking.Sample.Backend ...@@ -42,6 +43,8 @@ namespace SkyWalking.Sample.Backend
} }
app.UseMvc(); app.UseMvc();
// app.UseCap();
} }
} }
} }
\ No newline at end of file
...@@ -13,32 +13,7 @@ namespace SkyWalking.Sample.Frontend.Controllers ...@@ -13,32 +13,7 @@ namespace SkyWalking.Sample.Frontend.Controllers
public async Task<IEnumerable<string>> Get() public async Task<IEnumerable<string>> Get()
{ {
await new HttpClient().GetAsync("http://localhost:5002/api/values"); await new HttpClient().GetAsync("http://localhost:5002/api/values");
return new string[] {"value1", "value2"}; return new string[] { "value1", "value2" };
}
// GET api/values/5
[HttpGet("{id}")]
public string Get(int id)
{
return "value";
}
// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
} }
} }
} }
\ No newline at end of file
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5001/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"SkyWalking.Sample.Frontend": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5001/"
}
}
}
\ No newline at end of file
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" /> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
</ItemGroup> </ItemGroup>
......
using System; using Microsoft.AspNetCore.Builder;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using SkyWalking.AspNetCore; using SkyWalking.AspNetCore;
namespace SkyWalking.Sample.Frontend namespace SkyWalking.Sample.Frontend
......
...@@ -22,23 +22,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{613F0980-9 ...@@ -22,23 +22,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{613F0980-9
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyWalking.Core.Tests", "test\SkyWalking.Core.Tests\SkyWalking.Core.Tests.csproj", "{3915A2C2-7174-4651-A4F1-D45CD109916A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyWalking.Core.Tests", "test\SkyWalking.Core.Tests\SkyWalking.Core.Tests.csproj", "{3915A2C2-7174-4651-A4F1-D45CD109916A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyWalking.NetworkProtocol.Trace", "src\SkyWalking.NetworkProtocol.Trace\SkyWalking.NetworkProtocol.Trace.csproj", "{50BE8184-EC7A-4257-AF54-764C0E61276F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyWalking.NetworkProtocol.Trace", "src\SkyWalking.NetworkProtocol.Trace\SkyWalking.NetworkProtocol.Trace.csproj", "{50BE8184-EC7A-4257-AF54-764C0E61276F}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{79ED86A5-E9B9-49B2-9354-C911C079D03E}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{79ED86A5-E9B9-49B2-9354-C911C079D03E}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyWalking.AspNetCore", "src\SkyWalking.AspNetCore\SkyWalking.AspNetCore.csproj", "{D75B68C5-6788-4871-A63F-F6EB48FB0DC5}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyWalking.AspNetCore", "src\SkyWalking.AspNetCore\SkyWalking.AspNetCore.csproj", "{D75B68C5-6788-4871-A63F-F6EB48FB0DC5}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{844CEACD-4C85-4B15-9E2B-892B01FDA4BB}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{844CEACD-4C85-4B15-9E2B-892B01FDA4BB}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyWalking.Sample.Backend", "sample\SkyWalking.Sample.Backend\SkyWalking.Sample.Backend.csproj", "{80A67B09-83F2-477F-907F-95FFF5B8FEAF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyWalking.Sample.Backend", "sample\SkyWalking.Sample.Backend\SkyWalking.Sample.Backend.csproj", "{80A67B09-83F2-477F-907F-95FFF5B8FEAF}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyWalking.Sample.Frontend", "sample\SkyWalking.Sample.Frontend\SkyWalking.Sample.Frontend.csproj", "{2B4E350E-A1E5-4B4A-A642-BCA6D3887E5A}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyWalking.Sample.Frontend", "sample\SkyWalking.Sample.Frontend\SkyWalking.Sample.Frontend.csproj", "{2B4E350E-A1E5-4B4A-A642-BCA6D3887E5A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyWalking.Diagnostics.HttpClient", "src\SkyWalking.Diagnostics.HttpClient\SkyWalking.Diagnostics.HttpClient.csproj", "{49DEFCA8-4289-4875-B6A5-35D84B3D2290}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyWalking.Diagnostics.HttpClient", "src\SkyWalking.Diagnostics.HttpClient\SkyWalking.Diagnostics.HttpClient.csproj", "{49DEFCA8-4289-4875-B6A5-35D84B3D2290}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyWalking.Extensions.DependencyInjection", "src\SkyWalking.Extensions.DependencyInjection\SkyWalking.Extensions.DependencyInjection.csproj", "{BF5579ED-113C-4EE6-AE03-9A9CA590C924}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyWalking.Extensions.DependencyInjection", "src\SkyWalking.Extensions.DependencyInjection\SkyWalking.Extensions.DependencyInjection.csproj", "{BF5579ED-113C-4EE6-AE03-9A9CA590C924}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyWalking.Diagnostics.CAP", "src\SkyWalking.Diagnostics.CAP\SkyWalking.Diagnostics.CAP.csproj", "{55621423-19C3-4928-8B45-666FA87BF6A2}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
...@@ -86,23 +88,28 @@ Global ...@@ -86,23 +88,28 @@ Global
{BF5579ED-113C-4EE6-AE03-9A9CA590C924}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF5579ED-113C-4EE6-AE03-9A9CA590C924}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF5579ED-113C-4EE6-AE03-9A9CA590C924}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF5579ED-113C-4EE6-AE03-9A9CA590C924}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF5579ED-113C-4EE6-AE03-9A9CA590C924}.Release|Any CPU.Build.0 = Release|Any CPU {BF5579ED-113C-4EE6-AE03-9A9CA590C924}.Release|Any CPU.Build.0 = Release|Any CPU
{55621423-19C3-4928-8B45-666FA87BF6A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55621423-19C3-4928-8B45-666FA87BF6A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55621423-19C3-4928-8B45-666FA87BF6A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55621423-19C3-4928-8B45-666FA87BF6A2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{3915A2C2-7174-4651-A4F1-D45CD109916A} = {613F0980-91ED-4064-8E8C-168582EF4AD7} {54B9183A-928B-43E1-9851-10E2F1CCE61C} = {CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810}
{79ED86A5-E9B9-49B2-9354-C911C079D03E} = {05BF0D4E-C824-4EC8-8330-36C1FC49910E}
{CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810} = {05BF0D4E-C824-4EC8-8330-36C1FC49910E}
{C3860B5F-21D0-429F-8A00-B0C0F4573DF7} = {CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810} {C3860B5F-21D0-429F-8A00-B0C0F4573DF7} = {CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810}
{FD84A10C-C962-4AEA-BA06-86F08EB048E6} = {CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810} {FD84A10C-C962-4AEA-BA06-86F08EB048E6} = {CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810}
{54B9183A-928B-43E1-9851-10E2F1CCE61C} = {CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810} {3915A2C2-7174-4651-A4F1-D45CD109916A} = {613F0980-91ED-4064-8E8C-168582EF4AD7}
{50BE8184-EC7A-4257-AF54-764C0E61276F} = {CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810} {50BE8184-EC7A-4257-AF54-764C0E61276F} = {CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810}
{79ED86A5-E9B9-49B2-9354-C911C079D03E} = {05BF0D4E-C824-4EC8-8330-36C1FC49910E}
{CBFF7EE0-69D7-4D6A-9BBD-8E567FF4D810} = {05BF0D4E-C824-4EC8-8330-36C1FC49910E}
{D75B68C5-6788-4871-A63F-F6EB48FB0DC5} = {79ED86A5-E9B9-49B2-9354-C911C079D03E} {D75B68C5-6788-4871-A63F-F6EB48FB0DC5} = {79ED86A5-E9B9-49B2-9354-C911C079D03E}
{80A67B09-83F2-477F-907F-95FFF5B8FEAF} = {844CEACD-4C85-4B15-9E2B-892B01FDA4BB} {80A67B09-83F2-477F-907F-95FFF5B8FEAF} = {844CEACD-4C85-4B15-9E2B-892B01FDA4BB}
{2B4E350E-A1E5-4B4A-A642-BCA6D3887E5A} = {844CEACD-4C85-4B15-9E2B-892B01FDA4BB} {2B4E350E-A1E5-4B4A-A642-BCA6D3887E5A} = {844CEACD-4C85-4B15-9E2B-892B01FDA4BB}
{49DEFCA8-4289-4875-B6A5-35D84B3D2290} = {79ED86A5-E9B9-49B2-9354-C911C079D03E} {49DEFCA8-4289-4875-B6A5-35D84B3D2290} = {79ED86A5-E9B9-49B2-9354-C911C079D03E}
{BF5579ED-113C-4EE6-AE03-9A9CA590C924} = {79ED86A5-E9B9-49B2-9354-C911C079D03E} {BF5579ED-113C-4EE6-AE03-9A9CA590C924} = {79ED86A5-E9B9-49B2-9354-C911C079D03E}
{55621423-19C3-4928-8B45-666FA87BF6A2} = {79ED86A5-E9B9-49B2-9354-C911C079D03E}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {94C0DA2C-CCCB-4314-93A2-9809B5DD0583} SolutionGuid = {94C0DA2C-CCCB-4314-93A2-9809B5DD0583}
......
...@@ -15,7 +15,4 @@ ...@@ -15,7 +15,4 @@
<ProjectReference Include="..\SkyWalking.NetworkProtocol.Trace\SkyWalking.NetworkProtocol.Trace.csproj" /> <ProjectReference Include="..\SkyWalking.NetworkProtocol.Trace\SkyWalking.NetworkProtocol.Trace.csproj" />
<ProjectReference Include="..\SkyWalking.NetworkProtocol\SkyWalking.NetworkProtocol.csproj" /> <ProjectReference Include="..\SkyWalking.NetworkProtocol\SkyWalking.NetworkProtocol.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
</ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -26,39 +26,39 @@ namespace SkyWalking.Context.Tag ...@@ -26,39 +26,39 @@ namespace SkyWalking.Context.Tag
{ {
public static readonly StringTag Url = new StringTag("url"); public static readonly StringTag Url = new StringTag("url");
/** /// <summary>
* STATUS_CODE records the http status code of the response. /// STATUS_CODE records the http status code of the response.
*/ /// </summary>
public static readonly StringTag StatusCode = new StringTag("status_code"); public static readonly StringTag StatusCode = new StringTag("status_code");
/** /// <summary>
* DB_TYPE records database type, such as sql, redis, cassandra and so on. /// DB_TYPE records database type, such as sql, redis, cassandra and so on.
*/ /// </summary>
public static readonly StringTag DbType = new StringTag("db.type"); public static readonly StringTag DbType = new StringTag("db.type");
/** /// <summary>
* DB_INSTANCE records database instance name. /// DB_INSTANCE records database instance name.
*/ /// </summary>
public static readonly StringTag DbInstance = new StringTag("db.instance"); public static readonly StringTag DbInstance = new StringTag("db.instance");
/** /// <summary>
* DB_STATEMENT records the sql statement of the database access. /// DB_STATEMENT records the sql statement of the database access.
*/ /// </summary>
public static readonly StringTag DbStatement = new StringTag("db.statement"); public static readonly StringTag DbStatement = new StringTag("db.statement");
/** /// <summary>
* DB_BIND_VARIABLES records the bind variables of sql statement. /// DB_BIND_VARIABLES records the bind variables of sql statement.
*/ /// </summary>
public static readonly StringTag DbBindVariables = new StringTag("db.bind_vars"); public static readonly StringTag DbBindVariables = new StringTag("db.bind_vars");
/** /// <summary>
* MQ_BROKER records the broker address of message-middleware /// MQ_BROKER records the broker address of message-middleware
*/ /// </summary>
public static readonly StringTag MqBorker = new StringTag("mq.broker"); public static readonly StringTag MqBorker = new StringTag("mq.broker");
/** /// <summary>
* MQ_TOPIC records the topic name of message-middleware /// MQ_TOPIC records the topic name of message-middleware
*/ /// </summary>
public static readonly StringTag MqTopic = new StringTag("mq.topic"); public static readonly StringTag MqTopic = new StringTag("mq.topic");
public static class HTTP public static class HTTP
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
<ProjectReference Include="..\SkyWalking.Abstractions\SkyWalking.Abstractions.csproj" /> <ProjectReference Include="..\SkyWalking.Abstractions\SkyWalking.Abstractions.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.0.0-pre-05" /> <PackageReference Include="Nito.AsyncEx.Coordination" Version="5.0.0-pre-05" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.4.1" /> <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.4.1" />
</ItemGroup> </ItemGroup>
......
/*
* Licensed to the OpenSkywalking under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using DotNetCore.CAP.Diagnostics;
using DotNetCore.CAP.Infrastructure;
using Microsoft.Extensions.DiagnosticAdapter;
using SkyWalking.Context;
using SkyWalking.Context.Tag;
using SkyWalking.Context.Trace;
using SkyWalking.NetworkProtocol.Trace;
using CapEvents = DotNetCore.CAP.Diagnostics.CapDiagnosticListenerExtensions;
namespace SkyWalking.Diagnostics.CAP
{
/// <summary>
/// Diagnostics processor for listen and process releted events of CAP.
/// </summary>
public class CapDiagnosticProcessor : ITracingDiagnosticProcessor
{
private Func<BrokerEventData, string> _brokerOperationNameResolver;
public string ListenerName => CapEvents.DiagnosticListenerName;
public Func<BrokerEventData, string> BrokerOperationNameResolver
{
get
{
return _brokerOperationNameResolver ??
(_brokerOperationNameResolver = (data) => "CAP " + data.BrokerTopicName);
}
set => _brokerOperationNameResolver = value ?? throw new ArgumentNullException(nameof(BrokerOperationNameResolver));
}
[DiagnosticName(CapEvents.CapBeforePublish)]
public void CapBeforePublish(BrokerPublishEventData eventData)
{
var operationName = BrokerOperationNameResolver(eventData);
var contextCarrier = new ContextCarrier();
var peer = eventData.BrokerAddress;
var span = ContextManager.CreateExitSpan(operationName, contextCarrier, peer);
span.SetComponent(ComponentsDefine.CAP);
span.SetLayer(SpanLayer.MQ);
span.Tag(Tags.MqTopic.Key, eventData.BrokerTopicName);
foreach (var item in contextCarrier.Items)
{
eventData.Headers.Add(item.HeadKey, item.HeadValue);
}
}
[DiagnosticName(CapEvents.CapAfterPublish)]
public void CapAfterPublish(BrokerPublishEndEventData eventData)
{
ContextManager.StopSpan();
}
[DiagnosticName(CapEvents.CapErrorPublish)]
public void CapErrorPublish(BrokerPublishErrorEventData eventData)
{
var capSpan = ContextManager.ActiveSpan;
if (capSpan == null)
{
return;
}
capSpan.Log(eventData.Exception);
capSpan.ErrorOccurred();
ContextManager.StopSpan(capSpan);
}
[DiagnosticName(CapEvents.CapBeforeConsume)]
public void CapBeforeConsume(BrokerConsumeEventData eventData)
{
var operationName = BrokerOperationNameResolver(eventData);
var carrier = new ContextCarrier();
if (Helper.TryExtractTracingHeaders(eventData.BrokerTopicBody, out var headers,
out var removedHeadersJson))
{
eventData.Headers = headers;
eventData.BrokerTopicBody = removedHeadersJson;
foreach (var tracingHeader in headers)
{
foreach (var item in carrier.Items)
{
if (tracingHeader.Key == item.HeadKey)
{
item.HeadValue = tracingHeader.Value;
}
}
}
}
var span = ContextManager.CreateEntrySpan(operationName, carrier);
span.SetComponent(ComponentsDefine.CAP);
span.SetLayer(SpanLayer.MQ);
span.Tag(Tags.MqTopic.Key, eventData.BrokerTopicName);
}
[DiagnosticName(CapEvents.CapAfterConsume)]
public void CapAfterConsume(BrokerConsumeEndEventData eventData)
{
var capSpan = ContextManager.ActiveSpan;
if (capSpan == null)
{
return;
}
ContextManager.StopSpan(capSpan);
}
[DiagnosticName(CapEvents.CapErrorConsume)]
public void CapErrorConsume(BrokerConsumeErrorEventData eventData)
{
var capSpan = ContextManager.ActiveSpan;
if (capSpan == null)
{
return;
}
capSpan.Log(eventData.Exception);
capSpan.ErrorOccurred();
ContextManager.StopSpan(capSpan);
}
[DiagnosticName(CapEvents.CapBeforeSubscriberInvoke)]
public void CapBeforeSubscriberInvoke(SubscriberInvokeEventData eventData)
{
var span = ContextManager.CreateLocalSpan("Subscriber invoke");
span.SetComponent(ComponentsDefine.CAP);
span.Tag("subscriber.name", eventData.MethodName);
}
[DiagnosticName(CapEvents.CapAfterSubscriberInvoke)]
public void CapAfterSubscriberInvoke(SubscriberInvokeEventData eventData)
{
ContextManager.StopSpan();
}
[DiagnosticName(CapEvents.CapErrorSubscriberInvoke)]
public void CapErrorSubscriberInvoke(SubscriberInvokeErrorEventData eventData)
{
var capSpan = ContextManager.ActiveSpan;
if (capSpan == null)
{
return;
}
capSpan.Log(eventData.Exception);
capSpan.ErrorOccurred();
ContextManager.StopSpan(capSpan);
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Description>SkyWalking.Diagnostics.CAP notifies of CAP messages.</Description>
<AssemblyTitle>SkyWalking.Diagnostics.CAP</AssemblyTitle>
<AssemblyName>SkyWalking.Diagnostics.CAP</AssemblyName>
<PackageId>SkyWalking.Diagnostics.CAP</PackageId>
<PackageTags>SkyWalking;APM;CAP</PackageTags>
<RootNamespace>SkyWalking.Diagnostics.CAP</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNetCore.CAP" Version="2.2.2" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.1.0-preview2-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SkyWalking.Abstractions\SkyWalking.Abstractions.csproj" />
<ProjectReference Include="..\SkyWalking.Core\SkyWalking.Core.csproj" />
<ProjectReference Include="..\SkyWalking.Extensions.DependencyInjection\SkyWalking.Extensions.DependencyInjection.csproj" />
</ItemGroup>
</Project>
/*
* Licensed to the OpenSkywalking under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using Microsoft.Extensions.DependencyInjection;
using SkyWalking.Extensions.DependencyInjection;
namespace SkyWalking.Diagnostics.CAP
{
public static class SkyWalkingBuilderExtensions
{
public static SkyWalkingBuilder AddCap(this SkyWalkingBuilder builder)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
builder.Services.AddSingleton<ITracingDiagnosticProcessor, CapDiagnosticProcessor>();
return builder;
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<Description>SkyWalking.Diagnostics.HttpClient notifies outgoing Http requests.</Description> <Description>SkyWalking.Diagnostics.HttpClient notifies outgoing Http requests.</Description>
<AssemblyTitle>SkyWalking.Diagnostics.HttpClient</AssemblyTitle> <AssemblyTitle>SkyWalking.Diagnostics.HttpClient</AssemblyTitle>
...@@ -11,10 +12,11 @@ ...@@ -11,10 +12,11 @@
</PackageReleaseNotes> </PackageReleaseNotes>
<RootNamespace>SkyWalking.Diagnostics.HttpClient</RootNamespace> <RootNamespace>SkyWalking.Diagnostics.HttpClient</RootNamespace>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.1.0-preview2-final" /> <PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.1.0-preview2-final" />
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SkyWalking.Abstractions\SkyWalking.Abstractions.csproj" /> <ProjectReference Include="..\SkyWalking.Abstractions\SkyWalking.Abstractions.csproj" />
<ProjectReference Include="..\SkyWalking.Core\SkyWalking.Core.csproj" /> <ProjectReference Include="..\SkyWalking.Core\SkyWalking.Core.csproj" />
......
...@@ -16,6 +16,5 @@ ...@@ -16,6 +16,5 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -10,7 +10,4 @@ ...@@ -10,7 +10,4 @@
<PackageReleaseNotes> <PackageReleaseNotes>
</PackageReleaseNotes> </PackageReleaseNotes>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
</ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -15,6 +15,5 @@ ...@@ -15,6 +15,5 @@
<PackageReference Include="Google.Protobuf.Tools" Version="3.5.1" /> <PackageReference Include="Google.Protobuf.Tools" Version="3.5.1" />
<PackageReference Include="Grpc" Version="1.9.0" /> <PackageReference Include="Grpc" Version="1.9.0" />
<PackageReference Include="Grpc.Tools" Version="1.9.0" /> <PackageReference Include="Grpc.Tools" Version="1.9.0" />
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment