-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverting "unused" wrapper that was deleted. Apparently it's not as "…
…unused" as it seems...
- Loading branch information
1 parent
2c284fb
commit 0aba4d7
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...lic/Agent/Extensions/Providers/Wrapper/AspNetCore6Plus/BuildCommonServicesWrapper6Plus.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2020 New Relic, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Linq; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using NewRelic.Agent.Api; | ||
using NewRelic.Agent.Extensions.Providers.Wrapper; | ||
|
||
namespace NewRelic.Providers.Wrapper.AspNetCore6Plus | ||
{ | ||
public class BuildCommonServicesWrapper6Plus : IWrapper | ||
{ | ||
public bool IsTransactionRequired => false; | ||
|
||
public CanWrapResponse CanWrap(InstrumentedMethodInfo methodInfo) | ||
{ | ||
return new CanWrapResponse(nameof(BuildCommonServicesWrapper6Plus).Equals(methodInfo.RequestedWrapperName)); | ||
} | ||
|
||
public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall instrumentedMethodCall, IAgent agent, ITransaction transaction) | ||
{ | ||
//Do nothing at start of method | ||
|
||
return Delegates.GetDelegateFor<IServiceCollection>(onSuccess: HandleSuccess); | ||
|
||
void HandleSuccess(IServiceCollection services) | ||
{ | ||
//Forced evaluation is important. Do not remove ToList() | ||
var startupFilters = services.Where(serviceDescriptor => serviceDescriptor.ServiceType == typeof(IStartupFilter)).ToList(); | ||
|
||
services.AddTransient<IStartupFilter>(provider => new AddNewRelicStartupFilter(agent)); | ||
|
||
foreach (var filter in startupFilters) | ||
{ | ||
services.Remove(filter); // Remove from early in pipeline | ||
services.Add(filter); // Add to end after our AddNewRelicStartupFilter | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters