Skip to content

Commit

Permalink
CI no appsights
Browse files Browse the repository at this point in the history
  • Loading branch information
chullybun committed Oct 26, 2023
1 parent 8c8dd00 commit 9f45ef7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ jobs:
- name: Set environment variables
run: |
echo "DO_NOT_USE_APPINSIGHTS=true" >> $GITHUB_ENV
echo "My_Hr_ConnectionStrings__Database=Data Source=localhost,1433;Initial Catalog=My.Hr;User id=sa;Password=sAPWD23.^0;TrustServerCertificate=true" >> $GITHUB_ENV
echo "MyEf_Hr_ConnectionStrings__Database=Data Source=localhost,1433;Initial Catalog=MyEf.Hr;User id=sa;Password=sAPWD23.^0;TrustServerCertificate=true" >> $GITHUB_ENV
Expand Down
11 changes: 7 additions & 4 deletions samples/MyEf.Hr/MyEf.Hr.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ public void ConfigureServices(IServiceCollection services)
services.AddHttpClient();

// Add Azure monitor open telemetry.
services.AddOpenTelemetry().UseAzureMonitor();
services.Configure<AspNetCoreInstrumentationOptions>(options => options.RecordException = true);
services.Configure<EntityFrameworkInstrumentationOptions>(options => options.SetDbStatementForText = true);
services.ConfigureOpenTelemetryTracerProvider((sp, builder) => builder.AddSource("CoreEx.*", "MyEf.Hr.*", "Microsoft.EntityFrameworkCore.*", "EntityFrameworkCore.*"));
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DO_NOT_USE_APPINSIGHTS")))
{
services.AddOpenTelemetry().UseAzureMonitor();
services.Configure<AspNetCoreInstrumentationOptions>(options => options.RecordException = true);
services.Configure<EntityFrameworkInstrumentationOptions>(options => options.SetDbStatementForText = true);
services.ConfigureOpenTelemetryTracerProvider((sp, builder) => builder.AddSource("CoreEx.*", "MyEf.Hr.*", "Microsoft.EntityFrameworkCore.*", "EntityFrameworkCore.*"));
}

// Add Swagger services.
services.AddSwaggerGen(options =>
Expand Down

0 comments on commit 9f45ef7

Please sign in to comment.