Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

Commit

Permalink
Add build hook for closed-source assemblies (#763)
Browse files Browse the repository at this point in the history
Activate assembly modules and add more base configuration types to DI
Consider 4XX as successfully for telemetry purposes
Add KnownOperation for the V3 search endpoint
Progress on NuGet/Engineering#3020
  • Loading branch information
joelverhagen committed Apr 9, 2020
1 parent 4ce169a commit fa05c3f
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 38 deletions.
1 change: 1 addition & 0 deletions sign.thirdparty.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<ThirdPartyBinaries Include="AnglicanGeek.MarkdownMailer.dll" />
<ThirdPartyBinaries Include="Autofac.dll" />
<ThirdPartyBinaries Include="Autofac.Extensions.DependencyInjection.dll" />
<ThirdPartyBinaries Include="Autofac.Integration.WebApi.dll" />
<ThirdPartyBinaries Include="Dapper.StrongName.dll" />
<ThirdPartyBinaries Include="dotNetRDF.dll" />
<ThirdPartyBinaries Include="Elmah.dll" />
Expand Down
4 changes: 2 additions & 2 deletions src/Catalog/NuGet.Services.Metadata.Catalog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
<Version>4.4.5-dev-3612899</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Sql">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="NuGet.StrongName.json-ld.net">
<Version>1.0.6</Version>
Expand All @@ -309,7 +309,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NuGet.Services.Logging">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="WindowsAzure.Storage">
<Version>9.3.3</Version>
Expand Down
8 changes: 4 additions & 4 deletions src/Ng/Ng.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,16 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NuGet.Services.Configuration">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Logging">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Sql">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Storage">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="Serilog.Sinks.File">
<Version>4.0.0</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NuGet.Services.Storage">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
33 changes: 31 additions & 2 deletions src/NuGet.Services.SearchService/App_Start/WebApiConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -142,6 +143,8 @@ private static AutofacWebApiDependencyResolver GetDependencyResolver(HttpConfigu

var services = new ServiceCollection();
services.AddSingleton(configuration.SecretReaderFactory);
services.AddSingleton(applicationInsightsConfiguration.TelemetryConfiguration);
services.AddSingleton<IConfiguration>(configuration.Root);
services.Add(ServiceDescriptor.Scoped(typeof(IOptionsSnapshot<>), typeof(NonCachingOptionsSnapshot<>)));
services.Configure<AzureSearchConfiguration>(configuration.Root.GetSection(ConfigurationSectionName));
services.Configure<SearchServiceConfiguration>(configuration.Root.GetSection(ConfigurationSectionName));
Expand All @@ -150,6 +153,7 @@ private static AutofacWebApiDependencyResolver GetDependencyResolver(HttpConfigu
services.AddTransient<ITelemetryClient, TelemetryClientWrapper>();

var builder = new ContainerBuilder();
builder.RegisterAssemblyModules(typeof(WebApiConfig).Assembly);
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterWebApiFilterProvider(config);
builder.RegisterWebApiModelBinderProvider();
Expand All @@ -174,10 +178,30 @@ private static ApplicationInsightsConfiguration InitializeApplicationInsights(Re
var heartbeatIntervalSeconds = configuration.Root.GetValue("ApplicationInsights_HeartbeatIntervalSeconds", 60);

var applicationInsightsConfiguration = ApplicationInsights.Initialize(
instrumentationKey,
TimeSpan.FromSeconds(heartbeatIntervalSeconds));
instrumentationKey,
TimeSpan.FromSeconds(heartbeatIntervalSeconds));

applicationInsightsConfiguration.TelemetryConfiguration.TelemetryInitializers.Add(new AzureWebAppTelemetryInitializer());
applicationInsightsConfiguration.TelemetryConfiguration.TelemetryInitializers.Add(new KnownOperationNameEnricher(new[]
{
GetOperationName<SearchController>(HttpMethod.Get, nameof(SearchController.AutocompleteAsync)),
GetOperationName<SearchController>(HttpMethod.Get, nameof(SearchController.IndexAsync)),
GetOperationName<SearchController>(HttpMethod.Get, nameof(SearchController.GetStatusAsync)),
GetOperationName<SearchController>(HttpMethod.Get, nameof(SearchController.V2SearchAsync)),
GetOperationName<SearchController>(HttpMethod.Get, nameof(SearchController.V3SearchAsync)),
}));

applicationInsightsConfiguration.TelemetryConfiguration.TelemetryProcessorChainBuilder.Use(next =>
{
var processor = new RequestTelemetryProcessor(next);

processor.SuccessfulResponseCodes.Add(400);
processor.SuccessfulResponseCodes.Add(403);
processor.SuccessfulResponseCodes.Add(404);
processor.SuccessfulResponseCodes.Add(405);

return processor;
});

RegisterApplicationInsightsTelemetryModules(applicationInsightsConfiguration.TelemetryConfiguration);

Expand Down Expand Up @@ -318,6 +342,11 @@ private static string GetControllerName<T>() where T : ApiController
throw new ArgumentException($"The controller type name must end with '{ControllerSuffix}'.");
}

private static string GetOperationName<T>(HttpMethod verb, string actionName) where T : ApiController
{
return $"{verb} {GetControllerName<T>()}/{actionName}";
}

private class RefreshableConfiguration
{
public IRefreshableSecretReaderFactory SecretReaderFactory { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="..\..\sign.thirdparty.props" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -114,31 +115,8 @@
<SignType Condition="'$(SignType)' == ''">none</SignType>
</PropertyGroup>
<Import Project="$(SignPath)\sign.targets" Condition="Exists('$(SignPath)\sign.targets')" />
<ItemGroup>
<ThirdPartyBinaries Include="AnglicanGeek.MarkdownMailer.dll" Visible="false" />
<ThirdPartyBinaries Include="Autofac.dll" Visible="false" />
<ThirdPartyBinaries Include="Autofac.Extensions.DependencyInjection.dll" Visible="false" />
<ThirdPartyBinaries Include="Autofac.Integration.WebApi.dll" Visible="false" />
<ThirdPartyBinaries Include="Dapper.StrongName.dll" Visible="false" />
<ThirdPartyBinaries Include="dotNetRDF.dll" Visible="false" />
<ThirdPartyBinaries Include="Elmah.dll" Visible="false" />
<ThirdPartyBinaries Include="HtmlAgilityPack.dll" Visible="false" />
<ThirdPartyBinaries Include="ICSharpCode.SharpZipLib.dll" Visible="false" />
<ThirdPartyBinaries Include="json-ld.net.StrongName.dll" Visible="false" />
<ThirdPartyBinaries Include="Markdig.dll" Visible="false" />
<ThirdPartyBinaries Include="MarkdownSharp.dll" Visible="false" />
<ThirdPartyBinaries Include="Newtonsoft.Json.dll" Visible="false" />
<ThirdPartyBinaries Include="Serilog.dll" Visible="false" />
<ThirdPartyBinaries Include="Serilog.Enrichers.Environment.dll" Visible="false" />
<ThirdPartyBinaries Include="Serilog.Enrichers.Process.dll" Visible="false" />
<ThirdPartyBinaries Include="Serilog.Extensions.Logging.dll" Visible="false" />
<ThirdPartyBinaries Include="Serilog.Sinks.ApplicationInsights.dll" Visible="false" />
<ThirdPartyBinaries Include="Serilog.Sinks.Console.dll" Visible="false" />
<ThirdPartyBinaries Include="Serilog.Sinks.File.dll" Visible="false" />
<ThirdPartyBinaries Include="SerilogTraceListener.dll" Visible="false" />
<ThirdPartyBinaries Include="VDS.Common.dll" Visible="false" />
</ItemGroup>
<Import Project="$(SignPath)\sign.microbuild.targets" Condition="Exists('$(SignPath)\sign.microbuild.targets')" />
<Import Project="$(NuGetBuildExtensions)" Condition="'$(NuGetBuildExtensions)' != '' And Exists('$(NuGetBuildExtensions)')" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<ProjectExtensions>
Expand Down
6 changes: 5 additions & 1 deletion src/NuGet.Services.SearchService/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.webServer>
<modules>
<modules runAllManagedModulesForAllRequests="true">
<add name="TelemetryCorrelationHttpModule" type="Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation" preCondition="integratedMode,managedHandler"/>
<add name="ApplicationInsightsHttpModule" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler"/>
</modules>
Expand All @@ -23,6 +23,10 @@
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MessagePack" publicKeyToken="B4A0369545F0A1BE" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-9.3.2.0" newVersion="9.3.2.0"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/CatalogTests/CatalogTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
<Version>4.10.1</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Logging">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="xunit">
<Version>2.4.1</Version>
Expand Down
4 changes: 2 additions & 2 deletions tests/NgTests/NgTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@
<Version>4.10.1</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Configuration">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Logging">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="xunit">
<Version>2.4.1</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<Version>2.2.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Configuration">
<Version>2.74.0</Version>
<Version>2.75.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Versioning">
<Version>5.0.0-preview1.5707</Version>
Expand Down

0 comments on commit fa05c3f

Please sign in to comment.