Skip to content

Commit

Permalink
chore: use appinsights pkg for isolated az func (#442)
Browse files Browse the repository at this point in the history
* chore: use preview appinsights pkg for isolated az func

* pr-fix: update w/ trace logging for docker tests

* pr-tmp: try to see if the package addition is the cause

* pr-fix: solely rely on worker pkg

* pr-fix: solely rely on worker pkg

* pr-fix: solely rely on worker pkg

* pr-fix: solely rely on worker pkg

* pr-fix: update with env var

* pr-fix: update with env var

* pr-fix: update with env var

* pr-fix: remove app insights from az func regisration

* pr-fix: remove app insights from az func regisration

* pr-fix: realistic package deps

* pr-fix: use new app insights env var

* pr-fix: update arcus observability

* pr-fix: simplify dependencies

* pr-fix: complete upgrade arcus observability

* pr-fix: dockerfile setup

* pr-fix: move preview package back to arcus

* pr-fix: remaining package conflicts

* pr-fix: revert to original arcus observability dependency

* pr-revert: unnecessary changes

* Update Arcus.WebApi.Logging.AzureFunctions.csproj

* pr-up: newest preview package workings

* Update Arcus.WebApi.Logging.AzureFunctions.csproj

* pr-fix: update dockerfile w/ new 7 .net sdk

* Update Arcus.WebApi.Logging.AzureFunctions.csproj

* pr-fix: force add nuget package diagnostic source

* pr-fix: conditional isolated

* pr-fix: update webjobs package

* Update Dockerfile

* Update Dockerfile

* Update Arcus.WebApi.Tests.Runtimes.AzureFunction.csproj

* Update run-docker-integration-tests.yml

* Update IServiceCollectionExtensions.cs

* Update IServiceCollectionExtensions.cs

* Update Arcus.WebApi.Tests.Integration.csproj

* Update Dockerfile

* Update Dockerfile

* Update Arcus.WebApi.Logging.AzureFunctions.csproj

* pr-fix: correct missing package after merge w/ 'main'

* pr-fix: revert az func isolated Dockerfile

* pr-fix: revert az func in-process Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update Arcus.WebApi.Logging.AzureFunctions.csproj

* Update Arcus.WebApi.Logging.AzureFunctions.csproj
  • Loading branch information
stijnmoreels authored Feb 29, 2024
1 parent 63dd672 commit 6cba745
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 30 deletions.
4 changes: 3 additions & 1 deletion build/templates/run-docker-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ steps:
parameters:
dockerProjectName: '$(Project).Tests.Runtimes.AzureFunction.Isolated'
port: '$(Arcus.AzureFunctions.Isolated.HttpPort)'
envVars: |
APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=$(Arcus.ApplicationInsights.InstrumentationKey)
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
Expand All @@ -36,4 +38,4 @@ steps:
docker logs $(Project).Tests.Runtimes.AzureFunction.Isolated
failOnStderr: true
displayName: Show $(Project).Tests.Runtimes.AzureFunction.Isolated logs
condition: always()
condition: always()
4 changes: 3 additions & 1 deletion build/templates/start-docker-project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
parameters:
dockerProjectName: ''
port: ''
envVars: {}

steps:
- bash: |
Expand Down Expand Up @@ -28,4 +29,5 @@ steps:
command: 'Run an image'
imageName: '${{ parameters.dockerProjectName }}:$(Build.BuildId)'
containerName: '${{ parameters.dockerProjectName }}'
ports: '${{ parameters.port }}:80'
ports: '${{ parameters.port }}:80'
envVars: ${{ parameters.envVars }}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
<ItemGroup>
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[3.0.0,4.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.AzureFunctions" Version="[3.0.0,4.0.0)" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Core" Version="1.6.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.33" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.35" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Net;
using Arcus.Observability.Correlation;
using Arcus.Observability.Telemetry.Core;
using Arcus.WebApi.Logging;
using Arcus.WebApi.Logging.AzureFunctions;
using Arcus.WebApi.Logging.AzureFunctions.Correlation;
using Arcus.WebApi.Logging.Core.Correlation;
using GuardNet;
using Microsoft.ApplicationInsights;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -64,11 +60,8 @@ public static IFunctionsWorkerApplicationBuilder UseHttpCorrelation(
{
Guard.NotNull(builder, nameof(builder), "Requires a function worker builder instance to add the HTTP correlation middleware");

builder.Services.AddLogging(logging =>
{
logging.AddApplicationInsightsWebJobs()
.RemoveMicrosoftApplicationInsightsLoggerProvider();
});
builder.Services.AddApplicationInsightsTelemetryWorkerService();
builder.Services.ConfigureFunctionsApplicationInsights();

builder.Services.AddSingleton<ICorrelationInfoAccessor<CorrelationInfo>>(provider => provider.GetRequiredService<IHttpCorrelationInfoAccessor>());
builder.Services.AddSingleton(provider => (ICorrelationInfoAccessor) provider.GetRequiredService<IHttpCorrelationInfoAccessor>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ public static IServiceCollection AddHttpCorrelation(this IFunctionsHostBuilder b
return services;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ FROM base AS final
WORKDIR /home/site/wwwroot
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<DockerFastModeProjectMountDirectory>/home/site/wwwroot</DockerFastModeProjectMountDirectory>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.33" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.13" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Arcus.WebApi.Logging.AzureFunctions\Arcus.WebApi.Logging.AzureFunctions.csproj" />
Expand All @@ -23,4 +22,4 @@
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion src/Arcus.WebApi.Tests.Runtimes.AzureFunction/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ FROM base AS final
WORKDIR /home/site/wwwroot
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
17 changes: 10 additions & 7 deletions src/Arcus.WebApi.Tests.Runtimes.AzureFunction/host.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
}
"logging": {
"logLevel": {
"default": "Trace"
},
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
}
}
}
1 change: 0 additions & 1 deletion src/Arcus.WebApi.Tests.Unit/Arcus.WebApi.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
</PackageReference>
<PackageReference Include="IdentityServer4" Version="4.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Core" Version="1.6.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Grpc" Version="1.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.1.4" />
Expand Down

0 comments on commit 6cba745

Please sign in to comment.