Skip to content

Commit b437942

Browse files
committed
Configure Launch profiles to be able to log to Seq or Aspire Dashboard + docker composite for needed services
1 parent 9ba23aa commit b437942

File tree

4 files changed

+51
-35
lines changed

4 files changed

+51
-35
lines changed

src/CourseLibrary/CourseLibrary.API/CourseLibrary.API.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
1111
<PackageReference Include="Bogus" Version="35.6.1" />
1212
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
13-
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.10.0" /><!--Demo purpose-->
1413
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.10.0" />
1514
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.10.0" />
1615
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.10.1" />
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
services:
2+
seq:
3+
image: datalust/seq:latest
4+
ports:
5+
- "5341:80"
6+
volumes:
7+
- C:\Temp\seq-data:/data
8+
environment:
9+
ACCEPT_EULA: Y
10+
restart: unless-stopped
11+
aspire:
12+
image: mcr.microsoft.com/dotnet/aspire-dashboard:latest
13+
ports:
14+
- "18888:18888"
15+
- "4317:18889"

src/CourseLibrary/CourseLibrary.API/IoC/StartupHelperExtensions.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,7 @@ public static WebApplicationBuilder ConfigureOpenTelemetry(this WebApplicationBu
6969
options.IncludeFormattedMessage = true;
7070
options.IncludeScopes = true;
7171
options.ParseStateValues = true;
72-
//options.AddConsoleExporter(); // Demo purposes
73-
options.AddOtlpExporter(x =>
74-
{
75-
x.Endpoint = new Uri("http://localhost:5341/ingest/otlp/v1/logs"); // seq endpoint
76-
x.Protocol = OtlpExportProtocol.HttpProtobuf;
77-
});
72+
options.AddOtlpExporter();
7873
});
7974

8075
builder.Services.AddOpenTelemetry()
@@ -88,21 +83,14 @@ public static WebApplicationBuilder ConfigureOpenTelemetry(this WebApplicationBu
8883
metrics.AddMeter(DiagnosticsConfig.Meter.Name);
8984

9085
metrics.AddOtlpExporter();
91-
//metrics.AddConsoleExporter(); // Demo purposes
9286
})
9387
.WithTracing(tracing =>
9488
{
95-
tracing.
96-
AddAspNetCoreInstrumentation()
89+
tracing
90+
.AddAspNetCoreInstrumentation()
9791
.AddHttpClientInstrumentation();
9892

99-
tracing.AddOtlpExporter(); // todo to be configured
100-
//tracing.AddOtlpExporter(x =>
101-
//{
102-
// x.Endpoint = new Uri("http://localhost:5341/ingest/otlp/v1/traces"); // seq endpoint
103-
// x.Protocol = OtlpExportProtocol.HttpProtobuf;
104-
//});
105-
//tracing.AddConsoleExporter(); // Demo purposes
93+
tracing.AddOtlpExporter();
10694
});
10795

10896
return builder;
Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1-
{
2-
"$schema": "https://json.schemastore.org/launchsettings.json",
3-
"iisSettings": {
4-
"windowsAuthentication": false,
5-
"anonymousAuthentication": true,
6-
"iisExpress": {
7-
"applicationUrl": "http://localhost:6168",
8-
"sslPort": 44338
9-
}
10-
},
1+
{
112
"profiles": {
123
"http": {
134
"commandName": "Project",
14-
"dotnetRunMessages": true,
155
"launchBrowser": true,
166
"launchUrl": "swagger",
17-
"applicationUrl": "http://localhost:5012",
187
"environmentVariables": {
198
"ASPNETCORE_ENVIRONMENT": "Development"
20-
}
9+
},
10+
"dotnetRunMessages": true,
11+
"applicationUrl": "http://localhost:5012"
2112
},
22-
"https": {
13+
"https-seq": {
2314
"commandName": "Project",
15+
"launchBrowser": true,
16+
"launchUrl": "swagger",
17+
"environmentVariables": {
18+
"ASPNETCORE_ENVIRONMENT": "Development",
19+
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:5341/ingest/otlp/v1/logs",
20+
"OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf"
21+
},
2422
"dotnetRunMessages": true,
23+
"applicationUrl": "https://localhost:7022;http://localhost:5012"
24+
},
25+
"https-aspire": {
26+
"commandName": "Project",
2527
"launchBrowser": true,
2628
"launchUrl": "swagger",
27-
"applicationUrl": "https://localhost:7022;http://localhost:5012",
2829
"environmentVariables": {
29-
"ASPNETCORE_ENVIRONMENT": "Development"
30-
}
30+
"ASPNETCORE_ENVIRONMENT": "Development",
31+
"OTEL_EXPORTER_OTLP_ENDPOINT": "http://localhost:4317",
32+
"OTEL_EXPORTER_OTLP_PROTOCOL": "grpc"
33+
},
34+
"dotnetRunMessages": true,
35+
"applicationUrl": "https://localhost:7024;http://localhost:5014"
3136
},
3237
"IIS Express": {
3338
"commandName": "IISExpress",
@@ -37,5 +42,14 @@
3742
"ASPNETCORE_ENVIRONMENT": "Development"
3843
}
3944
}
45+
},
46+
"$schema": "https://json.schemastore.org/launchsettings.json",
47+
"iisSettings": {
48+
"windowsAuthentication": false,
49+
"anonymousAuthentication": true,
50+
"iisExpress": {
51+
"applicationUrl": "http://localhost:6168",
52+
"sslPort": 44338
53+
}
4054
}
41-
}
55+
}

0 commit comments

Comments
 (0)