OpenTelemetry: context propagation and semconv update (#262)
This commit is contained in:
parent
f2fd2046f3
commit
d6cc65aced
3 changed files with 398 additions and 89 deletions
|
|
@ -12,4 +12,11 @@
|
|||
<ProjectReference Include="..\..\src\ModelContextProtocol.AspNetCore\ModelContextProtocol.AspNetCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,23 @@
|
|||
using TestServerWithHosting.Tools;
|
||||
using OpenTelemetry.Metrics;
|
||||
using OpenTelemetry.Trace;
|
||||
using OpenTelemetry;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddMcpServer()
|
||||
.WithTools<EchoTool>()
|
||||
.WithTools<SampleLlmTool>();
|
||||
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.WithTracing(b => b.AddSource("*")
|
||||
.AddAspNetCoreInstrumentation()
|
||||
.AddHttpClientInstrumentation())
|
||||
.WithMetrics(b => b.AddMeter("*")
|
||||
.AddAspNetCoreInstrumentation()
|
||||
.AddHttpClientInstrumentation())
|
||||
.WithLogging()
|
||||
.UseOtlpExporter();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapMcp();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://localhost:3001",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"OTEL_SERVICE_NAME": "sse-server",
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
|
|
@ -14,7 +15,8 @@
|
|||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "https://localhost:7133;http://localhost:3001",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"OTEL_SERVICE_NAME": "sse-server",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue