Skip to content

Commit

Permalink
try support AddSkyApm Extend Method ,support Configuration from Caller
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsonye committed Apr 30, 2024
1 parent fda9b9a commit ac3d6f6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/SkyApm.Agent.Hosting/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public static class ServiceCollectionExtensions
public static IServiceCollection AddSkyAPM(this IServiceCollection services,
Action<SkyApmExtensions> extensionsSetup = null)
{
#region can be optimized

string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
if (environment == null || environment.Length < 1)
{
Expand All @@ -60,6 +58,16 @@ public static class ServiceCollectionExtensions
configurationBuilder.AddJsonFile("skyapm.json", true);
configurationBuilder.AddJsonFile("skyapm." + environment + ".json", true);
IConfiguration configuration = configurationBuilder.Build();

services.AddSkyAPM(configuration,extensionsSetup);
return services;
}

public static IServiceCollection AddSkyAPM(this IServiceCollection services, IConfiguration configuration,
Action<SkyApmExtensions> extensionsSetup = null)
{
#region can be optimized

string enable = configuration?.GetSection("SkyWalking:Enable").Value;
if (enable != null && "false".Equals(enable.ToLower()))
{
Expand Down

0 comments on commit ac3d6f6

Please sign in to comment.