Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AddSkyApm override Method ,support configuration from caller #593

Merged
merged 1 commit into from
May 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 IServiceCollection AddSkyAPM(this IServiceCollection services,
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
Loading