Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SkyAPM
SkyAPM-dotnet
提交
b08027d4
S
SkyAPM-dotnet
项目概览
SkyAPM
/
SkyAPM-dotnet
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyAPM-dotnet
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b08027d4
编写于
1月 20, 2020
作者:
J
James Yeung
提交者:
Savorboard
1月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor hosting (#278)
上级
4b5809d7
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
395 addition
and
503 deletion
+395
-503
sample/SkyApm.Sample.Backend/Program.cs
sample/SkyApm.Sample.Backend/Program.cs
+13
-2
sample/SkyApm.Sample.Backend/SkyApm.Sample.Backend.csproj
sample/SkyApm.Sample.Backend/SkyApm.Sample.Backend.csproj
+7
-3
sample/SkyApm.Sample.Backend/Startup.cs
sample/SkyApm.Sample.Backend/Startup.cs
+26
-4
sample/SkyApm.Sample.Frontend/Controllers/ValuesController.cs
...le/SkyApm.Sample.Frontend/Controllers/ValuesController.cs
+15
-7
sample/SkyApm.Sample.Frontend/Program.cs
sample/SkyApm.Sample.Frontend/Program.cs
+14
-6
sample/SkyApm.Sample.Frontend/SkyApm.Sample.Frontend.csproj
sample/SkyApm.Sample.Frontend/SkyApm.Sample.Frontend.csproj
+7
-6
sample/SkyApm.Sample.Frontend/Startup.cs
sample/SkyApm.Sample.Frontend/Startup.cs
+17
-2
sample/SkyApm.Sample.GenericHost/Program.cs
sample/SkyApm.Sample.GenericHost/Program.cs
+3
-4
sample/SkyApm.Sample.GenericHost/SkyApm.Sample.GenericHost.csproj
...kyApm.Sample.GenericHost/SkyApm.Sample.GenericHost.csproj
+26
-0
sample/SkyApm.Sample.GenericHost/Worker.cs
sample/SkyApm.Sample.GenericHost/Worker.cs
+1
-1
sample/SkyApm.Sample.GenericHost/skyapm.json
sample/SkyApm.Sample.GenericHost/skyapm.json
+1
-1
sample/grpc/SkyApm.Sample.GrpcServer/Program.cs
sample/grpc/SkyApm.Sample.GrpcServer/Program.cs
+0
-1
sample/grpc/SkyApm.Sample.GrpcServer/SkyApm.Sample.GrpcServer.csproj
.../SkyApm.Sample.GrpcServer/SkyApm.Sample.GrpcServer.csproj
+7
-7
skyapm-dotnet.sln
skyapm-dotnet.sln
+22
-15
src/SkyApm.Agent.AspNetCore/HostingEnvironmentProvider.cs
src/SkyApm.Agent.AspNetCore/HostingEnvironmentProvider.cs
+0
-50
src/SkyApm.Agent.AspNetCore/InstrumentationHostedService.cs
src/SkyApm.Agent.AspNetCore/InstrumentationHostedService.cs
+0
-44
src/SkyApm.Agent.AspNetCore/SkyApm.Agent.AspNetCore.csproj
src/SkyApm.Agent.AspNetCore/SkyApm.Agent.AspNetCore.csproj
+1
-19
src/SkyApm.Agent.AspNetCore/SkyApmHostingStartup.cs
src/SkyApm.Agent.AspNetCore/SkyApmHostingStartup.cs
+3
-1
src/SkyApm.Agent.GeneralHost/Extensions/ServiceCollectionExtensions.cs
...ent.GeneralHost/Extensions/ServiceCollectionExtensions.cs
+0
-118
src/SkyApm.Agent.GeneralHost/SkyApm.Agent.GeneralHost.csproj
src/SkyApm.Agent.GeneralHost/SkyApm.Agent.GeneralHost.csproj
+17
-35
src/SkyApm.Agent.Hosting/Extensions/HostBuilderExtensions.cs
src/SkyApm.Agent.Hosting/Extensions/HostBuilderExtensions.cs
+3
-3
src/SkyApm.Agent.Hosting/Extensions/ServiceCollectionExtensions.cs
...m.Agent.Hosting/Extensions/ServiceCollectionExtensions.cs
+124
-119
src/SkyApm.Agent.Hosting/HostingEnvironmentProvider.cs
src/SkyApm.Agent.Hosting/HostingEnvironmentProvider.cs
+9
-12
src/SkyApm.Agent.Hosting/InstrumentationHostedService.cs
src/SkyApm.Agent.Hosting/InstrumentationHostedService.cs
+43
-43
src/SkyApm.Agent.Hosting/SkyApm.Agent.Hosting.csproj
src/SkyApm.Agent.Hosting/SkyApm.Agent.Hosting.csproj
+36
-0
未找到文件。
sample/SkyApm.Sample.Backend/Program.cs
浏览文件 @
b08027d4
using
Microsoft.AspNetCore
.Hosting
;
using
Microsoft.AspNetCore
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
namespace
SkyApm.Sample.Backend
namespace
SkyApm.Sample.Backend
{
{
...
@@ -8,7 +9,15 @@ namespace SkyApm.Sample.Backend
...
@@ -8,7 +9,15 @@ namespace SkyApm.Sample.Backend
public
static
void
Main
(
string
[]
args
)
public
static
void
Main
(
string
[]
args
)
{
{
BuildHost
(
args
).
Run
();
BuildHost
(
args
).
Run
();
}
}
#if NETCOREAPP2_1
public
static
IWebHost
BuildHost
(
string
[]
args
)
=>
WebHost
.
CreateDefaultBuilder
<
Startup
>(
args
)
.
Build
();
#else
public
static
IHost
BuildHost
(
string
[]
args
)
=>
public
static
IHost
BuildHost
(
string
[]
args
)
=>
Host
.
CreateDefaultBuilder
(
args
)
Host
.
CreateDefaultBuilder
(
args
)
...
@@ -16,5 +25,7 @@ namespace SkyApm.Sample.Backend
...
@@ -16,5 +25,7 @@ namespace SkyApm.Sample.Backend
{
{
builder
.
UseStartup
<
Startup
>();
builder
.
UseStartup
<
Startup
>();
}).
Build
();
}).
Build
();
#endif
}
}
}
}
\ No newline at end of file
sample/SkyApm.Sample.Backend/SkyApm.Sample.Backend.csproj
浏览文件 @
b08027d4
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<PropertyGroup>
<TargetFramework
>netcoreapp3.1</TargetFramework
>
<TargetFramework
s>netcoreapp2.1;netcoreapp3.1</TargetFrameworks
>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
...
@@ -11,11 +11,15 @@
...
@@ -11,11 +11,15 @@
<ProjectReference Include="..\grpc\SkyApm.Sample.GrpcProto\SkyApm.Sample.GrpcProto.csproj" />
<ProjectReference Include="..\grpc\SkyApm.Sample.GrpcProto\SkyApm.Sample.GrpcProto.csproj" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.26.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite">
<Version>3.1.0</Version>
<Version>3.1.0</Version>
</PackageReference>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Grpc.AspNetCore" Version="2.26.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0" PrivateAssets="All" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<Content Update="appsettings.json">
...
...
sample/SkyApm.Sample.Backend/Startup.cs
浏览文件 @
b08027d4
...
@@ -10,6 +10,12 @@ using SkyApm.Sample.Backend.Services;
...
@@ -10,6 +10,12 @@ using SkyApm.Sample.Backend.Services;
using
SkyApm.Sample.GrpcServer
;
using
SkyApm.Sample.GrpcServer
;
using
SkyApm.Tracing
;
using
SkyApm.Tracing
;
#if NETCOREAPP2_1
using
IHostEnvironment
=
Microsoft
.
Extensions
.
Hosting
.
IHostingEnvironment
;
#endif
namespace
SkyApm.Sample.Backend
namespace
SkyApm.Sample.Backend
{
{
public
class
Startup
public
class
Startup
...
@@ -24,7 +30,14 @@ namespace SkyApm.Sample.Backend
...
@@ -24,7 +30,14 @@ namespace SkyApm.Sample.Backend
// This method gets called by the runtime. Use this method to add services to the container.
// This method gets called by the runtime. Use this method to add services to the container.
public
void
ConfigureServices
(
IServiceCollection
services
)
public
void
ConfigureServices
(
IServiceCollection
services
)
{
{
services
.
AddControllers
();
#if NETCOREAPP2_1
services
.
AddMvc
();
#else
services
.
AddControllers
();
#endif
var
sqlLiteConnection
=
new
SqliteConnection
(
"DataSource=:memory:"
);
var
sqlLiteConnection
=
new
SqliteConnection
(
"DataSource=:memory:"
);
sqlLiteConnection
.
Open
();
sqlLiteConnection
.
Open
();
...
@@ -35,7 +48,10 @@ namespace SkyApm.Sample.Backend
...
@@ -35,7 +48,10 @@ namespace SkyApm.Sample.Backend
// DI grpc service
// DI grpc service
services
.
AddSingleton
<
GreeterGrpcService
>();
services
.
AddSingleton
<
GreeterGrpcService
>();
#if !NETCOREAPP2_1
services
.
AddGrpc
();
services
.
AddGrpc
();
#endif
}
}
// 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.
...
@@ -46,10 +62,15 @@ namespace SkyApm.Sample.Backend
...
@@ -46,10 +62,15 @@ namespace SkyApm.Sample.Backend
app
.
UseDeveloperExceptionPage
();
app
.
UseDeveloperExceptionPage
();
}
}
using
var
scope
=
app
.
ApplicationServices
.
CreateScope
();
using
(
var
scope
=
app
.
ApplicationServices
.
CreateScope
())
using
var
sampleDbContext
=
scope
.
ServiceProvider
.
GetService
<
SampleDbContext
>();
using
(
var
sampleDbContext
=
scope
.
ServiceProvider
.
GetService
<
SampleDbContext
>())
sampleDbContext
.
Database
.
EnsureCreated
();
{
sampleDbContext
.
Database
.
EnsureCreated
();
}
#if NETCOREAPP2_1
app
.
UseMvcWithDefaultRoute
();
#else
app
.
UseRouting
();
app
.
UseRouting
();
app
.
UseEndpoints
(
endpoint
=>
app
.
UseEndpoints
(
endpoint
=>
...
@@ -57,6 +78,7 @@ namespace SkyApm.Sample.Backend
...
@@ -57,6 +78,7 @@ namespace SkyApm.Sample.Backend
endpoint
.
MapDefaultControllerRoute
();
endpoint
.
MapDefaultControllerRoute
();
endpoint
.
MapGrpcService
<
GreeterImpl
>();
endpoint
.
MapGrpcService
<
GreeterImpl
>();
});
});
#endif
}
}
}
}
}
}
\ No newline at end of file
sample/SkyApm.Sample.Frontend/Controllers/ValuesController.cs
浏览文件 @
b08027d4
...
@@ -3,10 +3,15 @@ using System.Collections.Generic;
...
@@ -3,10 +3,15 @@ using System.Collections.Generic;
using
System.Net.Http
;
using
System.Net.Http
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Grpc.Net.Client
;
using
GrpcGreeter
;
using
GrpcGreeter
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
SkyApm.Sample.Backend.Services
;
using
SkyApm.Sample.Backend.Services
;
#if NETCOREAPP2_1
#else
using
Grpc.Net.Client
;
#endif
namespace
SkyApm.Sample.Frontend.Controllers
namespace
SkyApm.Sample.Frontend.Controllers
{
{
...
@@ -61,16 +66,19 @@ namespace SkyApm.Sample.Frontend.Controllers
...
@@ -61,16 +66,19 @@ namespace SkyApm.Sample.Frontend.Controllers
return
Ok
(
message
);
return
Ok
(
message
);
}
}
#if NETCOREAPP2_1
#else
[
HttpGet
(
"greeter/grpc-net"
)]
[
HttpGet
(
"greeter/grpc-net"
)]
public
async
Task
<
IActionResult
>
GrpcNetAsync
(
string
name
)
public
async
Task
<
IActionResult
>
GrpcNetAsync
(
string
name
)
{
{
const
string
Switch_AllowUnencryptedHttp2
=
"System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport"
;
const
string
Switch_AllowUnencryptedHttp2
=
"System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport"
;
AppContext
.
SetSwitch
(
Switch_AllowUnencryptedHttp2
,
true
);
AppContext
.
SetSwitch
(
Switch_AllowUnencryptedHttp2
,
true
);
var
channel
=
GrpcChannel
.
ForAddress
(
"http://localhost:5003"
);
var
channel
=
GrpcChannel
.
ForAddress
(
"http://localhost:5003"
);
var
client
=
new
Greeter
.
GreeterClient
(
channel
);
var
client
=
new
Greeter
.
GreeterClient
(
channel
);
var
result
=
await
client
.
SayHelloAsync
(
new
HelloRequest
()
{
Name
=
name
});
var
result
=
await
client
.
SayHelloAsync
(
new
HelloRequest
()
{
Name
=
name
});
return
Ok
(
result
);
return
Ok
(
result
);
}
}
#endif
}
}
}
}
\ No newline at end of file
sample/SkyApm.Sample.Frontend/Program.cs
浏览文件 @
b08027d4
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
namespace
SkyApm.Sample.Frontend
namespace
SkyApm.Sample.Frontend
...
@@ -10,14 +11,21 @@ namespace SkyApm.Sample.Frontend
...
@@ -10,14 +11,21 @@ namespace SkyApm.Sample.Frontend
BuildHost
(
args
).
Run
();
BuildHost
(
args
).
Run
();
}
}
#if NETCOREAPP2_1
public
static
IWebHost
BuildHost
(
string
[]
args
)
=>
WebHost
.
CreateDefaultBuilder
<
Startup
>(
args
)
.
Build
();
#else
public
static
IHost
BuildHost
(
string
[]
args
)
=>
public
static
IHost
BuildHost
(
string
[]
args
)
=>
Host
.
CreateDefaultBuilder
(
args
)
Host
.
CreateDefaultBuilder
(
args
)
.
ConfigureWebHostDefaults
(
builder
=>
.
ConfigureWebHostDefaults
(
builder
=>
{
{
builder
builder
.
UseStartup
<
Startup
>();
.
UseStartup
<
Startup
>()
}).
Build
();
.
UseUrls
(
"http://*:5001"
);
})
#endif
.
Build
();
}
}
}
}
\ No newline at end of file
sample/SkyApm.Sample.Frontend/SkyApm.Sample.Frontend.csproj
浏览文件 @
b08027d4
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<PropertyGroup>
<TargetFramework
>netcoreapp3.1</TargetFramework
>
<TargetFramework
s>netcoreapp2.1;netcoreapp3.1</TargetFrameworks
>
<RootNamespace>SkyApm.Sample.Backend</RootNamespace>
<RootNamespace>SkyApm.Sample.Backend</RootNamespace>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.3" />
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
</ItemGroup>
<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.26.0" />
<PackageReference Include="Grpc.Net.Client" Version="2.26.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.0" />
</ItemGroup>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<Content Update="appsettings.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
...
...
sample/SkyApm.Sample.Frontend/Startup.cs
浏览文件 @
b08027d4
...
@@ -4,6 +4,12 @@ using Microsoft.Extensions.DependencyInjection;
...
@@ -4,6 +4,12 @@ using Microsoft.Extensions.DependencyInjection;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
using
SkyApm.Sample.Backend.Services
;
using
SkyApm.Sample.Backend.Services
;
#if NETCOREAPP2_1
using
IHostEnvironment
=
Microsoft
.
Extensions
.
Hosting
.
IHostingEnvironment
;
#endif
namespace
SkyApm.Sample.Frontend
namespace
SkyApm.Sample.Frontend
{
{
public
class
Startup
public
class
Startup
...
@@ -18,7 +24,13 @@ namespace SkyApm.Sample.Frontend
...
@@ -18,7 +24,13 @@ namespace SkyApm.Sample.Frontend
// This method gets called by the runtime. Use this method to add services to the container.
// This method gets called by the runtime. Use this method to add services to the container.
public
void
ConfigureServices
(
IServiceCollection
services
)
public
void
ConfigureServices
(
IServiceCollection
services
)
{
{
services
.
AddControllers
();
#if NETCOREAPP2_1
services
.
AddMvc
();
#else
services
.
AddControllers
();
#endif
// DI grpc service
// DI grpc service
services
.
AddSingleton
<
GreeterGrpcService
>();
services
.
AddSingleton
<
GreeterGrpcService
>();
...
@@ -31,13 +43,16 @@ namespace SkyApm.Sample.Frontend
...
@@ -31,13 +43,16 @@ namespace SkyApm.Sample.Frontend
{
{
app
.
UseDeveloperExceptionPage
();
app
.
UseDeveloperExceptionPage
();
}
}
#if NETCOREAPP2_1
app
.
UseMvcWithDefaultRoute
();
#else
app
.
UseRouting
();
app
.
UseRouting
();
app
.
UseEndpoints
(
endpoint
=>
app
.
UseEndpoints
(
endpoint
=>
{
{
endpoint
.
MapDefaultControllerRoute
();
endpoint
.
MapDefaultControllerRoute
();
});
});
#endif
}
}
}
}
}
}
\ No newline at end of file
sample/SkyApm.Sample.Gener
al
Host/Program.cs
→
sample/SkyApm.Sample.Gener
ic
Host/Program.cs
浏览文件 @
b08027d4
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
using
SkyApm.Agent.GeneralHost
;
namespace
SkyApm.Sample.Gener
al
Host
namespace
SkyApm.Sample.Gener
ic
Host
{
{
public
class
Program
public
class
Program
{
{
...
@@ -12,8 +11,8 @@ namespace SkyApm.Sample.GeneralHost
...
@@ -12,8 +11,8 @@ namespace SkyApm.Sample.GeneralHost
}
}
public
static
IHostBuilder
CreateHostBuilder
(
string
[]
args
)
=>
public
static
IHostBuilder
CreateHostBuilder
(
string
[]
args
)
=>
Host
.
CreateDefaultBuilder
(
args
)
new
HostBuilder
(
)
.
ConfigureServices
(
services
=>
services
.
AddHostedService
<
Worker
>())
.
ConfigureServices
(
services
=>
services
.
AddHostedService
<
Worker
>())
.
AddSkyAPM
();
.
AddSkyAPM
();
}
}
}
}
\ No newline at end of file
sample/SkyApm.Sample.Gener
alHost/SkyApm.Sample.General
Host.csproj
→
sample/SkyApm.Sample.Gener
icHost/SkyApm.Sample.Generic
Host.csproj
浏览文件 @
b08027d4
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PropertyGroup>
<TargetFramework
>netcoreapp3.1</TargetFramework
>
<TargetFramework
s>netcoreapp2.1;netcoreapp3.1</TargetFrameworks
>
<OutputType>Exe</OutputType>
<OutputType>Exe</OutputType>
</PropertyGroup>
</PropertyGroup>
...
@@ -10,9 +10,17 @@
...
@@ -10,9 +10,17 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</Content>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" />
</ItemGroup>
<ProjectReference Include="..\..\src\SkyApm.Agent.GeneralHost\SkyApm.Agent.GeneralHost.csproj" />
<ItemGroup>
<ProjectReference Include="..\..\src\SkyApm.Agent.Hosting\SkyApm.Agent.Hosting.csproj" />
</ItemGroup>
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
sample/SkyApm.Sample.Gener
al
Host/Worker.cs
→
sample/SkyApm.Sample.Gener
ic
Host/Worker.cs
浏览文件 @
b08027d4
...
@@ -6,7 +6,7 @@ using System.Collections.Generic;
...
@@ -6,7 +6,7 @@ using System.Collections.Generic;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
SkyApm.Sample.Gener
al
Host
namespace
SkyApm.Sample.Gener
ic
Host
{
{
public
class
Worker
:
BackgroundService
public
class
Worker
:
BackgroundService
{
{
...
...
sample/SkyApm.Sample.Gener
al
Host/skyapm.json
→
sample/SkyApm.Sample.Gener
ic
Host/skyapm.json
浏览文件 @
b08027d4
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
"QueueSize"
:
30000
,
"QueueSize"
:
30000
,
"BatchSize"
:
3000
,
"BatchSize"
:
3000
,
"gRPC"
:
{
"gRPC"
:
{
"Servers"
:
"
192.168.79.132
:11800"
,
"Servers"
:
"
localhost
:11800"
,
"Timeout"
:
100000
,
"Timeout"
:
100000
,
"ConnectTimeout"
:
100000
,
"ConnectTimeout"
:
100000
,
"ReportTimeout"
:
600000
"ReportTimeout"
:
600000
...
...
sample/grpc/SkyApm.Sample.GrpcServer/Program.cs
浏览文件 @
b08027d4
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
using
GrpcGreeter
;
using
GrpcGreeter
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
using
SkyApm.Agent.GeneralHost
;
using
System
;
using
System
;
using
System.Net.Http
;
using
System.Net.Http
;
using
System.Threading
;
using
System.Threading
;
...
...
sample/grpc/SkyApm.Sample.GrpcServer/SkyApm.Sample.GrpcServer.csproj
浏览文件 @
b08027d4
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework
>netcoreapp3.1</TargetFramework
>
<TargetFramework
s>netcoreapp2.1;netcoreapp3.1</TargetFrameworks
>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
...
@@ -11,14 +11,14 @@
...
@@ -11,14 +11,14 @@
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</Content>
</ItemGroup>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.0" PrivateAssets="All" />
<PackageReference Include="Grpc" Version="2.26.0" />
</ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" />
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" PrivateAssets="All" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\SkyApm.Agent.
GeneralHost\SkyApm.Agent.GeneralHost
.csproj" />
<ProjectReference Include="..\..\..\src\SkyApm.Agent.
Hosting\SkyApm.Agent.Hosting
.csproj" />
<ProjectReference Include="..\SkyApm.Sample.GrpcProto\SkyApm.Sample.GrpcProto.csproj" />
<ProjectReference Include="..\SkyApm.Sample.GrpcProto\SkyApm.Sample.GrpcProto.csproj" />
</ItemGroup>
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
skyapm-dotnet.sln
浏览文件 @
b08027d4
...
@@ -84,10 +84,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.DotNet.CLI", "src\Sk
...
@@ -84,10 +84,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.DotNet.CLI", "src\Sk
EndProject
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Diagnostics.SmartSql", "src\SkyApm.Diagnostics.SmartSql\SkyApm.Diagnostics.SmartSql.csproj", "{B43160C8-C9E3-43F6-83E9-A9A45B32F022}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Diagnostics.SmartSql", "src\SkyApm.Diagnostics.SmartSql\SkyApm.Diagnostics.SmartSql.csproj", "{B43160C8-C9E3-43F6-83E9-A9A45B32F022}"
EndProject
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Agent.GeneralHost", "src\SkyApm.Agent.GeneralHost\SkyApm.Agent.GeneralHost.csproj", "{4C1CF0E7-4CD3-4731-9A56-E033D5216D58}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Sample.GeneralHost", "sample\SkyApm.Sample.GeneralHost\SkyApm.Sample.GeneralHost.csproj", "{477D705E-576B-46C8-8F1E-9A86EDAE9D86}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Benchmark", "benchmark\SkyApm.Benchmark\SkyApm.Benchmark.csproj", "{33581FDE-ABAF-4C27-A40A-1A2743309399}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Benchmark", "benchmark\SkyApm.Benchmark\SkyApm.Benchmark.csproj", "{33581FDE-ABAF-4C27-A40A-1A2743309399}"
EndProject
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmark", "benchmark", "{2B7F59E8-147F-4399-9804-E7EAEF2DCB22}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "benchmark", "benchmark", "{2B7F59E8-147F-4399-9804-E7EAEF2DCB22}"
...
@@ -102,7 +98,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Sample.GrpcProto", "
...
@@ -102,7 +98,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Sample.GrpcProto", "
EndProject
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Sample.GrpcServer", "sample\grpc\SkyApm.Sample.GrpcServer\SkyApm.Sample.GrpcServer.csproj", "{0EB6D474-A915-4075-B142-FE07321F3AA9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Sample.GrpcServer", "sample\grpc\SkyApm.Sample.GrpcServer\SkyApm.Sample.GrpcServer.csproj", "{0EB6D474-A915-4075-B142-FE07321F3AA9}"
EndProject
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkyApm.Diagnostics.Grpc.Net.Client", "src\SkyApm.Diagnostics.Grpc.Net.Client\SkyApm.Diagnostics.Grpc.Net.Client.csproj", "{34211B07-381E-4489-AA7F-7697D106B7DC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Diagnostics.Grpc.Net.Client", "src\SkyApm.Diagnostics.Grpc.Net.Client\SkyApm.Diagnostics.Grpc.Net.Client.csproj", "{34211B07-381E-4489-AA7F-7697D106B7DC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Agent.Hosting", "src\SkyApm.Agent.Hosting\SkyApm.Agent.Hosting.csproj", "{BC56D244-6C76-4E40-8351-B74B636B17A6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Agent.GeneralHost", "src\SkyApm.Agent.GeneralHost\SkyApm.Agent.GeneralHost.csproj", "{D96279FD-0020-427B-85C5-DC1C2336AA25}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkyApm.Sample.GenericHost", "sample\SkyApm.Sample.GenericHost\SkyApm.Sample.GenericHost.csproj", "{71F61C77-E04F-464D-A0B7-E109CE7E30D7}"
EndProject
EndProject
Global
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
GlobalSection(SolutionConfigurationPlatforms) = preSolution
...
@@ -198,14 +200,6 @@ Global
...
@@ -198,14 +200,6 @@ Global
{B43160C8-C9E3-43F6-83E9-A9A45B32F022}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B43160C8-C9E3-43F6-83E9-A9A45B32F022}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B43160C8-C9E3-43F6-83E9-A9A45B32F022}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B43160C8-C9E3-43F6-83E9-A9A45B32F022}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B43160C8-C9E3-43F6-83E9-A9A45B32F022}.Release|Any CPU.Build.0 = Release|Any CPU
{B43160C8-C9E3-43F6-83E9-A9A45B32F022}.Release|Any CPU.Build.0 = Release|Any CPU
{4C1CF0E7-4CD3-4731-9A56-E033D5216D58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C1CF0E7-4CD3-4731-9A56-E033D5216D58}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C1CF0E7-4CD3-4731-9A56-E033D5216D58}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C1CF0E7-4CD3-4731-9A56-E033D5216D58}.Release|Any CPU.Build.0 = Release|Any CPU
{477D705E-576B-46C8-8F1E-9A86EDAE9D86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{477D705E-576B-46C8-8F1E-9A86EDAE9D86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{477D705E-576B-46C8-8F1E-9A86EDAE9D86}.Release|Any CPU.ActiveCfg = Release|Any CPU
{477D705E-576B-46C8-8F1E-9A86EDAE9D86}.Release|Any CPU.Build.0 = Release|Any CPU
{33581FDE-ABAF-4C27-A40A-1A2743309399}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33581FDE-ABAF-4C27-A40A-1A2743309399}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33581FDE-ABAF-4C27-A40A-1A2743309399}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33581FDE-ABAF-4C27-A40A-1A2743309399}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33581FDE-ABAF-4C27-A40A-1A2743309399}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33581FDE-ABAF-4C27-A40A-1A2743309399}.Release|Any CPU.ActiveCfg = Release|Any CPU
...
@@ -230,6 +224,18 @@ Global
...
@@ -230,6 +224,18 @@ Global
{34211B07-381E-4489-AA7F-7697D106B7DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34211B07-381E-4489-AA7F-7697D106B7DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34211B07-381E-4489-AA7F-7697D106B7DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34211B07-381E-4489-AA7F-7697D106B7DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34211B07-381E-4489-AA7F-7697D106B7DC}.Release|Any CPU.Build.0 = Release|Any CPU
{34211B07-381E-4489-AA7F-7697D106B7DC}.Release|Any CPU.Build.0 = Release|Any CPU
{BC56D244-6C76-4E40-8351-B74B636B17A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC56D244-6C76-4E40-8351-B74B636B17A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC56D244-6C76-4E40-8351-B74B636B17A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC56D244-6C76-4E40-8351-B74B636B17A6}.Release|Any CPU.Build.0 = Release|Any CPU
{D96279FD-0020-427B-85C5-DC1C2336AA25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D96279FD-0020-427B-85C5-DC1C2336AA25}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D96279FD-0020-427B-85C5-DC1C2336AA25}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D96279FD-0020-427B-85C5-DC1C2336AA25}.Release|Any CPU.Build.0 = Release|Any CPU
{71F61C77-E04F-464D-A0B7-E109CE7E30D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71F61C77-E04F-464D-A0B7-E109CE7E30D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71F61C77-E04F-464D-A0B7-E109CE7E30D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71F61C77-E04F-464D-A0B7-E109CE7E30D7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
HideSolutionNode = FALSE
...
@@ -265,8 +271,6 @@ Global
...
@@ -265,8 +271,6 @@ Global
{2F7EEC69-35F4-4D31-B52A-7465D65E9DE0} = {A4E67E09-3156-4D30-B451-F24F706E96C4}
{2F7EEC69-35F4-4D31-B52A-7465D65E9DE0} = {A4E67E09-3156-4D30-B451-F24F706E96C4}
{E909EEF5-5EBF-43F3-AB4A-6B2FB56EF89B} = {1B0865AF-369E-493C-AA6F-C56D3E520A22}
{E909EEF5-5EBF-43F3-AB4A-6B2FB56EF89B} = {1B0865AF-369E-493C-AA6F-C56D3E520A22}
{B43160C8-C9E3-43F6-83E9-A9A45B32F022} = {B5E677CF-2920-4B0A-A056-E73F6B2CF2BC}
{B43160C8-C9E3-43F6-83E9-A9A45B32F022} = {B5E677CF-2920-4B0A-A056-E73F6B2CF2BC}
{4C1CF0E7-4CD3-4731-9A56-E033D5216D58} = {EF6194B2-9ACB-49B9-8049-DD6AFAEB0399}
{477D705E-576B-46C8-8F1E-9A86EDAE9D86} = {844CEACD-4C85-4B15-9E2B-892B01FDA4BB}
{33581FDE-ABAF-4C27-A40A-1A2743309399} = {2B7F59E8-147F-4399-9804-E7EAEF2DCB22}
{33581FDE-ABAF-4C27-A40A-1A2743309399} = {2B7F59E8-147F-4399-9804-E7EAEF2DCB22}
{5E654407-E22F-4696-A33F-C4B372F547BD} = {613F0980-91ED-4064-8E8C-168582EF4AD7}
{5E654407-E22F-4696-A33F-C4B372F547BD} = {613F0980-91ED-4064-8E8C-168582EF4AD7}
{8C389735-61CE-405C-972F-3790DF1E823E} = {B5E677CF-2920-4B0A-A056-E73F6B2CF2BC}
{8C389735-61CE-405C-972F-3790DF1E823E} = {B5E677CF-2920-4B0A-A056-E73F6B2CF2BC}
...
@@ -274,6 +278,9 @@ Global
...
@@ -274,6 +278,9 @@ Global
{5576D9C5-8856-44AD-86AD-FE73A22751EF} = {53E9CEBA-2D11-41FD-AA60-0151A5442CC4}
{5576D9C5-8856-44AD-86AD-FE73A22751EF} = {53E9CEBA-2D11-41FD-AA60-0151A5442CC4}
{0EB6D474-A915-4075-B142-FE07321F3AA9} = {53E9CEBA-2D11-41FD-AA60-0151A5442CC4}
{0EB6D474-A915-4075-B142-FE07321F3AA9} = {53E9CEBA-2D11-41FD-AA60-0151A5442CC4}
{34211B07-381E-4489-AA7F-7697D106B7DC} = {B5E677CF-2920-4B0A-A056-E73F6B2CF2BC}
{34211B07-381E-4489-AA7F-7697D106B7DC} = {B5E677CF-2920-4B0A-A056-E73F6B2CF2BC}
{BC56D244-6C76-4E40-8351-B74B636B17A6} = {EF6194B2-9ACB-49B9-8049-DD6AFAEB0399}
{D96279FD-0020-427B-85C5-DC1C2336AA25} = {EF6194B2-9ACB-49B9-8049-DD6AFAEB0399}
{71F61C77-E04F-464D-A0B7-E109CE7E30D7} = {844CEACD-4C85-4B15-9E2B-892B01FDA4BB}
EndGlobalSection
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {94C0DA2C-CCCB-4314-93A2-9809B5DD0583}
SolutionGuid = {94C0DA2C-CCCB-4314-93A2-9809B5DD0583}
...
...
src/SkyApm.Agent.AspNetCore/HostingEnvironmentProvider.cs
已删除
100644 → 0
浏览文件 @
4b5809d7
/*
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The SkyAPM 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.
*
*/
#if NETCOREAPP3_1
using
Microsoft.Extensions.Hosting
;
#else
using
Microsoft.AspNetCore.Hosting
;
#endif
namespace
SkyApm.Agent.AspNetCore
{
internal
class
HostingEnvironmentProvider
:
IEnvironmentProvider
{
public
string
EnvironmentName
{
get
;
}
#if NETCOREAPP3_1
public
HostingEnvironmentProvider
(
IHostEnvironment
hostingEnvironment
)
{
EnvironmentName
=
hostingEnvironment
.
EnvironmentName
;
}
#else
public
HostingEnvironmentProvider
(
IHostingEnvironment
hostingEnvironment
)
{
EnvironmentName
=
hostingEnvironment
.
EnvironmentName
;
}
#endif
}
}
\ No newline at end of file
src/SkyApm.Agent.AspNetCore/InstrumentationHostedService.cs
已删除
100644 → 0
浏览文件 @
4b5809d7
/*
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The SkyAPM 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.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.Extensions.Hosting
;
namespace
SkyApm.Agent.AspNetCore
{
internal
class
InstrumentationHostedService
:
IHostedService
{
private
readonly
IInstrumentStartup
_startup
;
public
InstrumentationHostedService
(
IInstrumentStartup
startup
)
{
_startup
=
startup
;
}
public
Task
StartAsync
(
CancellationToken
cancellationToken
)
{
return
_startup
.
StartAsync
(
cancellationToken
);
}
public
Task
StopAsync
(
CancellationToken
cancellationToken
)
{
return
_startup
.
StopAsync
(
cancellationToken
);
}
}
}
\ No newline at end of file
src/SkyApm.Agent.AspNetCore/SkyApm.Agent.AspNetCore.csproj
浏览文件 @
b08027d4
...
@@ -14,26 +14,8 @@
...
@@ -14,26 +14,8 @@
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.0" PrivateAssets="All" />
</ItemGroup>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SkyApm.A
bstractions\SkyApm.Abstractions
.csproj" />
<ProjectReference Include="..\SkyApm.A
gent.Hosting\SkyApm.Agent.Hosting
.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.AspNetCore\SkyApm.Diagnostics.AspNetCore.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.AspNetCore\SkyApm.Diagnostics.AspNetCore.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.CAP\SkyApm.Diagnostics.CAP.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore.Npgsql\SkyApm.Diagnostics.EntityFrameworkCore.Npgsql.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore.Pomelo.MySql\SkyApm.Diagnostics.EntityFrameworkCore.Pomelo.MySql.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore.Sqlite\SkyApm.Diagnostics.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore\SkyApm.Diagnostics.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\SkyApm.Core\SkyApm.Core.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.Grpc.Net.Client\SkyApm.Diagnostics.Grpc.Net.Client.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.Grpc\SkyApm.Diagnostics.Grpc.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.HttpClient\SkyApm.Diagnostics.HttpClient.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.SmartSql\SkyApm.Diagnostics.SmartSql.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.SqlClient\SkyApm.Diagnostics.SqlClient.csproj" />
<ProjectReference Include="..\SkyApm.Transport.Grpc\SkyApm.Transport.Grpc.csproj" />
<ProjectReference Include="..\SkyApm.Utilities.Configuration\SkyApm.Utilities.Configuration.csproj" />
<ProjectReference Include="..\SkyApm.Utilities.DependencyInjection\SkyApm.Utilities.DependencyInjection.csproj" />
<ProjectReference Include="..\SkyApm.Utilities.Logging\SkyApm.Utilities.Logging.csproj" />
</ItemGroup>
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
src/SkyApm.Agent.AspNetCore/SkyApmHostingStartup.cs
浏览文件 @
b08027d4
...
@@ -18,6 +18,8 @@
...
@@ -18,6 +18,8 @@
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
SkyApm.Agent.AspNetCore
;
using
SkyApm.Agent.AspNetCore
;
using
SkyApm.Agent.Hosting
;
using
SkyApm.AspNetCore.Diagnostics
;
[
assembly
:
HostingStartup
(
typeof
(
SkyApmHostingStartup
))]
[
assembly
:
HostingStartup
(
typeof
(
SkyApmHostingStartup
))]
...
@@ -27,7 +29,7 @@ namespace SkyApm.Agent.AspNetCore
...
@@ -27,7 +29,7 @@ namespace SkyApm.Agent.AspNetCore
{
{
public
void
Configure
(
IWebHostBuilder
builder
)
public
void
Configure
(
IWebHostBuilder
builder
)
{
{
builder
.
ConfigureServices
(
services
=>
services
.
AddSkyAPM
Core
(
));
builder
.
ConfigureServices
(
services
=>
services
.
AddSkyAPM
(
ext
=>
ext
.
AddAspNetCoreHosting
()
));
}
}
}
}
}
}
\ No newline at end of file
src/SkyApm.Agent.GeneralHost/Extensions/ServiceCollectionExtensions.cs
已删除
100644 → 0
浏览文件 @
4b5809d7
/*
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The SkyAPM 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
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Hosting
;
using
SkyApm.Config
;
using
SkyApm.Diagnostics
;
using
SkyApm.Diagnostics.EntityFrameworkCore
;
using
SkyApm.Diagnostics.Grpc
;
using
SkyApm.Diagnostics.HttpClient
;
using
SkyApm.Diagnostics.SqlClient
;
using
SkyApm.Logging
;
using
SkyApm.Sampling
;
using
SkyApm.Service
;
using
SkyApm.Tracing
;
using
SkyApm.Transport
;
using
SkyApm.Transport.Grpc
;
using
SkyApm.Transport.Grpc.V5
;
using
SkyApm.Transport.Grpc.V6
;
using
SkyApm.Utilities.Configuration
;
using
SkyApm.Utilities.DependencyInjection
;
using
SkyApm.Utilities.Logging
;
using
System
;
using
SkyApm.Diagnostics.Grpc.Net.Client
;
namespace
SkyApm.Agent.GeneralHost
{
internal
static
class
ServiceCollectionExtensions
{
internal
static
IServiceCollection
AddSkyAPMCore
(
this
IServiceCollection
services
)
{
if
(
services
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
services
));
}
services
.
AddSingleton
<
ISegmentDispatcher
,
AsyncQueueSegmentDispatcher
>();
services
.
AddSingleton
<
IExecutionService
,
RegisterService
>();
services
.
AddSingleton
<
IExecutionService
,
PingService
>();
services
.
AddSingleton
<
IExecutionService
,
ServiceDiscoveryV5Service
>();
services
.
AddSingleton
<
IExecutionService
,
SegmentReportService
>();
services
.
AddSingleton
<
IInstrumentStartup
,
InstrumentStartup
>();
services
.
AddSingleton
<
IRuntimeEnvironment
>(
RuntimeEnvironment
.
Instance
);
services
.
AddSingleton
<
TracingDiagnosticProcessorObserver
>();
services
.
AddSingleton
<
IConfigAccessor
,
ConfigAccessor
>();
services
.
AddSingleton
<
IConfigurationFactory
,
ConfigurationFactory
>();
services
.
AddSingleton
<
IHostedService
,
InstrumentationHostedService
>();
services
.
AddSingleton
<
IEnvironmentProvider
,
HostingEnvironmentProvider
>();
services
.
AddTracing
().
AddSampling
().
AddGrpcTransport
().
AddLogging
();
services
.
AddSkyApmExtensions
()
.
AddHttpClient
()
.
AddGrpcClient
()
.
AddSqlClient
()
.
AddGrpc
()
.
AddEntityFrameworkCore
(
c
=>
c
.
AddPomeloMysql
().
AddNpgsql
().
AddSqlite
());
return
services
;
}
private
static
IServiceCollection
AddTracing
(
this
IServiceCollection
services
)
{
services
.
AddSingleton
<
ITracingContext
,
Tracing
.
TracingContext
>();
services
.
AddSingleton
<
ICarrierPropagator
,
CarrierPropagator
>();
services
.
AddSingleton
<
ICarrierFormatter
,
Sw3CarrierFormatter
>();
services
.
AddSingleton
<
ICarrierFormatter
,
Sw6CarrierFormatter
>();
services
.
AddSingleton
<
ISegmentContextFactory
,
SegmentContextFactory
>();
services
.
AddSingleton
<
IEntrySegmentContextAccessor
,
EntrySegmentContextAccessor
>();
services
.
AddSingleton
<
ILocalSegmentContextAccessor
,
LocalSegmentContextAccessor
>();
services
.
AddSingleton
<
IExitSegmentContextAccessor
,
ExitSegmentContextAccessor
>();
services
.
AddSingleton
<
ISamplerChainBuilder
,
SamplerChainBuilder
>();
services
.
AddSingleton
<
IUniqueIdGenerator
,
UniqueIdGenerator
>();
services
.
AddSingleton
<
IUniqueIdParser
,
UniqueIdParser
>();
services
.
AddSingleton
<
ISegmentContextMapper
,
SegmentContextMapper
>();
services
.
AddSingleton
<
IBase64Formatter
,
Base64Formatter
>();
return
services
;
}
private
static
IServiceCollection
AddSampling
(
this
IServiceCollection
services
)
{
services
.
AddSingleton
<
SimpleCountSamplingInterceptor
>();
services
.
AddSingleton
<
ISamplingInterceptor
>(
p
=>
p
.
GetService
<
SimpleCountSamplingInterceptor
>());
services
.
AddSingleton
<
IExecutionService
>(
p
=>
p
.
GetService
<
SimpleCountSamplingInterceptor
>());
services
.
AddSingleton
<
ISamplingInterceptor
,
RandomSamplingInterceptor
>();
return
services
;
}
private
static
IServiceCollection
AddGrpcTransport
(
this
IServiceCollection
services
)
{
services
.
AddSingleton
<
ISkyApmClientV5
,
SkyApmClientV5
>();
services
.
AddSingleton
<
ISegmentReporter
,
SegmentReporter
>();
services
.
AddSingleton
<
ConnectionManager
>();
services
.
AddSingleton
<
IPingCaller
,
PingCaller
>();
services
.
AddSingleton
<
IServiceRegister
,
ServiceRegister
>();
services
.
AddSingleton
<
IExecutionService
,
ConnectService
>();
return
services
;
}
private
static
IServiceCollection
AddLogging
(
this
IServiceCollection
services
)
{
services
.
AddSingleton
<
ILoggerFactory
,
DefaultLoggerFactory
>();
return
services
;
}
}
}
\ No newline at end of file
src/SkyApm.Agent.GeneralHost/SkyApm.Agent.GeneralHost.csproj
浏览文件 @
b08027d4
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" />
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<PropertyGroup>
<Description>$(Product) ASP.NET Core Agent.</Description>
<Description>$(Product) ASP.NET Core Agent.</Description>
<AssemblyTitle>$(PackagePrefix).Agent.GeneralHost</AssemblyTitle>
<AssemblyTitle>$(PackagePrefix).Agent.GeneralHost</AssemblyTitle>
<AssemblyName>$(PackagePrefix).Agent.GeneralHost</AssemblyName>
<AssemblyName>$(PackagePrefix).Agent.GeneralHost</AssemblyName>
<PackageId>$(PackagePrefix).Agent.GeneralHost</PackageId>
<PackageId>$(PackagePrefix).Agent.GeneralHost</PackageId>
<PackageTags>SkyWalking;APM</PackageTags>
<PackageTags>SkyWalking;APM</PackageTags>
<PackageReleaseNotes>
<PackageReleaseNotes>
</PackageReleaseNotes>
</PackageReleaseNotes>
<RootNamespace>SkyApm.Agent.GeneralHost</RootNamespace>
<RootNamespace>SkyApm.Agent.GeneralHost</RootNamespace>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.1.0" PrivateAssets="All" />
<ItemGroup>
</ItemGroup>
<ProjectReference Include="..\SkyApm.Agent.Hosting\SkyApm.Agent.Hosting.csproj" />
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
</ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SkyApm.Abstractions\SkyApm.Abstractions.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore.Npgsql\SkyApm.Diagnostics.EntityFrameworkCore.Npgsql.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore.Pomelo.MySql\SkyApm.Diagnostics.EntityFrameworkCore.Pomelo.MySql.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore.Sqlite\SkyApm.Diagnostics.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore\SkyApm.Diagnostics.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\SkyApm.Core\SkyApm.Core.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.Grpc.Net.Client\SkyApm.Diagnostics.Grpc.Net.Client.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.Grpc\SkyApm.Diagnostics.Grpc.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.HttpClient\SkyApm.Diagnostics.HttpClient.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.SqlClient\SkyApm.Diagnostics.SqlClient.csproj" />
<ProjectReference Include="..\SkyApm.Transport.Grpc\SkyApm.Transport.Grpc.csproj" />
<ProjectReference Include="..\SkyApm.Utilities.Configuration\SkyApm.Utilities.Configuration.csproj" />
<ProjectReference Include="..\SkyApm.Utilities.DependencyInjection\SkyApm.Utilities.DependencyInjection.csproj" />
<ProjectReference Include="..\SkyApm.Utilities.Logging\SkyApm.Utilities.Logging.csproj" />
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
src/SkyApm.Agent.
GeneralHost
/Extensions/HostBuilderExtensions.cs
→
src/SkyApm.Agent.
Hosting
/Extensions/HostBuilderExtensions.cs
浏览文件 @
b08027d4
...
@@ -16,13 +16,13 @@
...
@@ -16,13 +16,13 @@
*
*
*/
*/
using
Microsoft.Extensions
.Hosting
;
using
SkyApm.Agent
.Hosting
;
namespace
SkyApm.Agent.GeneralHost
namespace
Microsoft.Extensions.Hosting
{
{
public
static
class
HostBuilderExtensions
public
static
class
HostBuilderExtensions
{
{
public
static
IHostBuilder
AddSkyAPM
(
this
IHostBuilder
builder
)
=>
public
static
IHostBuilder
AddSkyAPM
(
this
IHostBuilder
builder
)
=>
builder
.
ConfigureServices
((
context
,
services
)
=>
services
.
AddSkyAPM
Core
());
builder
.
ConfigureServices
((
context
,
services
)
=>
services
.
AddSkyAPM
());
}
}
}
}
\ No newline at end of file
src/SkyApm.Agent.
AspNetCore
/Extensions/ServiceCollectionExtensions.cs
→
src/SkyApm.Agent.
Hosting
/Extensions/ServiceCollectionExtensions.cs
浏览文件 @
b08027d4
/*
/*
* Licensed to the SkyAPM under one or more
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* this work for additional information regarding copyright ownership.
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
* The SkyAPM 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 not use this file except in compliance with
* the License. You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*
*
*/
*/
using
System
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.DependencyInjection
;
using
SkyApm.Config
;
using
Microsoft.Extensions.Hosting
;
using
SkyApm.Diagnostics
;
using
SkyApm.Config
;
using
SkyApm.Diagnostics.EntityFrameworkCore
;
using
SkyApm.Diagnostics
;
using
SkyApm.Diagnostics.Grpc
;
using
SkyApm.Logging
;
using
SkyApm.Diagnostics.HttpClient
;
using
SkyApm.Sampling
;
using
SkyApm.Diagnostics.SqlClient
;
using
SkyApm.Service
;
using
SkyApm.Logging
;
using
SkyApm.Tracing
;
using
SkyApm.Sampling
;
using
SkyApm.Transport
;
using
SkyApm.Service
;
using
SkyApm.Transport.Grpc
;
using
SkyApm.Tracing
;
using
SkyApm.Transport.Grpc.V5
;
using
SkyApm.Transport
;
using
SkyApm.Transport.Grpc.V6
;
using
SkyApm.Transport.Grpc
;
using
SkyApm.Utilities.Configuration
;
using
SkyApm.Transport.Grpc.V5
;
using
SkyApm.Utilities.Logging
;
using
SkyApm.Transport.Grpc.V6
;
using
SkyApm.AspNetCore.Diagnostics
;
using
SkyApm.Utilities.Configuration
;
using
SkyApm.Diagnostics.EntityFrameworkCore
;
using
SkyApm.Utilities.DependencyInjection
;
using
SkyApm.Diagnostics.HttpClient
;
using
SkyApm.Utilities.Logging
;
using
SkyApm.Diagnostics.SqlClient
;
using
System
;
using
SkyApm.Utilities.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
SkyApm.Diagnostics.Grpc
;
using
SkyApm.Diagnostics.Grpc.Net.Client
;
using
SkyApm.Diagnostics.Grpc.Net.Client
;
namespace
SkyApm.Agent.Hosting
namespace
SkyApm.Agent.AspNetCore
{
{
public
static
class
ServiceCollectionExtensions
internal
static
class
ServiceCollectionExtensions
{
{
public
static
IServiceCollection
AddSkyAPM
(
this
IServiceCollection
services
,
Action
<
SkyApmExtensions
>
extensionsSetup
=
null
)
internal
static
IServiceCollection
AddSkyAPMCore
(
this
IServiceCollection
services
)
{
{
services
.
AddSkyAPMCore
(
extensionsSetup
);
if
(
services
==
null
)
return
services
;
{
}
throw
new
ArgumentNullException
(
nameof
(
services
));
internal
static
IServiceCollection
AddSkyAPMCore
(
this
IServiceCollection
services
,
Action
<
SkyApmExtensions
>
extensionsSetup
=
null
)
{
if
(
services
==
null
)
{
throw
new
ArgumentNullException
(
nameof
(
services
));
}
}
services
.
AddSingleton
<
ISegmentDispatcher
,
AsyncQueueSegmentDispatcher
>();
services
.
AddSingleton
<
ISegmentDispatcher
,
AsyncQueueSegmentDispatcher
>();
services
.
AddSingleton
<
IExecutionService
,
RegisterService
>();
services
.
AddSingleton
<
IExecutionService
,
RegisterService
>();
services
.
AddSingleton
<
IExecutionService
,
PingService
>();
services
.
AddSingleton
<
IExecutionService
,
PingService
>();
services
.
AddSingleton
<
IExecutionService
,
ServiceDiscoveryV5Service
>();
services
.
AddSingleton
<
IExecutionService
,
ServiceDiscoveryV5Service
>();
services
.
AddSingleton
<
IExecutionService
,
SegmentReportService
>();
services
.
AddSingleton
<
IExecutionService
,
SegmentReportService
>();
services
.
AddSingleton
<
IInstrumentStartup
,
InstrumentStartup
>();
services
.
AddSingleton
<
IInstrumentStartup
,
InstrumentStartup
>();
services
.
AddSingleton
<
IRuntimeEnvironment
>(
RuntimeEnvironment
.
Instance
);
services
.
AddSingleton
<
IRuntimeEnvironment
>(
RuntimeEnvironment
.
Instance
);
services
.
AddSingleton
<
TracingDiagnosticProcessorObserver
>();
services
.
AddSingleton
<
TracingDiagnosticProcessorObserver
>();
services
.
AddSingleton
<
IConfigAccessor
,
ConfigAccessor
>();
services
.
AddSingleton
<
IConfigAccessor
,
ConfigAccessor
>();
services
.
AddSingleton
<
IConfigurationFactory
,
ConfigurationFactory
>();
services
.
AddSingleton
<
IConfigurationFactory
,
ConfigurationFactory
>();
services
.
AddSingleton
<
IHostedService
,
InstrumentationHostedService
>();
services
.
AddSingleton
<
IHostedService
,
InstrumentationHostedService
>();
services
.
AddSingleton
<
IEnvironmentProvider
,
HostingEnvironmentProvider
>();
services
.
AddSingleton
<
IEnvironmentProvider
,
HostingEnvironmentProvider
>();
services
.
Add
Singleton
<
IExecutionService
,
CLRStatsService
>();
services
.
Add
Tracing
().
AddSampling
().
AddGrpcTransport
().
AddLogging
();
services
.
AddTracing
().
AddSampling
().
AddGrpcTransport
().
AddLogging
();
var
extensions
=
services
.
AddSkyApmExtensions
()
services
.
AddSkyApmExtensions
()
.
AddHttpClient
()
.
AddAspNetCoreHosting
()
.
AddGrpcClient
()
.
AddHttpClient
()
.
AddSqlClient
()
.
AddGrpcClient
()
.
AddGrpc
()
.
AddSqlClient
()
.
AddEntityFrameworkCore
(
c
=>
c
.
AddPomeloMysql
().
AddNpgsql
().
AddSqlite
());
.
AddGrpc
()
.
AddEntityFrameworkCore
(
c
=>
c
.
AddPomeloMysql
().
AddNpgsql
().
AddSqlite
());
extensionsSetup
?.
Invoke
(
extensions
);
return
services
;
}
return
services
;
}
private
static
IServiceCollection
AddTracing
(
this
IServiceCollection
services
)
{
private
static
IServiceCollection
AddTracing
(
this
IServiceCollection
services
)
services
.
AddSingleton
<
ITracingContext
,
Tracing
.
TracingContext
>();
{
services
.
AddSingleton
<
I
CarrierPropagator
,
CarrierPropagator
>();
services
.
AddSingleton
<
I
TracingContext
,
TracingContext
>();
services
.
AddSingleton
<
ICarrier
Formatter
,
Sw3CarrierFormatter
>();
services
.
AddSingleton
<
ICarrier
Propagator
,
CarrierPropagator
>();
services
.
AddSingleton
<
ICarrierFormatter
,
Sw
6CarrierFormatter
>();
services
.
AddSingleton
<
ICarrierFormatter
,
Sw
3CarrierFormatter
>();
services
.
AddSingleton
<
I
SegmentContextFactory
,
SegmentContextFactory
>();
services
.
AddSingleton
<
I
CarrierFormatter
,
Sw6CarrierFormatter
>();
services
.
AddSingleton
<
I
EntrySegmentContextAccessor
,
EntrySegmentContextAccessor
>();
services
.
AddSingleton
<
I
SegmentContextFactory
,
SegmentContextFactory
>();
services
.
AddSingleton
<
I
LocalSegmentContextAccessor
,
LocalSegmentContextAccessor
>();
services
.
AddSingleton
<
I
EntrySegmentContextAccessor
,
EntrySegmentContextAccessor
>();
services
.
AddSingleton
<
I
ExitSegmentContextAccessor
,
ExitSegmentContextAccessor
>();
services
.
AddSingleton
<
I
LocalSegmentContextAccessor
,
LocalSegmentContextAccessor
>();
services
.
AddSingleton
<
I
SamplerChainBuilder
,
SamplerChainBuilder
>();
services
.
AddSingleton
<
I
ExitSegmentContextAccessor
,
ExitSegmentContextAccessor
>();
services
.
AddSingleton
<
I
UniqueIdGenerator
,
UniqueIdGenerator
>();
services
.
AddSingleton
<
I
SamplerChainBuilder
,
SamplerChainBuilder
>();
services
.
AddSingleton
<
IUniqueId
Parser
,
UniqueIdParser
>();
services
.
AddSingleton
<
IUniqueId
Generator
,
UniqueIdGenerator
>();
services
.
AddSingleton
<
I
SegmentContextMapper
,
SegmentContextMapper
>();
services
.
AddSingleton
<
I
UniqueIdParser
,
UniqueIdParser
>();
services
.
AddSingleton
<
I
Base64Formatter
,
Base64Formatter
>();
services
.
AddSingleton
<
I
SegmentContextMapper
,
SegmentContextMapper
>();
return
services
;
services
.
AddSingleton
<
IBase64Formatter
,
Base64Formatter
>();
}
return
services
;
}
private
static
IServiceCollection
AddSampling
(
this
IServiceCollection
services
)
{
private
static
IServiceCollection
AddSampling
(
this
IServiceCollection
services
)
services
.
AddSingleton
<
SimpleCountSamplingInterceptor
>();
{
services
.
AddSingleton
<
ISamplingInterceptor
>(
p
=>
p
.
GetService
<
SimpleCountSamplingInterceptor
>());
services
.
AddSingleton
<
SimpleCountSamplingInterceptor
>();
services
.
AddSingleton
<
I
ExecutionService
>(
p
=>
p
.
GetService
<
SimpleCountSamplingInterceptor
>());
services
.
AddSingleton
<
I
SamplingInterceptor
>(
p
=>
p
.
GetService
<
SimpleCountSamplingInterceptor
>());
services
.
AddSingleton
<
I
SamplingInterceptor
,
RandomSamplingInterceptor
>();
services
.
AddSingleton
<
I
ExecutionService
>(
p
=>
p
.
GetService
<
SimpleCountSamplingInterceptor
>());
return
services
;
services
.
AddSingleton
<
ISamplingInterceptor
,
RandomSamplingInterceptor
>();
}
return
services
;
}
private
static
IServiceCollection
AddGrpcTransport
(
this
IServiceCollection
services
)
{
private
static
IServiceCollection
AddGrpcTransport
(
this
IServiceCollection
services
)
services
.
AddSingleton
<
ISkyApmClientV5
,
SkyApmClientV5
>();
{
services
.
AddSingleton
<
IS
egmentReporter
,
SegmentReporter
>();
services
.
AddSingleton
<
IS
kyApmClientV5
,
SkyApmClientV5
>();
services
.
AddSingleton
<
ConnectionManager
>();
services
.
AddSingleton
<
ISegmentReporter
,
SegmentReporter
>();
services
.
AddSingleton
<
IPingCaller
,
PingCaller
>();
services
.
AddSingleton
<
ConnectionManager
>();
services
.
AddSingleton
<
I
ServiceRegister
,
ServiceRegister
>();
services
.
AddSingleton
<
I
PingCaller
,
PingCaller
>();
services
.
AddSingleton
<
I
ExecutionService
,
ConnectService
>();
services
.
AddSingleton
<
I
ServiceRegister
,
ServiceRegister
>();
services
.
AddSingleton
<
I
CLRStatsReporter
,
CLRStatsReporter
>();
services
.
AddSingleton
<
I
ExecutionService
,
ConnectService
>();
return
services
;
return
services
;
}
}
private
static
IServiceCollection
AddLogging
(
this
IServiceCollection
services
)
private
static
IServiceCollection
AddLogging
(
this
IServiceCollection
services
)
{
{
services
.
AddSingleton
<
ILoggerFactory
,
DefaultLoggerFactory
>();
services
.
AddSingleton
<
ILoggerFactory
,
DefaultLoggerFactory
>();
return
services
;
return
services
;
}
}
}
}
}
}
\ No newline at end of file
src/SkyApm.Agent.
GeneralHost
/HostingEnvironmentProvider.cs
→
src/SkyApm.Agent.
Hosting
/HostingEnvironmentProvider.cs
浏览文件 @
b08027d4
...
@@ -18,24 +18,21 @@
...
@@ -18,24 +18,21 @@
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
namespace
SkyApm.Agent.GeneralHost
#if NETSTANDARD2_0
using
IHostEnvironment
=
Microsoft
.
Extensions
.
Hosting
.
IHostingEnvironment
;
#endif
namespace
SkyApm.Agent.Hosting
{
{
internal
class
HostingEnvironmentProvider
:
IEnvironmentProvider
internal
class
HostingEnvironmentProvider
:
IEnvironmentProvider
{
{
public
string
EnvironmentName
{
get
;
}
public
string
EnvironmentName
{
get
;
}
#if NETCOREAPP3_1
public
HostingEnvironmentProvider
(
IHostEnvironment
hostingEnvironment
)
{
EnvironmentName
=
hostingEnvironment
.
EnvironmentName
;
}
#else
public
HostingEnvironmentProvider
(
IHost
ing
Environment
hostingEnvironment
)
public
HostingEnvironmentProvider
(
IHostEnvironment
hostingEnvironment
)
{
{
EnvironmentName
=
hostingEnvironment
.
EnvironmentName
;
EnvironmentName
=
hostingEnvironment
.
EnvironmentName
;
}
}
#endif
}
}
}
}
\ No newline at end of file
src/SkyApm.Agent.
GeneralHost
/InstrumentationHostedService.cs
→
src/SkyApm.Agent.
Hosting
/InstrumentationHostedService.cs
浏览文件 @
b08027d4
/*
/*
* Licensed to the SkyAPM under one or more
* Licensed to the SkyAPM under one or more
* contributor license agreements. See the NOTICE file distributed with
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* this work for additional information regarding copyright ownership.
* The SkyAPM licenses this file to You under the Apache License, Version 2.0
* The SkyAPM 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 not use this file except in compliance with
* the License. You may obtain a copy of the License at
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*
*
*/
*/
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Microsoft.Extensions.Hosting
;
using
Microsoft.Extensions.Hosting
;
namespace
SkyApm.Agent.
GeneralHost
namespace
SkyApm.Agent.
Hosting
{
{
internal
class
InstrumentationHostedService
:
IHostedService
internal
class
InstrumentationHostedService
:
IHostedService
{
{
private
readonly
IInstrumentStartup
_startup
;
private
readonly
IInstrumentStartup
_startup
;
public
InstrumentationHostedService
(
IInstrumentStartup
startup
)
public
InstrumentationHostedService
(
IInstrumentStartup
startup
)
{
{
_startup
=
startup
;
_startup
=
startup
;
}
}
public
Task
StartAsync
(
CancellationToken
cancellationToken
)
public
Task
StartAsync
(
CancellationToken
cancellationToken
)
{
{
return
_startup
.
StartAsync
(
cancellationToken
);
return
_startup
.
StartAsync
(
cancellationToken
);
}
}
public
Task
StopAsync
(
CancellationToken
cancellationToken
)
public
Task
StopAsync
(
CancellationToken
cancellationToken
)
{
{
return
_startup
.
StopAsync
(
cancellationToken
);
return
_startup
.
StopAsync
(
cancellationToken
);
}
}
}
}
}
}
\ No newline at end of file
src/SkyApm.Agent.Hosting/SkyApm.Agent.Hosting.csproj
0 → 100644
浏览文件 @
b08027d4
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<Description>$(Product) ASP.NET Core Agent.</Description>
<AssemblyTitle>$(PackagePrefix).Agent.Hosting</AssemblyTitle>
<AssemblyName>$(PackagePrefix).Agent.Hosting</AssemblyName>
<PackageId>$(PackagePrefix).Agent.Hosting</PackageId>
<PackageTags>SkyWalking;APM</PackageTags>
<PackageReleaseNotes>
</PackageReleaseNotes>
<RootNamespace>SkyApm.Agent.Hosting</RootNamespace>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.1.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SkyApm.Abstractions\SkyApm.Abstractions.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore.Npgsql\SkyApm.Diagnostics.EntityFrameworkCore.Npgsql.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore.Pomelo.MySql\SkyApm.Diagnostics.EntityFrameworkCore.Pomelo.MySql.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore.Sqlite\SkyApm.Diagnostics.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.EntityFrameworkCore\SkyApm.Diagnostics.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\SkyApm.Core\SkyApm.Core.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.Grpc.Net.Client\SkyApm.Diagnostics.Grpc.Net.Client.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.Grpc\SkyApm.Diagnostics.Grpc.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.HttpClient\SkyApm.Diagnostics.HttpClient.csproj" />
<ProjectReference Include="..\SkyApm.Diagnostics.SqlClient\SkyApm.Diagnostics.SqlClient.csproj" />
<ProjectReference Include="..\SkyApm.Transport.Grpc\SkyApm.Transport.Grpc.csproj" />
<ProjectReference Include="..\SkyApm.Utilities.Configuration\SkyApm.Utilities.Configuration.csproj" />
<ProjectReference Include="..\SkyApm.Utilities.DependencyInjection\SkyApm.Utilities.DependencyInjection.csproj" />
<ProjectReference Include="..\SkyApm.Utilities.Logging\SkyApm.Utilities.Logging.csproj" />
</ItemGroup>
</Project>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录