diff --git a/test/integrations/applications/SampleAspNetCoreApp/Startup.cs b/test/integrations/applications/SampleAspNetCoreApp/Startup.cs index 47d28a5a7..733510d64 100644 --- a/test/integrations/applications/SampleAspNetCoreApp/Startup.cs +++ b/test/integrations/applications/SampleAspNetCoreApp/Startup.cs @@ -33,9 +33,6 @@ public void ConfigureServices(IServiceCollection services) public static void ConfigureServicesExceptMvc(IServiceCollection services) { - if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SKIP_AGENT_REGISTRATION"))) - services.AddAllElasticApm(); - const string connection = @"Data Source=blogging.db"; services.AddDbContext (options => options.UseSqlite(connection)); @@ -57,12 +54,15 @@ public static void ConfigureServicesExceptMvc(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. -#if NET6_0_OR_GREATER public void Configure(IApplicationBuilder app, IWebHostEnvironment env) -#else - public void Configure(IApplicationBuilder app, IHostingEnvironment env) -#endif - => ConfigureAllExceptAgent(app); + { + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SKIP_AGENT_REGISTRATION"))) +#pragma warning disable CS0618 // Type or member is obsolete + app.UseAllElasticApm(Configuration); +#pragma warning restore CS0618 // Type or member is obsolete + + ConfigureAllExceptAgent(app); + } public static void ConfigureAllExceptAgent(IApplicationBuilder app) { diff --git a/test/integrations/applications/WebApiSample/Startup.cs b/test/integrations/applications/WebApiSample/Startup.cs index 33a1a144d..ad20626bd 100644 --- a/test/integrations/applications/WebApiSample/Startup.cs +++ b/test/integrations/applications/WebApiSample/Startup.cs @@ -2,6 +2,7 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information +using Elastic.Apm.NetCoreAll; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; @@ -17,7 +18,7 @@ public class Startup // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) => - services.AddAllElasticApm().AddMvc(); + services.AddMvc(); // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -26,7 +27,12 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) #else public void Configure(IApplicationBuilder app, IHostingEnvironment env) #endif - => ConfigureAllExceptAgent(app); + { +#pragma warning disable CS0618 // Type or member is obsolete + app.UseAllElasticApm(_configuration); +#pragma warning restore CS0618 // Type or member is obsolete + ConfigureAllExceptAgent(app); + } public static void ConfigureAllExceptAgent(IApplicationBuilder app) {