public AzureServiceFabricSerilogEnricher(ServiceContext context) { _properties = ServiceFabricHelpers.GetEnvironmentProperties(context) .Select(pair => new LogEventProperty(pair.Key, new ScalarValue(pair.Value))) .ToList(); }
public OrleansTestActorService(StatelessServiceContext context) : base(context) { var esLogsConfig = new FabricConfigProvider <ElasticSearchOutputConfig>("ElasticSearchLogs").Config; var esMetricsConfig = new FabricConfigProvider <ElasticSearchOutputConfig>("ElasticSearchMetrics").Config; var logger = new LoggerConfiguration() .MinimumLevel.Verbose() .Enrich.With(new AzureServiceFabricSerilogEnricher(context)) .Enrich.With <ExceptionEnricher>() .Enrich.With <ActivityIdSerilogEnricher>() .WriteTo.Elasticsearch( new ElasticsearchSinkOptions(new Uri(esLogsConfig.ElasticSearchUri)) { IndexFormat = $"{esLogsConfig.ElasticSearchIndexName}-{{0:yyyy.MM.dd}}" }) .CreateLogger(); Log.Logger = logger; //Metric.Config.WithAllCounters(); _disposable = new TelemetryPipe() .CollectMetricsNet(10, ServiceFabricHelpers.GetEnvironmentProperties(context), true) .SendToElasticSearch(esMetricsConfig) .Start(); TraceLogger.BulkMessageInterval = TimeSpan.FromSeconds(10); Logger.TelemetryConsumers.Add(new SerilogTelemetryConsumer()); Logger.TelemetryConsumers.Add(new MetricNetTelemetryConsumer()); }
private void ConfigureApi(IApplicationBuilder app) { app.UseExceptionHandler(ConfigureApiExceptions); var logger = app.ApplicationServices.GetRequiredService <ILogger <Startup> >(); logger.LogInformation( "Configuring API, env: '{env}', isDev: {isDev}, inSF: {inSF}, forceLocal: '{forceLocal}'", HostingEnvironment.EnvironmentName, HostingEnvironment.IsDevelopment(), ServiceFabricHelpers.RunningInServiceFabric(), Configuration["ForceLocalApi"] ); if (HostingEnvironment.IsDevelopment() && !ServiceFabricHelpers.RunningInServiceFabric() && !string.Equals( Configuration["ForceLocalApi"], true.ToString(), StringComparison.OrdinalIgnoreCase)) { // Redirect api requests to prod when running locally outside of service fabric // This is for the `ng serve` local debugging case for the website app.MapWhen( ctx => IsGet(ctx) && ctx.Request.Path.StartsWithSegments("/api") && !ctx.Request.Path.Value.EndsWith("swagger.json"), a => { a.Run(ApiRedirectHandler); }); } app.Use( (ctx, next) => { if (ctx.Request.Path == "/api/swagger.json") { var vcp = ctx.RequestServices.GetRequiredService <VersionedControllerProvider>(); string highestVersion = vcp.Versions.Keys.OrderByDescending(n => n).First(); ctx.Request.Path = $"/api/{highestVersion}/swagger.json"; } return(next()); }); app.UseSwagger(); app.UseAuthentication(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(e => { e.MapRazorPages(); e.MapControllers(); }); }
public GatewayService(StatelessServiceContext context) : base(context) { WinApi.TimeBeginPeriod(1); //improve sleep precision for polling type transports float timeoutDebugMultiplier = 1; var builder = new ContainerBuilder(); var esLogsConfig = new FabricConfigProvider <ElasticSearchOutputConfig>("ElasticSearchLogs").Config; var esMetricsConfig = new FabricConfigProvider <ElasticSearchOutputConfig>("ElasticSearchMetrics").Config; var logger = new LoggerConfiguration() .ConfigureMOUSETypesDestructure() .MinimumLevel.Error() .Enrich.With(new AzureServiceFabricSerilogEnricher(context)) .Enrich.With <ExceptionEnricher>() .Enrich.With <ActivityIdSerilogEnricher>() .WriteTo.Elasticsearch( new ElasticsearchSinkOptions(new Uri(esLogsConfig.ElasticSearchUri)) { IndexFormat = $"{esLogsConfig.ElasticSearchIndexName}-{{0:yyyy.MM.dd}}" }) .CreateLogger(); Log.Logger = logger; builder.RegisterInstance(logger).As <ILogger>(); builder.RegisterType <SerilogCoreEvents>().As <ICoreEvents>(); builder.RegisterType <SerilogActorCoreEvents>().As <IActorCoreEvents>(); builder.RegisterType <SerilogLidgrenEvents>().As <ILidgrenEvents>(); Metric.Config.WithAllCounters(); _metricsSubscription = new TelemetryPipe() .CollectMetricsNet(5, ServiceFabricHelpers.GetEnvironmentProperties(context), true) .SendToElasticSearch(esMetricsConfig) .Start(); builder.Register( c => new ProtobufMessageSerializer(typeof(Message).Assembly, typeof(TestStateless).Assembly)) .As <IMessageSerializer>(); var publicEndpoint = FabricRuntime.GetActivationContext().GetEndpoint("Public"); var public2Endpoint = FabricRuntime.GetActivationContext().GetEndpoint("Public2"); var public3Endpoint = FabricRuntime.GetActivationContext().GetEndpoint("Public3"); var nodeIP = Dns.GetHostAddresses(FabricRuntime.GetNodeContext().IPAddressOrFQDN).First(x => x.AddressFamily == AddressFamily.InterNetwork); var publicNetConfig = new NetPeerConfiguration("PublicNet") { LocalAddress = nodeIP, MaximumConnections = 10000, AcceptIncomingConnections = true, Port = publicEndpoint.Port, ConnectionTimeout = 10 * timeoutDebugMultiplier }; var public2NetConfig = new NetPeerConfiguration("PublicNet") { LocalAddress = nodeIP, MaximumConnections = 10000, AcceptIncomingConnections = true, Port = public2Endpoint.Port, ConnectionTimeout = 10 * timeoutDebugMultiplier }; var public3NetConfig = new NetPeerConfiguration("PublicNet") { LocalAddress = nodeIP, MaximumConnections = 10000, AcceptIncomingConnections = true, Port = public3Endpoint.Port, ConnectionTimeout = 10 * timeoutDebugMultiplier }; var testActorsNetConfig = new NetPeerConfiguration("TestActors") { LocalAddress = nodeIP, AcceptIncomingConnections = false, Port = 0, ConnectionTimeout = 10 * timeoutDebugMultiplier }; builder.RegisterType <WcfBufferPool>().As <IBufferPool>(); builder.Register(c => { var messageSerialer = c.Resolve <IMessageSerializer>(); var coreLogger = c.Resolve <ICoreEvents>(); var nedNodeConfig = c.Resolve <INetNodeConfig>(); var bufferPool = c.Resolve <IBufferPool>(); return(new NetNode <SFActorsBackendClientNetChannel>("PublicNet", new LidgrenNetProvider(publicNetConfig, c.Resolve <ILidgrenEvents>()), coreLogger, messageSerialer, (node, transport) => new SFActorsBackendClientNetChannel(node, transport, messageSerialer, coreLogger, nedNodeConfig, bufferPool), nedNodeConfig)); }) .As <INetNode>() .SingleInstance(); builder.Register(c => { var actorSystem = c.Resolve <IActorSystem <ITestActor> >(); var messageSerialer = c.Resolve <IMessageSerializer>(); var coreLogger = c.Resolve <ICoreEvents>(); var netNodeConfig = c.Resolve <INetNodeConfig>(); var bufferPool = c.Resolve <IBufferPool>(); return(new NetNode <MouseActorsBackendClientNetChannel>("PublicNet2", new LidgrenNetProvider(public2NetConfig, c.Resolve <ILidgrenEvents>()), coreLogger, messageSerialer, (node, transport) => new MouseActorsBackendClientNetChannel(actorSystem, node, transport, messageSerialer, coreLogger, netNodeConfig, bufferPool), netNodeConfig)); }) .As <INetNode>() .SingleInstance(); builder.Register(c => { var messageSerialer = c.Resolve <IMessageSerializer>(); var coreLogger = c.Resolve <ICoreEvents>(); var netNodeConfig = c.Resolve <INetNodeConfig>(); var bufferPool = c.Resolve <IBufferPool>(); return(new NetNode <OrleansBackendClientNetChannel>("PublicNet3", new LidgrenNetProvider(public3NetConfig, c.Resolve <ILidgrenEvents>()), coreLogger, messageSerialer, (node, transport) => new OrleansBackendClientNetChannel(node, transport, messageSerialer, coreLogger, netNodeConfig, bufferPool), netNodeConfig)); }) .As <INetNode>() .SingleInstance(); builder.Register(c => new ServiceFabricActorSystemNetNode <ITestActor>("TestActors", new Uri("fabric:/MouseTestActor.Deploy/MouseTestActor"), new LidgrenNetProvider(testActorsNetConfig, c.Resolve <ILidgrenEvents>()), c.Resolve <IActorCoreEvents>(), c.Resolve <ICoreEvents>(), c.Resolve <IMessageSerializer>(), c.Resolve <INetNodeConfig>(), c.Resolve <IBufferPool>())) .As <INetNode>() .As <IActorSystem <ITestActor> >() .SingleInstance(); builder.Register(c => new NetNodeConfig() { SendTimeoutSec = (int)(10.0 * timeoutDebugMultiplier), ConnectTimeoutSec = (int)(10 * timeoutDebugMultiplier) }).As <INetNodeConfig>(); var container = builder.Build(); _netNodes = container.Resolve <IEnumerable <INetNode> >(); var config = new ClientConfiguration { //DataConnectionString = "DefaultEndpointsProtocol=https;AccountName=actorchatstorage;AccountKey=1hCY/Ak2TFrqE61cMhbPU5rkv9PuDfX7QQFU4tXCSc2AO78hLdm6u3PrGrZbUzOj7OkIZ93YKbU81VSVnBMbPg==", DataConnectionString = "UseDevelopmentStorage=true", PropagateActivityId = true, DefaultTraceLevel = Severity.Info, GatewayProvider = ClientConfiguration.GatewayProviderType.AzureTable, TraceToConsole = true, StatisticsCollectionLevel = StatisticsLevel.Critical, StatisticsLogWriteInterval = TimeSpan.FromDays(6), TraceFileName = null, TraceFilePattern = null, ResponseTimeout = TimeSpan.FromSeconds(90), StatisticsMetricsTableWriteInterval = TimeSpan.FromDays(6), StatisticsPerfCountersWriteInterval = TimeSpan.FromDays(6), }; OrleansFabricClient.Initialize(new Uri("fabric:/OrleansTest/OrleansTestActor"), config); }
public async Task SubmitForApproval(int month, int year) { var participations = await this.StateManager.GetStateAsync <Participations>(ActorStateKeyName); var records = participations.Records.FirstOrDefault(i => i.Month == month && i.Year == year); var submission = new ApprovalSubmission() { Activities = records.Activities.Where(i => !i.Approved).Select(i => i.Id).ToList(), Events = records.Events.Where(i => !i.Approved).Select(i => i.Id).ToList(), ParticipantActorId = this.Id }; var approval = _actorProxyFactory.CreateActorProxy <IApproval>(ServiceFabricHelpers.ApprovalServiceUri, ServiceFabricHelpers.CreateActorId()); await approval.Submit(submission); }
public override void Configure(IApplicationBuilder app) { if (HostingEnvironment.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); app.UseHttpsRedirection(); } // Add security headers app.Use( (ctx, next) => { ctx.Response.OnStarting(() => { if (!ctx.Response.Headers.ContainsKey("X-XSS-Protection")) { ctx.Response.Headers.Add("X-XSS-Protection", "1"); } if (!ctx.Response.Headers.ContainsKey("X-Frame-Options")) { ctx.Response.Headers.Add("X-Frame-Options", "DENY"); } if (!ctx.Response.Headers.ContainsKey("X-Content-Type-Options")) { ctx.Response.Headers.Add("X-Content-Type-Options", "nosniff"); } if (!ctx.Response.Headers.ContainsKey("Referrer-Policy")) { ctx.Response.Headers.Add("Referrer-Policy", "no-referrer-when-downgrade"); } return(Task.CompletedTask); }); return(next()); }); if (HostingEnvironment.IsDevelopment() && !ServiceFabricHelpers.RunningInServiceFabric()) { // In local dev with the `ng serve` scenario, just redirect /_/api to /api app.UseRewriter(new RewriteOptions().AddRewrite("^_/(.*)", "$1", true)); } app.MapWhen(ctx => ctx.Request.Path.StartsWithSegments("/api"), ConfigureApi); if (ServiceFabricHelpers.RunningInServiceFabric()) { app.MapWhen( ctx => ctx.Request.Path.StartsWithSegments("/_/api") && IsGet(ctx), ConfigureCookieAuthedApi); } app.UseRewriter(new RewriteOptions().AddRedirect("^swagger(/ui)?/?$", "/swagger/ui/index.html")); app.UseStatusCodePagesWithReExecute("/Error", "?code={0}"); app.UseCookiePolicy(); app.UseStaticFiles(); app.UseAuthentication(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(e => { e.MapRazorPages(); e.MapControllers(); } ); app.MapWhen(IsGet, AngularIndexHtmlRedirect); }
public override void ConfigureServices(IServiceCollection services) { if (HostingEnvironment.IsDevelopment()) { services.AddDataProtection() .SetDefaultKeyLifetime(LoginCookieLifetime * 2); } else { IConfigurationSection dpConfig = Configuration.GetSection("DataProtection"); string vaultUri = Configuration["KeyVaultUri"]; string keyVaultKeyIdentifierName = dpConfig["KeyIdentifier"]; var provider = new AzureServiceTokenProvider(); var kvClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(provider.KeyVaultTokenCallback)); KeyBundle key = kvClient.GetKeyAsync(vaultUri, keyVaultKeyIdentifierName).GetAwaiter().GetResult(); services.AddDataProtection() .PersistKeysToAzureBlobStorage(new Uri(dpConfig["KeyFileUri"])) .ProtectKeysWithAzureKeyVault(kvClient, key.KeyIdentifier.ToString()) .SetDefaultKeyLifetime(LoginCookieLifetime * 2) .SetApplicationName(typeof(Startup).FullName); } ConfigureApiServices(services); services.Configure <CookiePolicyOptions>( options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.Lax; options.HttpOnly = Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy.Always; if (HostingEnvironment.IsDevelopment()) { options.Secure = CookieSecurePolicy.SameAsRequest; } else { options.Secure = CookieSecurePolicy.Always; } }); services.AddBuildAssetRegistry( options => { options.UseSqlServer(Configuration.GetSection("BuildAssetRegistry")["ConnectionString"]); }); services.AddRazorPages(options => { options.Conventions.AuthorizeFolder("/", MsftAuthorizationPolicyName); options.Conventions.AllowAnonymousToPage("/Index"); options.Conventions.AllowAnonymousToPage("/Error"); options.Conventions.AllowAnonymousToPage("/SwaggerUi"); }) .SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddFluentValidation(options => options.RegisterValidatorsFromAssemblyContaining <Startup>()) .AddGitHubWebHooks() .AddApiPagination() .AddCookieTempDataProvider( options => { // Cookie Policy will not send this cookie unless we mark it as Essential // The application will not function without this cookie. options.Cookie.IsEssential = true; }); services.AddControllers() .AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); options.SerializerSettings.Converters.Add(new StringEnumConverter { NamingStrategy = new CamelCaseNamingStrategy() }); options.SerializerSettings.Converters.Add( new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-ddTHH:mm:ssZ", DateTimeStyles = DateTimeStyles.AdjustToUniversal }); }); services.AddSingleton(Configuration); ConfigureAuthServices(services); services.AddSingleton <BackgroundQueue>(); services.AddSingleton <IBackgroundQueue>(provider => provider.GetRequiredService <BackgroundQueue>()); services.AddSingleton <IHostedService>(provider => provider.GetRequiredService <BackgroundQueue>()); services.AddServiceFabricService <IDependencyUpdater>("fabric:/MaestroApplication/DependencyUpdater"); services.AddGitHubTokenProvider(); services.Configure <GitHubClientOptions>(o => { o.ProductHeader = new Octokit.ProductHeaderValue("Maestro", Assembly.GetEntryAssembly() .GetCustomAttribute <AssemblyInformationalVersionAttribute>() ?.InformationalVersion); }); services.Configure <GitHubTokenProviderOptions>( (options, provider) => { IConfigurationSection section = Configuration.GetSection("GitHub"); section.Bind(options); }); services.AddAzureDevOpsTokenProvider(); services.Configure <AzureDevOpsTokenProviderOptions>( (options, provider) => { var config = provider.GetRequiredService <IConfiguration>(); var tokenMap = config.GetSection("AzureDevOps:Tokens").GetChildren(); foreach (IConfigurationSection token in tokenMap) { options.Tokens.Add(token.GetValue <string>("Account"), token.GetValue <string>("Token")); } }); services.AddKustoClientProvider( options => { IConfigurationSection section = Configuration.GetSection("Kusto"); section.Bind(options); }); // We do not use AddMemoryCache here. We use our own cache because we wish to // use a sized cache and some components, such as EFCore, do not implement their caching // in such a way that will work with sizing. services.AddSingleton <DarcRemoteMemoryCache>(); services.AddScoped <IRemoteFactory, DarcRemoteFactory>(); services.AddSingleton(typeof(IActorProxyFactory <>), typeof(ActorProxyFactory <>)); services.EnableLazy(); services.AddMergePolicies(); services.Configure <SwaggerOptions>(options => { options.SerializeAsV2 = false; options.RouteTemplate = "api/{documentName}/swagger.json"; options.PreSerializeFilters.Add( (doc, req) => { bool http = HostingEnvironment.IsDevelopment() && !ServiceFabricHelpers.RunningInServiceFabric(); doc.Servers = new List <OpenApiServer> { new OpenApiServer { Url = $"{(http ? "http" : "https")}://{req.Host.Value}/", }, }; req.HttpContext.Response.Headers["Access-Control-Allow-Origin"] = "*"; }); }); services.AddSingleton <ISystemClock, SystemClock>(); }
public MouseTestActorService(StatefulServiceContext context) : base(context) { WinApi.TimeBeginPeriod(1); //improve sleep precision for polling type transports float timeoutDebugMultiplier = 1; var builder = new ContainerBuilder(); var esLogsConfig = new FabricConfigProvider <ElasticSearchOutputConfig>("ElasticSearchLogs").Config; var esMetricsConfig = new FabricConfigProvider <ElasticSearchOutputConfig>("ElasticSearchMetrics").Config; var logger = new LoggerConfiguration() .ConfigureMOUSETypesDestructure() .MinimumLevel.Error() .Enrich.With(new AzureServiceFabricSerilogEnricher(context)) .Enrich.With <ExceptionEnricher>() .Enrich.With <ActivityIdSerilogEnricher>() .WriteTo.Elasticsearch( new ElasticsearchSinkOptions(new Uri(esLogsConfig.ElasticSearchUri)) { IndexFormat = $"{esLogsConfig.ElasticSearchIndexName}-{{0:yyyy.MM.dd}}" }) .CreateLogger(); Log.Logger = logger; builder.RegisterInstance(logger).As <ILogger>(); builder.RegisterType <SerilogCoreEvents>().As <ICoreEvents>(); builder.RegisterType <SerilogActorCoreEvents>().As <IActorCoreEvents>(); builder.RegisterType <SerilogLidgrenEvents>().As <ILidgrenEvents>(); Metric.Config.WithAllCounters(); _metricsSubscription = new TelemetryPipe() .CollectMetricsNet(5, ServiceFabricHelpers.GetEnvironmentProperties(context), true) .SendToElasticSearch(esMetricsConfig) .Start(); builder.Register(c => new ProtobufMessageSerializer(typeof(Message).Assembly, typeof(TestStateless).Assembly)).As <IMessageSerializer>(); var roomActorsEndpoint = FabricRuntime.GetActivationContext().GetEndpoint("TestActors"); var nodeIP = Dns.GetHostAddresses(FabricRuntime.GetNodeContext().IPAddressOrFQDN).First(x => x.AddressFamily == AddressFamily.InterNetwork); var roomActorsNetConfig = new NetPeerConfiguration("TestActors") { LocalAddress = nodeIP, MaximumConnections = 10000, AcceptIncomingConnections = true, Port = roomActorsEndpoint.Port, ConnectionTimeout = 10 * timeoutDebugMultiplier }; builder.RegisterType <WcfBufferPool>().As <IBufferPool>(); builder.Register(c => new NetNodeConfig() { SendTimeoutSec = (int)(10.0 * timeoutDebugMultiplier), ConnectTimeoutSec = (int)(10 * timeoutDebugMultiplier) }).As <INetNodeConfig>(); builder.Register(c => new TestActor(StateManager)).As <ITestActor>(); builder.Register(c => new ServiceFabricActorSystemNetNode <ITestActor>("TestActors", Context.ServiceName, new LidgrenNetProvider(roomActorsNetConfig, c.Resolve <ILidgrenEvents>()), c.Resolve <IActorCoreEvents>(), c.Resolve <ICoreEvents>(), c.Resolve <IMessageSerializer>(), c.Resolve <INetNodeConfig>(), c.Resolve <IBufferPool>(), actorFactory: c.Resolve <Func <ITestActor> >())) .As <INetNode>() .SingleInstance(); var container = builder.Build(); _netNodes = container.Resolve <IEnumerable <INetNode> >(); }
async protected override Task RunAsync(CancellationToken cancellationToken) { var esLogsConfig = new FabricConfigProvider <ElasticSearchOutputConfig>("ElasticSearchLogs").Config; var esMetricsConfig = new FabricConfigProvider <ElasticSearchOutputConfig>("ElasticSearchMetrics").Config; var logger = new LoggerConfiguration() .ConfigureMOUSETypesDestructure() .MinimumLevel.Warning() .Enrich.With(new AzureServiceFabricSerilogEnricher(Context)) .Enrich.With <ExceptionEnricher>() .WriteTo.Elasticsearch( new ElasticsearchSinkOptions(new Uri(esLogsConfig.ElasticSearchUri)) { IndexFormat = $"{esLogsConfig.ElasticSearchIndexName}-{{0:yyyy.MM.dd}}" }) .CreateLogger(); Log.Logger = logger; Metric.Config.WithAllCounters(); //Metric.PerformanceCounter("Actor calls waiting for actor lock", "Service Fabric Actor", "# of actor calls waiting for actor lock", "*", Unit.Items); //Metric.PerformanceCounter("Actor outstanding requests", "Service Fabric Actor", "# of outstanding requests", "*", Unit.Items); //Metric.PerformanceCounter("Actor Average milliseconds actor lock held", "Service Fabric Actor", "Average milliseconds actor lock held", "*", Unit.Custom("ms")); //Metric.PerformanceCounter("Actor Average milliseconds for request deserialization", "Service Fabric Actor", "Average milliseconds for request deserialization", "*", Unit.Custom("ms")); //Metric.PerformanceCounter("Actor Average milliseconds for response serialization", "Service Fabric Actor", "Average milliseconds for response serialization", "*", Unit.Custom("ms")); //Metric.PerformanceCounter("Actor Average milliseconds per load state operation", "Service Fabric Actor", "Average milliseconds per load state operation", "*", Unit.Custom("ms")); //Metric.PerformanceCounter("Actor Average milliseconds per lock wait", "Service Fabric Actor", "Average milliseconds per lock wait", "*", Unit.Custom("ms")); //Metric.PerformanceCounter("Actor Average milliseconds per request", "Service Fabric Actor", "Average milliseconds per request", "*", Unit.Custom("ms")); //Metric.PerformanceCounter("Actor Average milliseconds per save state operation", "Service Fabric Actor", "Average milliseconds per save state operation", "*", Unit.Custom("ms")); //Metric.PerformanceCounter("Actor Average OnActivateAsync milliseconds", "Service Fabric Actor", "Average OnActivateAsync milliseconds", "*", Unit.Custom("ms")); //Metric.PerformanceCounter("Actor Method Average milliseconds per invocation", "Service Fabric Actor Method", "Average milliseconds per invocation", "*", Unit.Custom("ms")); //Metric.PerformanceCounter("Actor Method Exceptions thrown/Sec", "Service Fabric Actor Method", "Exceptions thrown/Sec", "*", Unit.Custom("rate/sec")); //Metric.PerformanceCounter("Actor Method Invocations/Sec", "Service Fabric Actor Method", "Invocations/Sec", "*", Unit.Custom("rate/sec")); var metricsSubscription = new TelemetryPipe() .CollectMetricsNet(5, ServiceFabricHelpers.GetEnvironmentProperties(Context), true) .SendToElasticSearch(esMetricsConfig) .Start(); var logsSubscription = new TelemetryPipe() .CollectEventSourceEvents(new[] { //new ETWProvider("Microsoft-ServiceFabric-Services"), //new ETWProvider("Microsoft-ServiceFabric-Actors"), new ETWProvider("SFActorsPerfTest-SFTestActor") }, ServiceFabricHelpers.GetEnvironmentProperties(Context)) .SendToElasticSearch(esLogsConfig) .Start(); using (logsSubscription) using (metricsSubscription) { await base.RunAsync(cancellationToken); await Task.Delay(Timeout.Infinite, cancellationToken); } }