Skip to content

Commit 6ab1da0

Browse files
authored
Merge pull request #10 from dotnetcore/master
merge
2 parents 7412a58 + be43a8d commit 6ab1da0

33 files changed

+308
-113
lines changed

src/Surging.ApiGateway/Configs/gatewaySettings.json

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"TokenEndpointPath": "api/oauth2/token",
66
"CacheMode": "MemoryCache", //MemoryCache or gateway.Redis save token
77
"AccessPolicy": {
8-
"Origins": [ "http://127.0.0.1:1927", "http://localhost:927" ],
98
"AllowAnyHeader": true,
109
"AllowAnyMethod": true
1110
},

src/Surging.ApiGateway/Startup.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
using Surging.Core.Caching;
2727
using Surging.Core.CPlatform.Cache;
2828
using System.Linq;
29+
using Surging.Apm.Skywalking;
30+
using Surging.Apm.Skywalking.Abstractions;
2931

3032
namespace Surging.ApiGateway
3133
{
@@ -74,7 +76,9 @@ private IServiceProvider RegisterAutofac(IServiceCollection services)
7476
else if(registerConfig.Provider == RegisterProvider.Zookeeper)
7577
option.UseZooKeeperManager(new ZookeeperConfigInfo(registerConfig.Address, enableChildrenMonitor: true));
7678
option.UseDotNettyTransport();
77-
option.AddApiGateWay();
79+
option.AddApiGateWay();
80+
option.AddRpcTransportDiagnostic();
81+
option.UseSkywalking();
7882
option.AddFilter(new ServiceExceptionFilter());
7983
//option.UseProtoBufferCodec();
8084
option.UseMessagePackCodec();
@@ -93,7 +97,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
9397
ServiceLocator.Current.Resolve<IServiceProxyFactory>();
9498
ServiceLocator.Current.Resolve<IServiceCacheManager>().SetCachesAsync(addressDescriptors);
9599
ServiceLocator.Current.Resolve<IConfigurationWatchProvider>();
96-
100+
ServiceLocator.Current.Resolve<IInstrumentStartup>().StartAsync();
97101
if (env.IsDevelopment())
98102
{
99103
app.UseDeveloperExceptionPage();
@@ -105,6 +109,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
105109
app.UseCors(builder =>
106110
{
107111
var policy = Core.ApiGateWay.AppConfig.Policy;
112+
if(policy.Origins !=null)
108113
builder.WithOrigins(policy.Origins);
109114
if (policy.AllowAnyHeader)
110115
builder.AllowAnyHeader();

src/Surging.ApiGateway/Surging.ApiGateway.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
</ItemGroup>
4343

4444
<ItemGroup>
45+
<ProjectReference Include="..\Surging.Apm\SkyApm.Transport.Grpc.Protocol\SkyApm.Transport.Grpc.Protocol.csproj" />
46+
<ProjectReference Include="..\Surging.Apm\Surging.Apm.Skywalking\Surging.Apm.Skywalking.csproj" />
4547
<ProjectReference Include="..\Surging.Core\Surging.Core.ApiGateWay\Surging.Core.ApiGateWay.csproj" />
4648
<ProjectReference Include="..\Surging.Core\Surging.Core.Caching\Surging.Core.Caching.csproj" />
4749
<ProjectReference Include="..\Surging.Core\Surging.Core.Codec.MessagePack\Surging.Core.Codec.MessagePack.csproj" />
@@ -64,6 +66,9 @@
6466
<Content Update="Configs\gatewaySettings.json">
6567
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6668
</Content>
69+
<Content Update="skyapm.json">
70+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
71+
</Content>
6772
</ItemGroup>
6873

6974
</Project>

src/Surging.ApiGateway/skyapm.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"SkyWalking": {
3+
"ServiceName": "Surging.ApiGateway",
4+
"Namespace": "",
5+
"HeaderVersions": [
6+
"sw6"
7+
],
8+
"Sampling": {
9+
"SamplePer3Secs": -1,
10+
"Percentage": -1.0
11+
},
12+
"Logging": {
13+
"Level": "Information",
14+
"FilePath": "logs/skyapm-{Date}.log"
15+
},
16+
"Transport": {
17+
"Interval": 3000,
18+
"ProtocolVersion": "v6",
19+
"QueueSize": 30000,
20+
"BatchSize": 3000,
21+
"gRPC": {
22+
"Servers": "localhost:11800",
23+
"Timeout": 100000,
24+
"ConnectTimeout": 100000,
25+
"ReportTimeout": 600000
26+
}
27+
}
28+
}
29+
}

src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/SkyApm.Transport.Grpc.Protocol.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<PropertyGroup>
55
<Description>$(Product) gRPC data transmitter.</Description>
66
<AssemblyTitle>$(PackagePrefix).Transport.Grpc.Protocol</AssemblyTitle>
7-
<AssemblyName>$(PackagePrefix).Transport.Grpc.Protocol</AssemblyName>
7+
<AssemblyName>SkyApm.Transport.Grpc.Protocol</AssemblyName>
88
<PackageId>$(PackagePrefix).Transport.Grpc.Protocol</PackageId>
99
<PackageTags>SkyWalking;Grpc</PackageTags>
1010
<PackageReleaseNotes>
@@ -14,9 +14,9 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Google.Protobuf" Version="3.6.1" />
18-
<PackageReference Include="Grpc" Version="1.17.0" />
19-
<PackageReference Include="Grpc.Tools" Version="1.17.0" PrivateAssets="All" />
17+
<PackageReference Include="Google.Protobuf" Version="3.10.1" />
18+
<PackageReference Include="Grpc" Version="2.24.0" />
19+
<PackageReference Include="Grpc.Tools" Version="2.24.0" PrivateAssets="All" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterService.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public void MergeFrom(ApplicationMapping other) {
280280
}
281281
if (other.application_ != null) {
282282
if (application_ == null) {
283-
application_ = new global::SkyWalking.NetworkProtocol.KeyWithIntegerValue();
283+
Application = new global::SkyWalking.NetworkProtocol.KeyWithIntegerValue();
284284
}
285285
Application.MergeFrom(other.Application);
286286
}
@@ -297,9 +297,9 @@ public void MergeFrom(pb::CodedInputStream input) {
297297
break;
298298
case 10: {
299299
if (application_ == null) {
300-
application_ = new global::SkyWalking.NetworkProtocol.KeyWithIntegerValue();
300+
Application = new global::SkyWalking.NetworkProtocol.KeyWithIntegerValue();
301301
}
302-
input.ReadMessage(application_);
302+
input.ReadMessage(Application);
303303
break;
304304
}
305305
}

src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterServiceGrpc.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public static partial class ApplicationRegisterService
5050
}
5151

5252
/// <summary>Base class for server-side implementations of ApplicationRegisterService</summary>
53+
[grpc::BindServiceMethod(typeof(ApplicationRegisterService), "BindService")]
5354
public abstract partial class ApplicationRegisterServiceBase
5455
{
5556
public virtual global::System.Threading.Tasks.Task<global::SkyWalking.NetworkProtocol.ApplicationMapping> applicationCodeRegister(global::SkyWalking.NetworkProtocol.Application request, grpc::ServerCallContext context)
@@ -64,7 +65,7 @@ public partial class ApplicationRegisterServiceClient : grpc::ClientBase<Applica
6465
{
6566
/// <summary>Creates a new client for ApplicationRegisterService</summary>
6667
/// <param name="channel">The channel to use to make remote calls.</param>
67-
public ApplicationRegisterServiceClient(grpc::Channel channel) : base(channel)
68+
public ApplicationRegisterServiceClient(grpc::ChannelBase channel) : base(channel)
6869
{
6970
}
7071
/// <summary>Creates a new client for ApplicationRegisterService that uses a custom <c>CallInvoker</c>.</summary>
@@ -113,13 +114,13 @@ protected override ApplicationRegisterServiceClient NewInstance(ClientBaseConfig
113114
.AddMethod(__Method_applicationCodeRegister, serviceImpl.applicationCodeRegister).Build();
114115
}
115116

116-
/// <summary>Register service method implementations with a service binder. Useful when customizing the service binding logic.
117+
/// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
117118
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
118119
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
119120
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
120121
public static void BindService(grpc::ServiceBinderBase serviceBinder, ApplicationRegisterServiceBase serviceImpl)
121122
{
122-
serviceBinder.AddMethod(__Method_applicationCodeRegister, serviceImpl.applicationCodeRegister);
123+
serviceBinder.AddMethod(__Method_applicationCodeRegister, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::SkyWalking.NetworkProtocol.Application, global::SkyWalking.NetworkProtocol.ApplicationMapping>(serviceImpl.applicationCodeRegister));
123124
}
124125

125126
}

src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLR.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,19 @@ public void MergeFrom(CLRMetric other) {
220220
}
221221
if (other.cpu_ != null) {
222222
if (cpu_ == null) {
223-
cpu_ = new global::SkyWalking.NetworkProtocol.CPU();
223+
Cpu = new global::SkyWalking.NetworkProtocol.CPU();
224224
}
225225
Cpu.MergeFrom(other.Cpu);
226226
}
227227
if (other.gc_ != null) {
228228
if (gc_ == null) {
229-
gc_ = new global::SkyWalking.NetworkProtocol.ClrGC();
229+
Gc = new global::SkyWalking.NetworkProtocol.ClrGC();
230230
}
231231
Gc.MergeFrom(other.Gc);
232232
}
233233
if (other.thread_ != null) {
234234
if (thread_ == null) {
235-
thread_ = new global::SkyWalking.NetworkProtocol.ClrThread();
235+
Thread = new global::SkyWalking.NetworkProtocol.ClrThread();
236236
}
237237
Thread.MergeFrom(other.Thread);
238238
}
@@ -253,23 +253,23 @@ public void MergeFrom(pb::CodedInputStream input) {
253253
}
254254
case 18: {
255255
if (cpu_ == null) {
256-
cpu_ = new global::SkyWalking.NetworkProtocol.CPU();
256+
Cpu = new global::SkyWalking.NetworkProtocol.CPU();
257257
}
258-
input.ReadMessage(cpu_);
258+
input.ReadMessage(Cpu);
259259
break;
260260
}
261261
case 26: {
262262
if (gc_ == null) {
263-
gc_ = new global::SkyWalking.NetworkProtocol.ClrGC();
263+
Gc = new global::SkyWalking.NetworkProtocol.ClrGC();
264264
}
265-
input.ReadMessage(gc_);
265+
input.ReadMessage(Gc);
266266
break;
267267
}
268268
case 34: {
269269
if (thread_ == null) {
270-
thread_ = new global::SkyWalking.NetworkProtocol.ClrThread();
270+
Thread = new global::SkyWalking.NetworkProtocol.ClrThread();
271271
}
272-
input.ReadMessage(thread_);
272+
input.ReadMessage(Thread);
273273
break;
274274
}
275275
}

src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLRMetricGrpc.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public static partial class CLRMetricReportService
4747
}
4848

4949
/// <summary>Base class for server-side implementations of CLRMetricReportService</summary>
50+
[grpc::BindServiceMethod(typeof(CLRMetricReportService), "BindService")]
5051
public abstract partial class CLRMetricReportServiceBase
5152
{
5253
public virtual global::System.Threading.Tasks.Task<global::SkyWalking.NetworkProtocol.Commands> collect(global::SkyWalking.NetworkProtocol.CLRMetricCollection request, grpc::ServerCallContext context)
@@ -61,7 +62,7 @@ public partial class CLRMetricReportServiceClient : grpc::ClientBase<CLRMetricRe
6162
{
6263
/// <summary>Creates a new client for CLRMetricReportService</summary>
6364
/// <param name="channel">The channel to use to make remote calls.</param>
64-
public CLRMetricReportServiceClient(grpc::Channel channel) : base(channel)
65+
public CLRMetricReportServiceClient(grpc::ChannelBase channel) : base(channel)
6566
{
6667
}
6768
/// <summary>Creates a new client for CLRMetricReportService that uses a custom <c>CallInvoker</c>.</summary>
@@ -110,13 +111,13 @@ protected override CLRMetricReportServiceClient NewInstance(ClientBaseConfigurat
110111
.AddMethod(__Method_collect, serviceImpl.collect).Build();
111112
}
112113

113-
/// <summary>Register service method implementations with a service binder. Useful when customizing the service binding logic.
114+
/// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
114115
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
115116
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
116117
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
117118
public static void BindService(grpc::ServiceBinderBase serviceBinder, CLRMetricReportServiceBase serviceImpl)
118119
{
119-
serviceBinder.AddMethod(__Method_collect, serviceImpl.collect);
120+
serviceBinder.AddMethod(__Method_collect, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::SkyWalking.NetworkProtocol.CLRMetricCollection, global::SkyWalking.NetworkProtocol.Commands>(serviceImpl.collect));
120121
}
121122

122123
}

src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryService.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void MergeFrom(ApplicationInstance other) {
250250
}
251251
if (other.osinfo_ != null) {
252252
if (osinfo_ == null) {
253-
osinfo_ = new global::SkyWalking.NetworkProtocol.OSInfo();
253+
Osinfo = new global::SkyWalking.NetworkProtocol.OSInfo();
254254
}
255255
Osinfo.MergeFrom(other.Osinfo);
256256
}
@@ -279,9 +279,9 @@ public void MergeFrom(pb::CodedInputStream input) {
279279
}
280280
case 34: {
281281
if (osinfo_ == null) {
282-
osinfo_ = new global::SkyWalking.NetworkProtocol.OSInfo();
282+
Osinfo = new global::SkyWalking.NetworkProtocol.OSInfo();
283283
}
284-
input.ReadMessage(osinfo_);
284+
input.ReadMessage(Osinfo);
285285
break;
286286
}
287287
}
@@ -626,7 +626,7 @@ public void MergeFrom(ApplicationInstanceRecover other) {
626626
}
627627
if (other.osinfo_ != null) {
628628
if (osinfo_ == null) {
629-
osinfo_ = new global::SkyWalking.NetworkProtocol.OSInfo();
629+
Osinfo = new global::SkyWalking.NetworkProtocol.OSInfo();
630630
}
631631
Osinfo.MergeFrom(other.Osinfo);
632632
}
@@ -655,9 +655,9 @@ public void MergeFrom(pb::CodedInputStream input) {
655655
}
656656
case 34: {
657657
if (osinfo_ == null) {
658-
osinfo_ = new global::SkyWalking.NetworkProtocol.OSInfo();
658+
Osinfo = new global::SkyWalking.NetworkProtocol.OSInfo();
659659
}
660-
input.ReadMessage(osinfo_);
660+
input.ReadMessage(Osinfo);
661661
break;
662662
}
663663
}
@@ -1401,7 +1401,7 @@ public void MergeFrom(ServiceNameMappingElement other) {
14011401
}
14021402
if (other.element_ != null) {
14031403
if (element_ == null) {
1404-
element_ = new global::SkyWalking.NetworkProtocol.ServiceNameElement();
1404+
Element = new global::SkyWalking.NetworkProtocol.ServiceNameElement();
14051405
}
14061406
Element.MergeFrom(other.Element);
14071407
}
@@ -1422,9 +1422,9 @@ public void MergeFrom(pb::CodedInputStream input) {
14221422
}
14231423
case 18: {
14241424
if (element_ == null) {
1425-
element_ = new global::SkyWalking.NetworkProtocol.ServiceNameElement();
1425+
Element = new global::SkyWalking.NetworkProtocol.ServiceNameElement();
14261426
}
1427-
input.ReadMessage(element_);
1427+
input.ReadMessage(Element);
14281428
break;
14291429
}
14301430
}
@@ -1609,7 +1609,7 @@ public void MergeFrom(pb::CodedInputStream input) {
16091609
break;
16101610
}
16111611
case 24: {
1612-
srcSpanType_ = (global::SkyWalking.NetworkProtocol.SpanType) input.ReadEnum();
1612+
SrcSpanType = (global::SkyWalking.NetworkProtocol.SpanType) input.ReadEnum();
16131613
break;
16141614
}
16151615
}

src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryServiceGrpc.cs

+9-7
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static partial class InstanceDiscoveryService
5656
}
5757

5858
/// <summary>Base class for server-side implementations of InstanceDiscoveryService</summary>
59+
[grpc::BindServiceMethod(typeof(InstanceDiscoveryService), "BindService")]
5960
public abstract partial class InstanceDiscoveryServiceBase
6061
{
6162
public virtual global::System.Threading.Tasks.Task<global::SkyWalking.NetworkProtocol.ApplicationInstanceMapping> registerInstance(global::SkyWalking.NetworkProtocol.ApplicationInstance request, grpc::ServerCallContext context)
@@ -75,7 +76,7 @@ public partial class InstanceDiscoveryServiceClient : grpc::ClientBase<InstanceD
7576
{
7677
/// <summary>Creates a new client for InstanceDiscoveryService</summary>
7778
/// <param name="channel">The channel to use to make remote calls.</param>
78-
public InstanceDiscoveryServiceClient(grpc::Channel channel) : base(channel)
79+
public InstanceDiscoveryServiceClient(grpc::ChannelBase channel) : base(channel)
7980
{
8081
}
8182
/// <summary>Creates a new client for InstanceDiscoveryService that uses a custom <c>CallInvoker</c>.</summary>
@@ -141,14 +142,14 @@ protected override InstanceDiscoveryServiceClient NewInstance(ClientBaseConfigur
141142
.AddMethod(__Method_heartbeat, serviceImpl.heartbeat).Build();
142143
}
143144

144-
/// <summary>Register service method implementations with a service binder. Useful when customizing the service binding logic.
145+
/// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
145146
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
146147
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
147148
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
148149
public static void BindService(grpc::ServiceBinderBase serviceBinder, InstanceDiscoveryServiceBase serviceImpl)
149150
{
150-
serviceBinder.AddMethod(__Method_registerInstance, serviceImpl.registerInstance);
151-
serviceBinder.AddMethod(__Method_heartbeat, serviceImpl.heartbeat);
151+
serviceBinder.AddMethod(__Method_registerInstance, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::SkyWalking.NetworkProtocol.ApplicationInstance, global::SkyWalking.NetworkProtocol.ApplicationInstanceMapping>(serviceImpl.registerInstance));
152+
serviceBinder.AddMethod(__Method_heartbeat, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::SkyWalking.NetworkProtocol.ApplicationInstanceHeartbeat, global::SkyWalking.NetworkProtocol.Downstream>(serviceImpl.heartbeat));
152153
}
153154

154155
}
@@ -176,6 +177,7 @@ public static partial class ServiceNameDiscoveryService
176177
}
177178

178179
/// <summary>Base class for server-side implementations of ServiceNameDiscoveryService</summary>
180+
[grpc::BindServiceMethod(typeof(ServiceNameDiscoveryService), "BindService")]
179181
public abstract partial class ServiceNameDiscoveryServiceBase
180182
{
181183
public virtual global::System.Threading.Tasks.Task<global::SkyWalking.NetworkProtocol.ServiceNameMappingCollection> discovery(global::SkyWalking.NetworkProtocol.ServiceNameCollection request, grpc::ServerCallContext context)
@@ -190,7 +192,7 @@ public partial class ServiceNameDiscoveryServiceClient : grpc::ClientBase<Servic
190192
{
191193
/// <summary>Creates a new client for ServiceNameDiscoveryService</summary>
192194
/// <param name="channel">The channel to use to make remote calls.</param>
193-
public ServiceNameDiscoveryServiceClient(grpc::Channel channel) : base(channel)
195+
public ServiceNameDiscoveryServiceClient(grpc::ChannelBase channel) : base(channel)
194196
{
195197
}
196198
/// <summary>Creates a new client for ServiceNameDiscoveryService that uses a custom <c>CallInvoker</c>.</summary>
@@ -239,13 +241,13 @@ protected override ServiceNameDiscoveryServiceClient NewInstance(ClientBaseConfi
239241
.AddMethod(__Method_discovery, serviceImpl.discovery).Build();
240242
}
241243

242-
/// <summary>Register service method implementations with a service binder. Useful when customizing the service binding logic.
244+
/// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
243245
/// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
244246
/// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
245247
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
246248
public static void BindService(grpc::ServiceBinderBase serviceBinder, ServiceNameDiscoveryServiceBase serviceImpl)
247249
{
248-
serviceBinder.AddMethod(__Method_discovery, serviceImpl.discovery);
250+
serviceBinder.AddMethod(__Method_discovery, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::SkyWalking.NetworkProtocol.ServiceNameCollection, global::SkyWalking.NetworkProtocol.ServiceNameMappingCollection>(serviceImpl.discovery));
249251
}
250252

251253
}

0 commit comments

Comments
 (0)