Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# appsettings files that may contain sensitive configuration
appsettings.Production.json
appsettings.*.local.json

# Mono auto generated files
mono_crash.*

Expand Down
8 changes: 4 additions & 4 deletions DotNetMcp.Tests/Server/ServerCapabilitiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public async Task DotnetServerCapabilities_Supports_Cancellation_IsTrue()
}

[Fact]
public async Task DotnetServerCapabilities_Supports_Telemetry_IsFalse()
public async Task DotnetServerCapabilities_Supports_Telemetry_IsTrue()
{
// Act
var result = await _tools.DotnetServerCapabilities();
Expand All @@ -153,8 +153,8 @@ public async Task DotnetServerCapabilities_Supports_Telemetry_IsFalse()
.GetProperty("telemetry")
.GetBoolean();

// Assert - Telemetry is a future feature, should be false initially
Assert.False(telemetry);
// Assert - Telemetry is enabled via SDK v0.6+ (request duration logging, OpenTelemetry semantic conventions)
Assert.True(telemetry);
}

[Fact]
Expand Down Expand Up @@ -231,7 +231,7 @@ public async Task DotnetServerCapabilities_JsonSchema_MatchesExpectedStructure()
Assert.True(capabilities.Supports.StructuredErrors);
Assert.True(capabilities.Supports.MachineReadable);
Assert.True(capabilities.Supports.Cancellation);
Assert.False(capabilities.Supports.Telemetry);
Assert.True(capabilities.Supports.Telemetry);
Assert.NotNull(capabilities.SdkVersions);
Assert.NotEmpty(capabilities.SdkVersions.Installed);
Assert.Equal("net10.0", capabilities.SdkVersions.Recommended);
Expand Down
4 changes: 3 additions & 1 deletion DotNetMcp/Server/ServerCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public sealed class ServerFeatureSupport
public bool Cancellation { get; init; }

/// <summary>
/// Whether the server supports telemetry reporting (future feature)
/// Whether the server supports telemetry reporting.
/// When enabled, the server emits request duration logs and follows OpenTelemetry semantic conventions (SDK v0.6+).
/// See doc/telemetry.md for configuration details.
/// </summary>
[JsonPropertyName("telemetry")]
public bool Telemetry { get; init; }
Expand Down
2 changes: 1 addition & 1 deletion DotNetMcp/Tools/Cli/DotNetCliTools.Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async partial Task<string> DotnetServerCapabilities()
StructuredErrors = true,
MachineReadable = true,
Cancellation = true,
Telemetry = false // Future feature
Telemetry = true // SDK v0.6.0-preview.1 provides request duration logging and OpenTelemetry semantic conventions
},
SdkVersions = new SdkVersionInfo
{
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ Key files to start with:
- 📖 [AI Assistant Best Practices Guide](doc/ai-assistant-guide.md) - **Workflows, prompts, integration patterns, and troubleshooting**
- 📖 [Machine-Readable JSON Contract](doc/machine-readable-contract.md) - **v1.0 stable contract for programmatic tool consumption**
- 📖 [Tool Surface Consolidation](doc/tool-surface-consolidation.md) - **Consolidated tool design and architecture**
- 📖 [Telemetry and Observability](doc/telemetry.md) - **Request duration logging, OpenTelemetry integration, and performance monitoring**
- 📖 [SDK Integration Details](doc/sdk-integration.md) - Technical architecture and SDK usage
- 📖 [Advanced Topics](doc/advanced-topics.md) - Performance, logging, and security details
- 📖 [Releasing](doc/releasing.md) - How to cut a release (checklists + scripts)
Expand Down
31 changes: 31 additions & 0 deletions appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/appsettings.json",
"Logging": {
"LogLevel": {
"Default": "Debug",
"ModelContextProtocol": "Debug",
"DotNetMcp": "Debug",
"Microsoft.Hosting": "Information"
}
},
"OpenTelemetry": {
"ServiceName": "dotnet-mcp",
"ServiceVersion": "1.0.0-dev",
"Traces": {
"Enabled": false,
"ConsoleExporter": true,
"OtlpExporter": {
"Enabled": false,
"Endpoint": "http://localhost:4317"
}
},
"Metrics": {
"Enabled": false,
"ConsoleExporter": true,
"OtlpExporter": {
"Enabled": false,
"Endpoint": "http://localhost:4317"
}
}
}
}
31 changes: 31 additions & 0 deletions appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/appsettings.json",
"Logging": {
"LogLevel": {
"Default": "Information",
"ModelContextProtocol": "Information",
"DotNetMcp": "Information",
"Microsoft.Hosting": "Warning"
}
},
"OpenTelemetry": {
"ServiceName": "dotnet-mcp",
"ServiceVersion": "1.0.0",
"Traces": {
"Enabled": false,
"ConsoleExporter": false,
"OtlpExporter": {
"Enabled": false,
"Endpoint": "http://localhost:4317"
}
},
"Metrics": {
"Enabled": false,
"ConsoleExporter": false,
"OtlpExporter": {
"Enabled": false,
"Endpoint": "http://localhost:4317"
}
}
}
}
50 changes: 50 additions & 0 deletions doc/performance-baseline.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ For comprehensive performance testing and regression detection, see [Issue #151]
- More comprehensive tool coverage
- Memory profiling

For telemetry and observability features, see [doc/telemetry.md](./telemetry.md):
- Request duration logging (SDK v0.6+)
- OpenTelemetry semantic conventions
- Distributed tracing integration

## Test Methodology

### Configuration
Expand Down Expand Up @@ -130,3 +135,48 @@ If results are consistently better:
- Cache behavior significantly affects results (warmup is critical)
- Results are informational only - tests never fail CI builds
- For production performance budgets, use BenchmarkDotNet (Issue #151)

## Using Telemetry for Performance Monitoring

The MCP SDK v0.6+ automatically logs request duration for all tool invocations. To monitor performance in real-time:

### View Request Durations

All tool executions are logged with duration at `Information` level:

```bash
# Run the server and filter for request completion logs
dotnet-mcp 2>&1 | grep "Request handler completed"
```

Example output:
```
info: ModelContextProtocol.Server.McpServer[LogRequestHandlerCompleted]
Request handler completed: tools/call (DotnetSdkVersion) in 125ms

info: ModelContextProtocol.Server.McpServer[LogRequestHandlerCompleted]
Request handler completed: tools/call (DotnetTemplateList) in 486ms
```

### Analyze Performance Trends

Enable debug logging to see detailed execution traces:

```bash
export Logging__LogLevel__Default=Debug
dotnet-mcp 2>&1 | tee performance-log.txt
```

Then analyze the log for:
- Average duration by tool
- P95 latency (95th percentile)
- Slowest operations
- Cache effectiveness

### Compare Against Baselines

Compare logged durations against the baselines in this document:
- DotnetSdkVersion: Expected ~100ms, investigate if >200ms
- DotnetTemplateList: Expected ~500ms (first run), ~50ms (cached)

For detailed telemetry configuration and OpenTelemetry integration, see [doc/telemetry.md](./telemetry.md).
Loading
Loading