diff --git a/src/Surging.ApiGateway/Configs/gatewaySettings.json b/src/Surging.ApiGateway/Configs/gatewaySettings.json index 910f6eb82..54a385d2d 100644 --- a/src/Surging.ApiGateway/Configs/gatewaySettings.json +++ b/src/Surging.ApiGateway/Configs/gatewaySettings.json @@ -5,7 +5,6 @@ "TokenEndpointPath": "api/oauth2/token", "CacheMode": "MemoryCache", //MemoryCache or gateway.Redis save token "AccessPolicy": { - "Origins": [ "http://127.0.0.1:1927", "http://localhost:927" ], "AllowAnyHeader": true, "AllowAnyMethod": true }, diff --git a/src/Surging.ApiGateway/Startup.cs b/src/Surging.ApiGateway/Startup.cs index 00842759b..6436f81ca 100644 --- a/src/Surging.ApiGateway/Startup.cs +++ b/src/Surging.ApiGateway/Startup.cs @@ -26,6 +26,8 @@ using Surging.Core.Caching; using Surging.Core.CPlatform.Cache; using System.Linq; +using Surging.Apm.Skywalking; +using Surging.Apm.Skywalking.Abstractions; namespace Surging.ApiGateway { @@ -74,7 +76,9 @@ private IServiceProvider RegisterAutofac(IServiceCollection services) else if(registerConfig.Provider == RegisterProvider.Zookeeper) option.UseZooKeeperManager(new ZookeeperConfigInfo(registerConfig.Address, enableChildrenMonitor: true)); option.UseDotNettyTransport(); - option.AddApiGateWay(); + option.AddApiGateWay(); + option.AddRpcTransportDiagnostic(); + option.UseSkywalking(); option.AddFilter(new ServiceExceptionFilter()); //option.UseProtoBufferCodec(); option.UseMessagePackCodec(); @@ -93,7 +97,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF ServiceLocator.Current.Resolve(); ServiceLocator.Current.Resolve().SetCachesAsync(addressDescriptors); ServiceLocator.Current.Resolve(); - + ServiceLocator.Current.Resolve().StartAsync(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); @@ -105,6 +109,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF app.UseCors(builder => { var policy = Core.ApiGateWay.AppConfig.Policy; + if(policy.Origins !=null) builder.WithOrigins(policy.Origins); if (policy.AllowAnyHeader) builder.AllowAnyHeader(); diff --git a/src/Surging.ApiGateway/Surging.ApiGateway.csproj b/src/Surging.ApiGateway/Surging.ApiGateway.csproj index ec318af9c..c3e74029c 100644 --- a/src/Surging.ApiGateway/Surging.ApiGateway.csproj +++ b/src/Surging.ApiGateway/Surging.ApiGateway.csproj @@ -42,6 +42,8 @@ + + @@ -64,6 +66,9 @@ PreserveNewest + + Always + diff --git a/src/Surging.ApiGateway/skyapm.json b/src/Surging.ApiGateway/skyapm.json new file mode 100644 index 000000000..cf0547ac2 --- /dev/null +++ b/src/Surging.ApiGateway/skyapm.json @@ -0,0 +1,29 @@ +{ + "SkyWalking": { + "ServiceName": "Surging.ApiGateway", + "Namespace": "", + "HeaderVersions": [ + "sw6" + ], + "Sampling": { + "SamplePer3Secs": -1, + "Percentage": -1.0 + }, + "Logging": { + "Level": "Information", + "FilePath": "logs/skyapm-{Date}.log" + }, + "Transport": { + "Interval": 3000, + "ProtocolVersion": "v6", + "QueueSize": 30000, + "BatchSize": 3000, + "gRPC": { + "Servers": "localhost:11800", + "Timeout": 100000, + "ConnectTimeout": 100000, + "ReportTimeout": 600000 + } + } + } +} \ No newline at end of file diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/SkyApm.Transport.Grpc.Protocol.csproj b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/SkyApm.Transport.Grpc.Protocol.csproj index 62cdc6e9f..9f073f38a 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/SkyApm.Transport.Grpc.Protocol.csproj +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/SkyApm.Transport.Grpc.Protocol.csproj @@ -4,7 +4,7 @@ $(Product) gRPC data transmitter. $(PackagePrefix).Transport.Grpc.Protocol - $(PackagePrefix).Transport.Grpc.Protocol + SkyApm.Transport.Grpc.Protocol $(PackagePrefix).Transport.Grpc.Protocol SkyWalking;Grpc @@ -14,9 +14,9 @@ - - - + + + diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterService.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterService.cs index 128ffbf3f..fa74e2c9a 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterService.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterService.cs @@ -280,7 +280,7 @@ public void MergeFrom(ApplicationMapping other) { } if (other.application_ != null) { if (application_ == null) { - application_ = new global::SkyWalking.NetworkProtocol.KeyWithIntegerValue(); + Application = new global::SkyWalking.NetworkProtocol.KeyWithIntegerValue(); } Application.MergeFrom(other.Application); } @@ -297,9 +297,9 @@ public void MergeFrom(pb::CodedInputStream input) { break; case 10: { if (application_ == null) { - application_ = new global::SkyWalking.NetworkProtocol.KeyWithIntegerValue(); + Application = new global::SkyWalking.NetworkProtocol.KeyWithIntegerValue(); } - input.ReadMessage(application_); + input.ReadMessage(Application); break; } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterServiceGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterServiceGrpc.cs index e9ba206e2..4ab50cd94 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterServiceGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ApplicationRegisterServiceGrpc.cs @@ -50,6 +50,7 @@ public static partial class ApplicationRegisterService } /// Base class for server-side implementations of ApplicationRegisterService + [grpc::BindServiceMethod(typeof(ApplicationRegisterService), "BindService")] public abstract partial class ApplicationRegisterServiceBase { public virtual global::System.Threading.Tasks.Task applicationCodeRegister(global::SkyWalking.NetworkProtocol.Application request, grpc::ServerCallContext context) @@ -64,7 +65,7 @@ public partial class ApplicationRegisterServiceClient : grpc::ClientBaseCreates a new client for ApplicationRegisterService /// The channel to use to make remote calls. - public ApplicationRegisterServiceClient(grpc::Channel channel) : base(channel) + public ApplicationRegisterServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for ApplicationRegisterService that uses a custom CallInvoker. @@ -113,13 +114,13 @@ protected override ApplicationRegisterServiceClient NewInstance(ClientBaseConfig .AddMethod(__Method_applicationCodeRegister, serviceImpl.applicationCodeRegister).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, ApplicationRegisterServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_applicationCodeRegister, serviceImpl.applicationCodeRegister); + serviceBinder.AddMethod(__Method_applicationCodeRegister, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.applicationCodeRegister)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLR.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLR.cs index 35747ce87..3fd962a6d 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLR.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLR.cs @@ -220,19 +220,19 @@ public void MergeFrom(CLRMetric other) { } if (other.cpu_ != null) { if (cpu_ == null) { - cpu_ = new global::SkyWalking.NetworkProtocol.CPU(); + Cpu = new global::SkyWalking.NetworkProtocol.CPU(); } Cpu.MergeFrom(other.Cpu); } if (other.gc_ != null) { if (gc_ == null) { - gc_ = new global::SkyWalking.NetworkProtocol.ClrGC(); + Gc = new global::SkyWalking.NetworkProtocol.ClrGC(); } Gc.MergeFrom(other.Gc); } if (other.thread_ != null) { if (thread_ == null) { - thread_ = new global::SkyWalking.NetworkProtocol.ClrThread(); + Thread = new global::SkyWalking.NetworkProtocol.ClrThread(); } Thread.MergeFrom(other.Thread); } @@ -253,23 +253,23 @@ public void MergeFrom(pb::CodedInputStream input) { } case 18: { if (cpu_ == null) { - cpu_ = new global::SkyWalking.NetworkProtocol.CPU(); + Cpu = new global::SkyWalking.NetworkProtocol.CPU(); } - input.ReadMessage(cpu_); + input.ReadMessage(Cpu); break; } case 26: { if (gc_ == null) { - gc_ = new global::SkyWalking.NetworkProtocol.ClrGC(); + Gc = new global::SkyWalking.NetworkProtocol.ClrGC(); } - input.ReadMessage(gc_); + input.ReadMessage(Gc); break; } case 34: { if (thread_ == null) { - thread_ = new global::SkyWalking.NetworkProtocol.ClrThread(); + Thread = new global::SkyWalking.NetworkProtocol.ClrThread(); } - input.ReadMessage(thread_); + input.ReadMessage(Thread); break; } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLRMetricGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLRMetricGrpc.cs index a650fc1f9..3bc459309 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLRMetricGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/CLRMetricGrpc.cs @@ -47,6 +47,7 @@ public static partial class CLRMetricReportService } /// Base class for server-side implementations of CLRMetricReportService + [grpc::BindServiceMethod(typeof(CLRMetricReportService), "BindService")] public abstract partial class CLRMetricReportServiceBase { public virtual global::System.Threading.Tasks.Task collect(global::SkyWalking.NetworkProtocol.CLRMetricCollection request, grpc::ServerCallContext context) @@ -61,7 +62,7 @@ public partial class CLRMetricReportServiceClient : grpc::ClientBaseCreates a new client for CLRMetricReportService /// The channel to use to make remote calls. - public CLRMetricReportServiceClient(grpc::Channel channel) : base(channel) + public CLRMetricReportServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for CLRMetricReportService that uses a custom CallInvoker. @@ -110,13 +111,13 @@ protected override CLRMetricReportServiceClient NewInstance(ClientBaseConfigurat .AddMethod(__Method_collect, serviceImpl.collect).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, CLRMetricReportServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_collect, serviceImpl.collect); + serviceBinder.AddMethod(__Method_collect, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.collect)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryService.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryService.cs index 1581a0704..086bc9978 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryService.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryService.cs @@ -250,7 +250,7 @@ public void MergeFrom(ApplicationInstance other) { } if (other.osinfo_ != null) { if (osinfo_ == null) { - osinfo_ = new global::SkyWalking.NetworkProtocol.OSInfo(); + Osinfo = new global::SkyWalking.NetworkProtocol.OSInfo(); } Osinfo.MergeFrom(other.Osinfo); } @@ -279,9 +279,9 @@ public void MergeFrom(pb::CodedInputStream input) { } case 34: { if (osinfo_ == null) { - osinfo_ = new global::SkyWalking.NetworkProtocol.OSInfo(); + Osinfo = new global::SkyWalking.NetworkProtocol.OSInfo(); } - input.ReadMessage(osinfo_); + input.ReadMessage(Osinfo); break; } } @@ -626,7 +626,7 @@ public void MergeFrom(ApplicationInstanceRecover other) { } if (other.osinfo_ != null) { if (osinfo_ == null) { - osinfo_ = new global::SkyWalking.NetworkProtocol.OSInfo(); + Osinfo = new global::SkyWalking.NetworkProtocol.OSInfo(); } Osinfo.MergeFrom(other.Osinfo); } @@ -655,9 +655,9 @@ public void MergeFrom(pb::CodedInputStream input) { } case 34: { if (osinfo_ == null) { - osinfo_ = new global::SkyWalking.NetworkProtocol.OSInfo(); + Osinfo = new global::SkyWalking.NetworkProtocol.OSInfo(); } - input.ReadMessage(osinfo_); + input.ReadMessage(Osinfo); break; } } @@ -1401,7 +1401,7 @@ public void MergeFrom(ServiceNameMappingElement other) { } if (other.element_ != null) { if (element_ == null) { - element_ = new global::SkyWalking.NetworkProtocol.ServiceNameElement(); + Element = new global::SkyWalking.NetworkProtocol.ServiceNameElement(); } Element.MergeFrom(other.Element); } @@ -1422,9 +1422,9 @@ public void MergeFrom(pb::CodedInputStream input) { } case 18: { if (element_ == null) { - element_ = new global::SkyWalking.NetworkProtocol.ServiceNameElement(); + Element = new global::SkyWalking.NetworkProtocol.ServiceNameElement(); } - input.ReadMessage(element_); + input.ReadMessage(Element); break; } } @@ -1609,7 +1609,7 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 24: { - srcSpanType_ = (global::SkyWalking.NetworkProtocol.SpanType) input.ReadEnum(); + SrcSpanType = (global::SkyWalking.NetworkProtocol.SpanType) input.ReadEnum(); break; } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryServiceGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryServiceGrpc.cs index d758e726d..270932194 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryServiceGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/DiscoveryServiceGrpc.cs @@ -56,6 +56,7 @@ public static partial class InstanceDiscoveryService } /// Base class for server-side implementations of InstanceDiscoveryService + [grpc::BindServiceMethod(typeof(InstanceDiscoveryService), "BindService")] public abstract partial class InstanceDiscoveryServiceBase { public virtual global::System.Threading.Tasks.Task registerInstance(global::SkyWalking.NetworkProtocol.ApplicationInstance request, grpc::ServerCallContext context) @@ -75,7 +76,7 @@ public partial class InstanceDiscoveryServiceClient : grpc::ClientBaseCreates a new client for InstanceDiscoveryService /// The channel to use to make remote calls. - public InstanceDiscoveryServiceClient(grpc::Channel channel) : base(channel) + public InstanceDiscoveryServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for InstanceDiscoveryService that uses a custom CallInvoker. @@ -141,14 +142,14 @@ protected override InstanceDiscoveryServiceClient NewInstance(ClientBaseConfigur .AddMethod(__Method_heartbeat, serviceImpl.heartbeat).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, InstanceDiscoveryServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_registerInstance, serviceImpl.registerInstance); - serviceBinder.AddMethod(__Method_heartbeat, serviceImpl.heartbeat); + serviceBinder.AddMethod(__Method_registerInstance, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.registerInstance)); + serviceBinder.AddMethod(__Method_heartbeat, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.heartbeat)); } } @@ -176,6 +177,7 @@ public static partial class ServiceNameDiscoveryService } /// Base class for server-side implementations of ServiceNameDiscoveryService + [grpc::BindServiceMethod(typeof(ServiceNameDiscoveryService), "BindService")] public abstract partial class ServiceNameDiscoveryServiceBase { public virtual global::System.Threading.Tasks.Task discovery(global::SkyWalking.NetworkProtocol.ServiceNameCollection request, grpc::ServerCallContext context) @@ -190,7 +192,7 @@ public partial class ServiceNameDiscoveryServiceClient : grpc::ClientBaseCreates a new client for ServiceNameDiscoveryService /// The channel to use to make remote calls. - public ServiceNameDiscoveryServiceClient(grpc::Channel channel) : base(channel) + public ServiceNameDiscoveryServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for ServiceNameDiscoveryService that uses a custom CallInvoker. @@ -239,13 +241,13 @@ protected override ServiceNameDiscoveryServiceClient NewInstance(ClientBaseConfi .AddMethod(__Method_discovery, serviceImpl.discovery).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, ServiceNameDiscoveryServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_discovery, serviceImpl.discovery); + serviceBinder.AddMethod(__Method_discovery, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.discovery)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/InstancePingGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/InstancePingGrpc.cs index 08b6d1b32..66a36b00e 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/InstancePingGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/InstancePingGrpc.cs @@ -47,6 +47,7 @@ public static partial class ServiceInstancePing } /// Base class for server-side implementations of ServiceInstancePing + [grpc::BindServiceMethod(typeof(ServiceInstancePing), "BindService")] public abstract partial class ServiceInstancePingBase { public virtual global::System.Threading.Tasks.Task doPing(global::SkyWalking.NetworkProtocol.ServiceInstancePingPkg request, grpc::ServerCallContext context) @@ -61,7 +62,7 @@ public partial class ServiceInstancePingClient : grpc::ClientBaseCreates a new client for ServiceInstancePing /// The channel to use to make remote calls. - public ServiceInstancePingClient(grpc::Channel channel) : base(channel) + public ServiceInstancePingClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for ServiceInstancePing that uses a custom CallInvoker. @@ -110,13 +111,13 @@ protected override ServiceInstancePingClient NewInstance(ClientBaseConfiguration .AddMethod(__Method_doPing, serviceImpl.doPing).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, ServiceInstancePingBase serviceImpl) { - serviceBinder.AddMethod(__Method_doPing, serviceImpl.doPing); + serviceBinder.AddMethod(__Method_doPing, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.doPing)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVM.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVM.cs index 6a5acb737..fab3403fa 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVM.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVM.cs @@ -245,7 +245,7 @@ public void MergeFrom(JVMMetric other) { } if (other.cpu_ != null) { if (cpu_ == null) { - cpu_ = new global::SkyWalking.NetworkProtocol.CPU(); + Cpu = new global::SkyWalking.NetworkProtocol.CPU(); } Cpu.MergeFrom(other.Cpu); } @@ -269,9 +269,9 @@ public void MergeFrom(pb::CodedInputStream input) { } case 18: { if (cpu_ == null) { - cpu_ = new global::SkyWalking.NetworkProtocol.CPU(); + Cpu = new global::SkyWalking.NetworkProtocol.CPU(); } - input.ReadMessage(cpu_); + input.ReadMessage(Cpu); break; } case 26: { @@ -749,7 +749,7 @@ public void MergeFrom(pb::CodedInputStream input) { _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { - type_ = (global::SkyWalking.NetworkProtocol.PoolType) input.ReadEnum(); + Type = (global::SkyWalking.NetworkProtocol.PoolType) input.ReadEnum(); break; } case 16: { @@ -942,7 +942,7 @@ public void MergeFrom(pb::CodedInputStream input) { _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { - phrase_ = (global::SkyWalking.NetworkProtocol.GCPhrase) input.ReadEnum(); + Phrase = (global::SkyWalking.NetworkProtocol.GCPhrase) input.ReadEnum(); break; } case 16: { diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVMMetricGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVMMetricGrpc.cs index 4ea66005d..c4dedad7e 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVMMetricGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVMMetricGrpc.cs @@ -47,6 +47,7 @@ public static partial class JVMMetricReportService } /// Base class for server-side implementations of JVMMetricReportService + [grpc::BindServiceMethod(typeof(JVMMetricReportService), "BindService")] public abstract partial class JVMMetricReportServiceBase { public virtual global::System.Threading.Tasks.Task collect(global::SkyWalking.NetworkProtocol.JVMMetricCollection request, grpc::ServerCallContext context) @@ -61,7 +62,7 @@ public partial class JVMMetricReportServiceClient : grpc::ClientBaseCreates a new client for JVMMetricReportService /// The channel to use to make remote calls. - public JVMMetricReportServiceClient(grpc::Channel channel) : base(channel) + public JVMMetricReportServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for JVMMetricReportService that uses a custom CallInvoker. @@ -110,13 +111,13 @@ protected override JVMMetricReportServiceClient NewInstance(ClientBaseConfigurat .AddMethod(__Method_collect, serviceImpl.collect).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, JVMMetricReportServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_collect, serviceImpl.collect); + serviceBinder.AddMethod(__Method_collect, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.collect)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVMMetricsServiceGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVMMetricsServiceGrpc.cs index 011c62bbc..c20e9c53b 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVMMetricsServiceGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/JVMMetricsServiceGrpc.cs @@ -47,6 +47,7 @@ public static partial class JVMMetricsService } /// Base class for server-side implementations of JVMMetricsService + [grpc::BindServiceMethod(typeof(JVMMetricsService), "BindService")] public abstract partial class JVMMetricsServiceBase { public virtual global::System.Threading.Tasks.Task collect(global::SkyWalking.NetworkProtocol.JVMMetrics request, grpc::ServerCallContext context) @@ -61,7 +62,7 @@ public partial class JVMMetricsServiceClient : grpc::ClientBaseCreates a new client for JVMMetricsService /// The channel to use to make remote calls. - public JVMMetricsServiceClient(grpc::Channel channel) : base(channel) + public JVMMetricsServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for JVMMetricsService that uses a custom CallInvoker. @@ -110,13 +111,13 @@ protected override JVMMetricsServiceClient NewInstance(ClientBaseConfiguration c .AddMethod(__Method_collect, serviceImpl.collect).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, JVMMetricsServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_collect, serviceImpl.collect); + serviceBinder.AddMethod(__Method_collect, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.collect)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/NetworkAddressRegisterServiceGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/NetworkAddressRegisterServiceGrpc.cs index 8029a07a3..e9b914762 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/NetworkAddressRegisterServiceGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/NetworkAddressRegisterServiceGrpc.cs @@ -47,6 +47,7 @@ public static partial class NetworkAddressRegisterService } /// Base class for server-side implementations of NetworkAddressRegisterService + [grpc::BindServiceMethod(typeof(NetworkAddressRegisterService), "BindService")] public abstract partial class NetworkAddressRegisterServiceBase { public virtual global::System.Threading.Tasks.Task batchRegister(global::SkyWalking.NetworkProtocol.NetworkAddresses request, grpc::ServerCallContext context) @@ -61,7 +62,7 @@ public partial class NetworkAddressRegisterServiceClient : grpc::ClientBaseCreates a new client for NetworkAddressRegisterService /// The channel to use to make remote calls. - public NetworkAddressRegisterServiceClient(grpc::Channel channel) : base(channel) + public NetworkAddressRegisterServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for NetworkAddressRegisterService that uses a custom CallInvoker. @@ -110,13 +111,13 @@ protected override NetworkAddressRegisterServiceClient NewInstance(ClientBaseCon .AddMethod(__Method_batchRegister, serviceImpl.batchRegister).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, NetworkAddressRegisterServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_batchRegister, serviceImpl.batchRegister); + serviceBinder.AddMethod(__Method_batchRegister, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.batchRegister)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Register.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Register.cs index 1d3352906..927d0d482 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Register.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Register.cs @@ -1559,7 +1559,7 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 40: { - from_ = (global::SkyWalking.NetworkProtocol.DetectPoint) input.ReadEnum(); + From = (global::SkyWalking.NetworkProtocol.DetectPoint) input.ReadEnum(); break; } } @@ -1893,7 +1893,7 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 32: { - from_ = (global::SkyWalking.NetworkProtocol.DetectPoint) input.ReadEnum(); + From = (global::SkyWalking.NetworkProtocol.DetectPoint) input.ReadEnum(); break; } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/RegisterGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/RegisterGrpc.cs index 8b8b29824..2f755a257 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/RegisterGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/RegisterGrpc.cs @@ -86,6 +86,7 @@ public static partial class Register } /// Base class for server-side implementations of Register + [grpc::BindServiceMethod(typeof(Register), "BindService")] public abstract partial class RegisterBase { public virtual global::System.Threading.Tasks.Task doServiceRegister(global::SkyWalking.NetworkProtocol.Services request, grpc::ServerCallContext context) @@ -120,7 +121,7 @@ public partial class RegisterClient : grpc::ClientBase { /// Creates a new client for Register /// The channel to use to make remote calls. - public RegisterClient(grpc::Channel channel) : base(channel) + public RegisterClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for Register that uses a custom CallInvoker. @@ -237,17 +238,17 @@ protected override RegisterClient NewInstance(ClientBaseConfiguration configurat .AddMethod(__Method_doServiceAndNetworkAddressMappingRegister, serviceImpl.doServiceAndNetworkAddressMappingRegister).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, RegisterBase serviceImpl) { - serviceBinder.AddMethod(__Method_doServiceRegister, serviceImpl.doServiceRegister); - serviceBinder.AddMethod(__Method_doServiceInstanceRegister, serviceImpl.doServiceInstanceRegister); - serviceBinder.AddMethod(__Method_doEndpointRegister, serviceImpl.doEndpointRegister); - serviceBinder.AddMethod(__Method_doNetworkAddressRegister, serviceImpl.doNetworkAddressRegister); - serviceBinder.AddMethod(__Method_doServiceAndNetworkAddressMappingRegister, serviceImpl.doServiceAndNetworkAddressMappingRegister); + serviceBinder.AddMethod(__Method_doServiceRegister, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.doServiceRegister)); + serviceBinder.AddMethod(__Method_doServiceInstanceRegister, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.doServiceInstanceRegister)); + serviceBinder.AddMethod(__Method_doEndpointRegister, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.doEndpointRegister)); + serviceBinder.AddMethod(__Method_doNetworkAddressRegister, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.doNetworkAddressRegister)); + serviceBinder.AddMethod(__Method_doServiceAndNetworkAddressMappingRegister, serviceImpl == null ? null : new grpc::UnaryServerMethod(serviceImpl.doServiceAndNetworkAddressMappingRegister)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Service-meshGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Service-meshGrpc.cs index 24a58a6d6..93206fa48 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Service-meshGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Service-meshGrpc.cs @@ -46,6 +46,7 @@ public static partial class ServiceMeshMetricService } /// Base class for server-side implementations of ServiceMeshMetricService + [grpc::BindServiceMethod(typeof(ServiceMeshMetricService), "BindService")] public abstract partial class ServiceMeshMetricServiceBase { public virtual global::System.Threading.Tasks.Task collect(grpc::IAsyncStreamReader requestStream, grpc::ServerCallContext context) @@ -60,7 +61,7 @@ public partial class ServiceMeshMetricServiceClient : grpc::ClientBaseCreates a new client for ServiceMeshMetricService /// The channel to use to make remote calls. - public ServiceMeshMetricServiceClient(grpc::Channel channel) : base(channel) + public ServiceMeshMetricServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for ServiceMeshMetricService that uses a custom CallInvoker. @@ -101,13 +102,13 @@ protected override ServiceMeshMetricServiceClient NewInstance(ClientBaseConfigur .AddMethod(__Method_collect, serviceImpl.collect).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, ServiceMeshMetricServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_collect, serviceImpl.collect); + serviceBinder.AddMethod(__Method_collect, serviceImpl == null ? null : new grpc::ClientStreamingServerMethod(serviceImpl.collect)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ServiceMesh.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ServiceMesh.cs index 8d5897fa8..b916ca872 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ServiceMesh.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/ServiceMesh.cs @@ -593,11 +593,11 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 120: { - protocol_ = (global::Protocol) input.ReadEnum(); + Protocol = (global::Protocol) input.ReadEnum(); break; } case 128: { - detectPoint_ = (global::SkyWalking.NetworkProtocol.DetectPoint) input.ReadEnum(); + DetectPoint = (global::SkyWalking.NetworkProtocol.DetectPoint) input.ReadEnum(); break; } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Trace.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Trace.cs index d5b277ca5..8752705e5 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Trace.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/Trace.cs @@ -248,7 +248,7 @@ public void MergeFrom(SegmentObject other) { } if (other.traceSegmentId_ != null) { if (traceSegmentId_ == null) { - traceSegmentId_ = new global::SkyWalking.NetworkProtocol.UniqueId(); + TraceSegmentId = new global::SkyWalking.NetworkProtocol.UniqueId(); } TraceSegmentId.MergeFrom(other.TraceSegmentId); } @@ -275,9 +275,9 @@ public void MergeFrom(pb::CodedInputStream input) { break; case 10: { if (traceSegmentId_ == null) { - traceSegmentId_ = new global::SkyWalking.NetworkProtocol.UniqueId(); + TraceSegmentId = new global::SkyWalking.NetworkProtocol.UniqueId(); } - input.ReadMessage(traceSegmentId_); + input.ReadMessage(TraceSegmentId); break; } case 18: { @@ -622,7 +622,7 @@ public void MergeFrom(SegmentReference other) { } if (other.parentTraceSegmentId_ != null) { if (parentTraceSegmentId_ == null) { - parentTraceSegmentId_ = new global::SkyWalking.NetworkProtocol.UniqueId(); + ParentTraceSegmentId = new global::SkyWalking.NetworkProtocol.UniqueId(); } ParentTraceSegmentId.MergeFrom(other.ParentTraceSegmentId); } @@ -665,14 +665,14 @@ public void MergeFrom(pb::CodedInputStream input) { _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { - refType_ = (global::SkyWalking.NetworkProtocol.RefType) input.ReadEnum(); + RefType = (global::SkyWalking.NetworkProtocol.RefType) input.ReadEnum(); break; } case 18: { if (parentTraceSegmentId_ == null) { - parentTraceSegmentId_ = new global::SkyWalking.NetworkProtocol.UniqueId(); + ParentTraceSegmentId = new global::SkyWalking.NetworkProtocol.UniqueId(); } - input.ReadMessage(parentTraceSegmentId_); + input.ReadMessage(ParentTraceSegmentId); break; } case 24: { @@ -1209,11 +1209,11 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 80: { - spanType_ = (global::SkyWalking.NetworkProtocol.SpanType) input.ReadEnum(); + SpanType = (global::SkyWalking.NetworkProtocol.SpanType) input.ReadEnum(); break; } case 88: { - spanLayer_ = (global::SkyWalking.NetworkProtocol.SpanLayer) input.ReadEnum(); + SpanLayer = (global::SkyWalking.NetworkProtocol.SpanLayer) input.ReadEnum(); break; } case 96: { diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceGrpc.cs index 5f9ad3af0..6c5b57c7b 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceGrpc.cs @@ -47,6 +47,7 @@ public static partial class TraceSegmentReportService } /// Base class for server-side implementations of TraceSegmentReportService + [grpc::BindServiceMethod(typeof(TraceSegmentReportService), "BindService")] public abstract partial class TraceSegmentReportServiceBase { public virtual global::System.Threading.Tasks.Task collect(grpc::IAsyncStreamReader requestStream, grpc::ServerCallContext context) @@ -61,7 +62,7 @@ public partial class TraceSegmentReportServiceClient : grpc::ClientBaseCreates a new client for TraceSegmentReportService /// The channel to use to make remote calls. - public TraceSegmentReportServiceClient(grpc::Channel channel) : base(channel) + public TraceSegmentReportServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for TraceSegmentReportService that uses a custom CallInvoker. @@ -102,13 +103,13 @@ protected override TraceSegmentReportServiceClient NewInstance(ClientBaseConfigu .AddMethod(__Method_collect, serviceImpl.collect).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, TraceSegmentReportServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_collect, serviceImpl.collect); + serviceBinder.AddMethod(__Method_collect, serviceImpl == null ? null : new grpc::ClientStreamingServerMethod(serviceImpl.collect)); } } diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceSegmentService.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceSegmentService.cs index 0e9a97f16..8b1db78ca 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceSegmentService.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceSegmentService.cs @@ -250,7 +250,7 @@ public void MergeFrom(TraceSegmentObject other) { } if (other.traceSegmentId_ != null) { if (traceSegmentId_ == null) { - traceSegmentId_ = new global::SkyWalking.NetworkProtocol.UniqueId(); + TraceSegmentId = new global::SkyWalking.NetworkProtocol.UniqueId(); } TraceSegmentId.MergeFrom(other.TraceSegmentId); } @@ -277,9 +277,9 @@ public void MergeFrom(pb::CodedInputStream input) { break; case 10: { if (traceSegmentId_ == null) { - traceSegmentId_ = new global::SkyWalking.NetworkProtocol.UniqueId(); + TraceSegmentId = new global::SkyWalking.NetworkProtocol.UniqueId(); } - input.ReadMessage(traceSegmentId_); + input.ReadMessage(TraceSegmentId); break; } case 18: { @@ -624,7 +624,7 @@ public void MergeFrom(TraceSegmentReference other) { } if (other.parentTraceSegmentId_ != null) { if (parentTraceSegmentId_ == null) { - parentTraceSegmentId_ = new global::SkyWalking.NetworkProtocol.UniqueId(); + ParentTraceSegmentId = new global::SkyWalking.NetworkProtocol.UniqueId(); } ParentTraceSegmentId.MergeFrom(other.ParentTraceSegmentId); } @@ -667,14 +667,14 @@ public void MergeFrom(pb::CodedInputStream input) { _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); break; case 8: { - refType_ = (global::SkyWalking.NetworkProtocol.RefType) input.ReadEnum(); + RefType = (global::SkyWalking.NetworkProtocol.RefType) input.ReadEnum(); break; } case 18: { if (parentTraceSegmentId_ == null) { - parentTraceSegmentId_ = new global::SkyWalking.NetworkProtocol.UniqueId(); + ParentTraceSegmentId = new global::SkyWalking.NetworkProtocol.UniqueId(); } - input.ReadMessage(parentTraceSegmentId_); + input.ReadMessage(ParentTraceSegmentId); break; } case 24: { @@ -1211,11 +1211,11 @@ public void MergeFrom(pb::CodedInputStream input) { break; } case 80: { - spanType_ = (global::SkyWalking.NetworkProtocol.SpanType) input.ReadEnum(); + SpanType = (global::SkyWalking.NetworkProtocol.SpanType) input.ReadEnum(); break; } case 88: { - spanLayer_ = (global::SkyWalking.NetworkProtocol.SpanLayer) input.ReadEnum(); + SpanLayer = (global::SkyWalking.NetworkProtocol.SpanLayer) input.ReadEnum(); break; } case 96: { diff --git a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceSegmentServiceGrpc.cs b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceSegmentServiceGrpc.cs index 80ac74ece..14e0eae7d 100644 --- a/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceSegmentServiceGrpc.cs +++ b/src/Surging.Apm/SkyApm.Transport.Grpc.Protocol/generated/TraceSegmentServiceGrpc.cs @@ -47,6 +47,7 @@ public static partial class TraceSegmentService } /// Base class for server-side implementations of TraceSegmentService + [grpc::BindServiceMethod(typeof(TraceSegmentService), "BindService")] public abstract partial class TraceSegmentServiceBase { public virtual global::System.Threading.Tasks.Task collect(grpc::IAsyncStreamReader requestStream, grpc::ServerCallContext context) @@ -61,7 +62,7 @@ public partial class TraceSegmentServiceClient : grpc::ClientBaseCreates a new client for TraceSegmentService /// The channel to use to make remote calls. - public TraceSegmentServiceClient(grpc::Channel channel) : base(channel) + public TraceSegmentServiceClient(grpc::ChannelBase channel) : base(channel) { } /// Creates a new client for TraceSegmentService that uses a custom CallInvoker. @@ -102,13 +103,13 @@ protected override TraceSegmentServiceClient NewInstance(ClientBaseConfiguration .AddMethod(__Method_collect, serviceImpl.collect).Build(); } - /// Register service method implementations with a service binder. Useful when customizing the service binding logic. + /// Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// Note: this method is part of an experimental API that can change or be removed without any prior notice. /// Service methods will be bound by calling AddMethod on this object. /// An object implementing the server-side handling logic. public static void BindService(grpc::ServiceBinderBase serviceBinder, TraceSegmentServiceBase serviceImpl) { - serviceBinder.AddMethod(__Method_collect, serviceImpl.collect); + serviceBinder.AddMethod(__Method_collect, serviceImpl == null ? null : new grpc::ClientStreamingServerMethod(serviceImpl.collect)); } } diff --git a/src/Surging.Apm/Surging.Apm.Skywalking/Configuration/ConfigurationFactory.cs b/src/Surging.Apm/Surging.Apm.Skywalking/Configuration/ConfigurationFactory.cs index d0f60483d..ac51c0406 100644 --- a/src/Surging.Apm/Surging.Apm.Skywalking/Configuration/ConfigurationFactory.cs +++ b/src/Surging.Apm/Surging.Apm.Skywalking/Configuration/ConfigurationFactory.cs @@ -55,9 +55,11 @@ public IConfiguration Create() builder.AddJsonFile("skyapm.json", true) .AddJsonFile($"skyapm.{_environmentProvider.EnvironmentName}.json", true); - var skyapmPath = Path.Combine(AppConfig.ServerOptions.RootPath, "skyapm.json"); - builder.AddJsonFile(skyapmPath, true); - + if (!string.IsNullOrEmpty(AppConfig.ServerOptions.RootPath)) + { + var skyapmPath = Path.Combine(AppConfig.ServerOptions.RootPath, "skyapm.json"); + builder.AddJsonFile(skyapmPath, true); + } if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(CONFIG_FILE_PATH_COMPATIBLE))) { builder.AddJsonFile(Environment.GetEnvironmentVariable(CONFIG_FILE_PATH_COMPATIBLE), false); diff --git a/src/Surging.Apm/Surging.Apm.Skywalking/ContainerBuilderExtensions.cs b/src/Surging.Apm/Surging.Apm.Skywalking/ContainerBuilderExtensions.cs new file mode 100644 index 000000000..c18cc9308 --- /dev/null +++ b/src/Surging.Apm/Surging.Apm.Skywalking/ContainerBuilderExtensions.cs @@ -0,0 +1,86 @@ +using Autofac; +using Surging.Apm.Skywalking.Abstractions; +using Surging.Apm.Skywalking.Abstractions.Common.Tracing; +using Surging.Apm.Skywalking.Abstractions.Common.Transport; +using Surging.Apm.Skywalking.Abstractions.Config; +using Surging.Apm.Skywalking.Abstractions.Tracing; +using Surging.Apm.Skywalking.Abstractions.Transport; +using Surging.Apm.Skywalking.Configuration; +using Surging.Apm.Skywalking.Core; +using Surging.Apm.Skywalking.Core.Common; +using Surging.Apm.Skywalking.Core.Diagnostics; +using Surging.Apm.Skywalking.Core.Sampling; +using Surging.Apm.Skywalking.Core.Service; +using Surging.Apm.Skywalking.Core.Tracing; +using Surging.Apm.Skywalking.Transport.Grpc; +using Surging.Apm.Skywalking.Transport.Grpc.V5; +using Surging.Apm.Skywalking.Transport.Grpc.V6; +using Surging.Core.CPlatform; +using Surging.Core.CPlatform.Diagnostics; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Surging.Apm.Skywalking +{ + public static class ContainerBuilderExtensions + { + public static IServiceBuilder UseSkywalking(this IServiceBuilder builder) + { + var services = builder.Services; + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.Register(p => RuntimeEnvironment.Instance).SingleInstance(); + services.RegisterType().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + return AddTracing(builder).AddSampling().AddGrpcTransport(); + } + + private static IServiceBuilder AddTracing(this IServiceBuilder builder) + { + var services = builder.Services; + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + return builder; + } + + private static IServiceBuilder AddSampling(this IServiceBuilder builder) + { + var services = builder.Services; + services.RegisterType().SingleInstance(); + services.Register(p => p.Resolve()).SingleInstance(); + services.Register(p => p.Resolve()).SingleInstance(); + services.RegisterType().As().SingleInstance(); + return builder; + } + + private static IServiceBuilder AddGrpcTransport(this IServiceBuilder builder) + { + var services = builder.Services; + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + services.RegisterType().As().SingleInstance(); + return builder; + } + } +} diff --git a/src/Surging.Core/Surging.Core.CPlatform/ContainerBuilderExtensions.cs b/src/Surging.Core/Surging.Core.CPlatform/ContainerBuilderExtensions.cs index 59991ea54..07e9429dc 100644 --- a/src/Surging.Core/Surging.Core.CPlatform/ContainerBuilderExtensions.cs +++ b/src/Surging.Core/Surging.Core.CPlatform/ContainerBuilderExtensions.cs @@ -535,7 +535,13 @@ public static IServiceBuilder RegisterServices(this IServiceBuilder builder, par .AsImplementedInterfaces(); services.RegisterAssemblyTypes(assembly) //注入实现IServiceBehavior接口并ModuleName为空的类,作为接口实现类 - .Where(t => typeof(IServiceBehavior).GetTypeInfo().IsAssignableFrom(t) && t.GetTypeInfo().GetCustomAttribute() == null).AsImplementedInterfaces(); + .Where(t => !typeof(ISingleInstance).GetTypeInfo().IsAssignableFrom(t) && + typeof(IServiceBehavior).GetTypeInfo().IsAssignableFrom(t) && t.GetTypeInfo().GetCustomAttribute() == null).AsImplementedInterfaces(); + + services.RegisterAssemblyTypes(assembly) + //注入实现IServiceBehavior接口并ModuleName为空的类,作为接口实现类 + .Where(t => typeof(ISingleInstance).GetTypeInfo().IsAssignableFrom(t) && + typeof(IServiceBehavior).GetTypeInfo().IsAssignableFrom(t) && t.GetTypeInfo().GetCustomAttribute() == null).SingleInstance().AsImplementedInterfaces(); var types = assembly.GetTypes().Where(t => typeof(IServiceBehavior).GetTypeInfo().IsAssignableFrom(t) && t.GetTypeInfo().GetCustomAttribute() != null); foreach (var type in types) diff --git a/src/Surging.Core/Surging.Core.CPlatform/Ioc/ISingleInstance.cs b/src/Surging.Core/Surging.Core.CPlatform/Ioc/ISingleInstance.cs new file mode 100644 index 000000000..624f33439 --- /dev/null +++ b/src/Surging.Core/Surging.Core.CPlatform/Ioc/ISingleInstance.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Surging.Core.CPlatform.Ioc +{ + public interface ISingleInstance + { + } +} diff --git a/src/Surging.Core/Surging.Core.ProxyGenerator/ContainerBuilderExtensions.cs b/src/Surging.Core/Surging.Core.ProxyGenerator/ContainerBuilderExtensions.cs index 35b67ed56..27109fcf9 100644 --- a/src/Surging.Core/Surging.Core.ProxyGenerator/ContainerBuilderExtensions.cs +++ b/src/Surging.Core/Surging.Core.ProxyGenerator/ContainerBuilderExtensions.cs @@ -5,7 +5,9 @@ using Surging.Core.ProxyGenerator.Interceptors; using Surging.Core.ProxyGenerator.Interceptors.Implementation; using Surging.Core.CPlatform.Runtime.Client; -using Surging.Core.CPlatform.Convertibles; +using Surging.Core.CPlatform.Convertibles; +using Surging.Core.ProxyGenerator.Diagnostics; +using Surging.Core.CPlatform.Diagnostics; namespace Surging.Core.ProxyGenerator { @@ -39,6 +41,13 @@ public static IServiceBuilder AddClientIntercepted(this IServiceBuilder builder, return builder; } + public static IServiceBuilder AddRpcTransportDiagnostic(this IServiceBuilder builder) + { + var services = builder.Services; + services.RegisterType().As().SingleInstance(); + return builder; + } + /// /// 添加客户端拦截 /// diff --git a/src/Surging.Core/Surging.Core.ServiceHosting.Extensions/Runtime/BackgroundServiceBehavior.cs b/src/Surging.Core/Surging.Core.ServiceHosting.Extensions/Runtime/BackgroundServiceBehavior.cs index 30faad4df..c196bda08 100644 --- a/src/Surging.Core/Surging.Core.ServiceHosting.Extensions/Runtime/BackgroundServiceBehavior.cs +++ b/src/Surging.Core/Surging.Core.ServiceHosting.Extensions/Runtime/BackgroundServiceBehavior.cs @@ -15,7 +15,7 @@ namespace Surging.Core.ServiceHosting.Extensions.Runtime public abstract class BackgroundServiceBehavior : IServiceBehavior, IDisposable { private Task _executingTask; - private readonly CancellationTokenSource _stoppingCts = new CancellationTokenSource(); + private CancellationTokenSource _stoppingCts = new CancellationTokenSource(); public T CreateProxy(string key) where T : class { @@ -79,9 +79,10 @@ public void Publish(IntegrationEvent @event) protected abstract Task ExecuteAsync(CancellationToken stoppingToken); public virtual Task StartAsync(CancellationToken cancellationToken) - { + { + _stoppingCts = new CancellationTokenSource(); _executingTask = ExecutingAsync(_stoppingCts.Token); - + if (_executingTask.IsCompleted) { return _executingTask; diff --git a/src/Surging.Core/Surging.Core.Stage/StageModule.cs b/src/Surging.Core/Surging.Core.Stage/StageModule.cs index a20fdc47e..4d90ed042 100644 --- a/src/Surging.Core/Surging.Core.Stage/StageModule.cs +++ b/src/Surging.Core/Surging.Core.Stage/StageModule.cs @@ -41,6 +41,7 @@ public override void Initialize(ApplicationInitializationContext context) { context.Builder.UseCors(builder => { + if(policy.Origins!=null) builder.WithOrigins(policy.Origins); if (policy.AllowAnyHeader) builder.AllowAnyHeader(); diff --git a/src/Surging.IModuleServices/Surging.IModuleServices.Common/IWorkService.cs b/src/Surging.IModuleServices/Surging.IModuleServices.Common/IWorkService.cs index ce09dfa93..3d803ed36 100644 --- a/src/Surging.IModuleServices/Surging.IModuleServices.Common/IWorkService.cs +++ b/src/Surging.IModuleServices/Surging.IModuleServices.Common/IWorkService.cs @@ -12,5 +12,9 @@ namespace Surging.IModuleServices.Common public interface IWorkService : IServiceKey { Task AddWork(Message message); + + Task StartAsync(); + + Task StopAsync(); } } diff --git a/src/Surging.Modules/Surging.Modules.Common/Domain/WorkService.cs b/src/Surging.Modules/Surging.Modules.Common/Domain/WorkService.cs index 4c95f43d1..333be6f6c 100644 --- a/src/Surging.Modules/Surging.Modules.Common/Domain/WorkService.cs +++ b/src/Surging.Modules/Surging.Modules.Common/Domain/WorkService.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using Surging.Core.CPlatform.Ioc; using Surging.Core.ProxyGenerator; using Surging.Core.ServiceHosting.Extensions.Runtime; using Surging.IModuleServices.Common; @@ -11,11 +12,12 @@ namespace Surging.Modules.Common.Domain { - public class WorkService : BackgroundServiceBehavior, IWorkService + public class WorkService : BackgroundServiceBehavior, IWorkService, ISingleInstance { private readonly ILogger _logger; - private readonly Queue _queue = new Queue(); + private readonly Queue _queue = new Queue(); private readonly IServiceProxyProvider _serviceProxyProvider; + private CancellationToken _token; public WorkService(ILogger logger, IServiceProxyProvider serviceProxyProvider) { @@ -31,14 +33,38 @@ public Task AddWork(Message message) protected override async Task ExecuteAsync(CancellationToken stoppingToken) { - _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); - _queue.TryDequeue(out Message message); - if (message != null) + try { - var result= await _serviceProxyProvider.Invoke(message.Parameters, message.RoutePath, message.ServiceKey); - _logger.LogInformation("Invoke Service at: {time}", DateTimeOffset.Now); + _token = stoppingToken; + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + _queue.TryDequeue(out Message message); + if (message != null) + { + var result = await _serviceProxyProvider.Invoke(message.Parameters, message.RoutePath, message.ServiceKey); + _logger.LogInformation("Invoke Service at: {time},Invoke result:{result}", DateTimeOffset.Now, result); + } + if (!_token.IsCancellationRequested) + await Task.Delay(1000, stoppingToken); + } + catch (Exception ex){ + _logger.LogError("WorkService execute error, message:{message} ,trace info:{trace} ", ex.Message, ex.StackTrace); + } + } + + public async Task StartAsync() + { + if (_token.IsCancellationRequested) + { + await base.StartAsync(_token); + } + } + + public async Task StopAsync() + { + if (!_token.IsCancellationRequested) + { + await base.StopAsync(_token); } - await Task.Delay(1000, stoppingToken); } } }