commit 08d8f7a4e0495b826887f42a0674d1d1998394e0 Author: Zhongwei Li Date: Sun Nov 30 08:38:14 2025 +0800 Initial commit diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..34deed2 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,22 @@ +{ + "name": "dd-trace-dotnet", + "description": "Datadog .NET APM Tracer development plugin with commands and context for the dd-trace-dotnet repository", + "version": "1.0.0", + "author": { + "name": "Lucas Pimentel", + "github": "lucaspimentel" + }, + "commands": [ + "./commands/build-tracer.md", + "./commands/check-logs.md", + "./commands/check-pr.md", + "./commands/create-integration.md", + "./commands/find-integration.md", + "./commands/review-and-comment.md", + "./commands/run-tests.md", + "./commands/troubleshoot-ci.md" + ], + "mcp": [ + "./.mcp.json" + ] +} \ No newline at end of file diff --git a/.mcp.json b/.mcp.json new file mode 100644 index 0000000..28110dd --- /dev/null +++ b/.mcp.json @@ -0,0 +1,12 @@ +{ + "mcpServers": { + "azure-devops-pipelines": { + "command": "npx", + "args": [ + "-y", + "github:lucaspimentel/azure-devops-mcp", + "${AZURE_DEVOPS_ORG:-datadoghq}" + ] + } + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..9025113 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# dd-trace-dotnet + +Datadog .NET APM Tracer development plugin with commands and context for the dd-trace-dotnet repository diff --git a/commands/build-tracer.md b/commands/build-tracer.md new file mode 100644 index 0000000..53bc5a8 --- /dev/null +++ b/commands/build-tracer.md @@ -0,0 +1,19 @@ +--- +description: Build the Datadog .NET tracer +--- + +Build the Datadog .NET tracer using the Nuke build system. + +Before building: +1. Check the current working directory - you should be in the dd-trace-dotnet repository root +2. Verify the build will succeed by checking for any obvious issues + +Build options: +- Quick build for testing: `dotnet build tracer/src/Datadog.Trace/ -c Release -f net6.0` +- Full tracer home build: `.\build.cmd BuildTracerHome` (Windows) or `./build.sh BuildTracerHome` (Linux/macOS) +- Clean and build: `.\build.cmd Clean BuildTracerHome` + +After building: +- Report the build result (success/failure) +- If there are errors, analyze them and suggest fixes +- Show the output location if successful diff --git a/commands/check-logs.md b/commands/check-logs.md new file mode 100644 index 0000000..616afa1 --- /dev/null +++ b/commands/check-logs.md @@ -0,0 +1,41 @@ +--- +description: Check and analyze tracer logs +--- + +Check and analyze Datadog .NET tracer logs for debugging. + +Log locations: +- **Windows**: `%ProgramData%\Datadog .NET Tracer\logs\` +- **Linux**: `/var/log/datadog/dotnet/` +- **Application logs**: Look for logs in the application directory + +Log files: +- **dotnet-tracer-managed-{ProcessName}-{PID}.log** - Managed tracer logs +- **dotnet-tracer-native-{ProcessName}-{PID}.log** - Native loader logs +- **dotnet-profiler-{ProcessName}-{PID}.log** - Native profiler logs + +Log levels: +- ERROR - Errors that prevent functionality +- WARN - Potential issues or degraded functionality +- INFO - Normal operation information +- DEBUG - Detailed debugging information + +Common log patterns to check: +1. **Initialization**: "Datadog.Trace.ClrProfiler.Managed.Loader" messages +2. **Configuration**: "Configuration" or "Settings" messages +3. **Instrumentation**: "Instrumentation" or "CallTarget" messages +4. **Errors**: "Error" or "Exception" messages +5. **Performance**: Timing or "elapsed" messages + +When analyzing logs: +1. Check for initialization errors first +2. Verify configuration is loaded correctly +3. Look for integration-specific messages +4. Identify any errors or warnings +5. Check for performance issues (slow initialization, etc.) + +Suggest solutions based on common patterns: +- Missing dependencies +- Configuration issues +- Version mismatches +- Permission problems diff --git a/commands/check-pr.md b/commands/check-pr.md new file mode 100644 index 0000000..b781581 --- /dev/null +++ b/commands/check-pr.md @@ -0,0 +1,60 @@ +--- +description: Check pull request status and CI results +--- + +Check pull request status, CI results, and review details. + +GitHub CLI commands: + +1. **List Recent PRs**: + ```bash + gh pr list --repo DataDog/dd-trace-dotnet + ``` + +2. **View PR Details**: + ```bash + gh pr view --repo DataDog/dd-trace-dotnet + ``` + +3. **Check PR Status/Checks**: + ```bash + gh pr checks --repo DataDog/dd-trace-dotnet + ``` + +4. **View PR Diff**: + ```bash + gh pr diff --repo DataDog/dd-trace-dotnet + ``` + +Azure DevOps commands: + +1. **List Pipeline Runs**: + ```bash + az pipelines runs list --org https://dev.azure.com/datadoghq --project dd-trace-dotnet + ``` + +2. **View Run Details**: + ```bash + az pipelines runs show --id --org https://dev.azure.com/datadoghq --project dd-trace-dotnet + ``` + +What to check: +- **Build status**: All builds passing +- **Test results**: No failing tests +- **Code coverage**: Coverage maintained or improved +- **Integration tests**: All integration tests passing +- **Smoke tests**: Smoke tests successful +- **PR template**: All sections filled out +- **Reviews**: Required reviewers approved + +Common issues: +- Flaky tests: Check test history for patterns +- Timeout: Look for long-running tests +- Docker issues: Verify Docker services are healthy +- Dependencies: Check for version conflicts + +After checking: +- Report status summary (passed/failed/running) +- Identify any blocking issues +- Suggest fixes for failures +- Provide links to detailed results diff --git a/commands/create-integration.md b/commands/create-integration.md new file mode 100644 index 0000000..732e400 --- /dev/null +++ b/commands/create-integration.md @@ -0,0 +1,54 @@ +--- +description: Create a new auto-instrumentation integration +--- + +Create a new auto-instrumentation integration for the Datadog .NET tracer. + +Follow these steps: + +1. **Gather requirements**: + - Target library name and NuGet package + - Supported version range + - Methods to instrument (assembly, type, method signatures) + - Integration category (e.g., HTTP, Database, Messaging, etc.) + +2. **Create integration class**: + - Location: `tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation//.cs` + - Add `[InstrumentMethod]` attribute with: + - `AssemblyName`: Target assembly + - `TypeName`: Fully qualified type name + - `MethodName`: Method to instrument + - `ReturnTypeName`: Method return type + - `ParameterTypeNames`: Array of parameter types + - `MinimumVersion` and `MaximumVersion`: Version range + - `IntegrationName`: Unique integration identifier + - Implement `OnMethodBegin` (for method entry) + - Implement `OnMethodEnd` or `OnAsyncMethodEnd` (for method exit) + +3. **Use duck typing for third-party types**: + - Define interface with required properties/methods + - Use `where TTarget : IMyInterface, IDuckType` constraint + - Or use `target.DuckCast()` for runtime casting + +4. **Add integration tests**: + - Location: `tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests//` + - Create sample application: `tracer/test/test-applications/integrations//` + - Test multiple library versions (package_versions.props) + - Verify spans are created with correct tags + +5. **Generate boilerplate**: + - Run: `./tracer/build.ps1 RunInstrumentationGenerator` + +6. **Update documentation**: + - Add integration to supported libraries list if needed + +Reference files: +- `docs/development/AutomaticInstrumentation.md` - Complete integration guide +- `docs/development/DuckTyping.md` - Duck typing patterns +- `tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/` - Existing integrations + +After creating: +- Run the instrumentation generator +- Build the tracer +- Run integration tests +- Verify spans in test output diff --git a/commands/find-integration.md b/commands/find-integration.md new file mode 100644 index 0000000..c3f5d16 --- /dev/null +++ b/commands/find-integration.md @@ -0,0 +1,40 @@ +--- +description: Find an existing integration in the tracer +--- + +Find an existing auto-instrumentation integration in the Datadog .NET tracer. + +Search strategies: +1. **By library name**: Search for the library name in integration files +2. **By technology**: Look in specific directories under `tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/` +3. **By assembly**: Search for `[InstrumentMethod(AssemblyName = "...")]` attributes + +Available integration categories: +- **AdoNet** - Database drivers (SqlClient, MySql, Npgsql, etc.) +- **AspNet** / **AspNetCore** - ASP.NET web frameworks +- **AWS** - AWS SDK integrations +- **Azure** - Azure SDK integrations +- **Couchbase** - Couchbase client +- **Elasticsearch** - Elasticsearch client +- **GraphQL** - GraphQL libraries +- **Grpc** - gRPC client/server +- **Http** - HttpClient and related +- **IbmMq** - IBM MQ client +- **Kafka** - Kafka client +- **Logging** - Logging frameworks (Serilog, NLog, log4net) +- **MongoDb** - MongoDB client +- **Msmq** - MSMQ messaging +- **OpenTelemetry** - OpenTelemetry interop +- **Process** - Process execution +- **RabbitMQ** - RabbitMQ client +- **Redis** - Redis clients (StackExchange.Redis, ServiceStack.Redis) +- **Remoting** - .NET Remoting +- **Testing** - Test frameworks (xUnit, NUnit, MSTest) +- **Wcf** - WCF services + +After finding: +- Show the integration file path with line numbers +- Display the `[InstrumentMethod]` attributes +- Show which methods are instrumented +- Identify the supported version range +- Link to integration tests if available diff --git a/commands/review-and-comment.md b/commands/review-and-comment.md new file mode 100644 index 0000000..c9f77ec --- /dev/null +++ b/commands/review-and-comment.md @@ -0,0 +1,5 @@ +--- +description: Review PR and post comments to GitHub +--- + +Review this PR, and post the comments to GitHub, making it clear that the comments are from Claude Code. Only mention specific issues not general positive feelings, create an over-arching PR review, ensure all comments are associated with that review, and make individual comments at a specific file and line. diff --git a/commands/run-tests.md b/commands/run-tests.md new file mode 100644 index 0000000..f241f97 --- /dev/null +++ b/commands/run-tests.md @@ -0,0 +1,29 @@ +--- +description: Run tests for the .NET tracer +--- + +Run tests for the Datadog .NET tracer. + +Test types available: +1. **Managed unit tests**: `.\build.cmd BuildAndRunManagedUnitTests` +2. **Native unit tests**: `.\build.cmd BuildAndRunNativeUnitTests` +3. **Windows integration tests**: `.\build.cmd BuildAndRunWindowsIntegrationTests` +4. **Linux integration tests**: `.\build.cmd BuildAndRunLinuxIntegrationTests` +5. **macOS integration tests**: `.\build.cmd BuildAndRunOsxIntegrationTests` +6. **Azure Functions tests**: `.\build.cmd BuildAndRunWindowsAzureFunctionsTests` +7. **Smoke tests**: Use `--filter "Category=Smoke"` parameter + +Additional options: +- Filter by framework: `--framework net6.0` +- Filter by category: `--filter "Category=Smoke"` +- Skip Docker tests: Use environment variable to skip tests requiring Docker + +Before running: +1. Ask the user which type of tests to run if not specified +2. Check if Docker is required and running (for integration tests) +3. Verify you're in the correct directory + +After running: +- Report test results (passed/failed/skipped counts) +- If tests fail, analyze failures and suggest fixes +- Show relevant error messages or stack traces diff --git a/commands/troubleshoot-ci.md b/commands/troubleshoot-ci.md new file mode 100644 index 0000000..bcf377c --- /dev/null +++ b/commands/troubleshoot-ci.md @@ -0,0 +1,35 @@ +--- +description: Troubleshoot CI/CD pipeline failures +--- + +Troubleshoot CI/CD pipeline failures in the dd-trace-dotnet repository. + +Available CI systems: +1. **Azure DevOps** - Primary CI/CD system (`.azure-pipelines/`) +2. **GitHub Actions** - Secondary workflows (`.github/workflows/`) + +Common failure types: +- **Build failures**: Check build logs for compilation errors +- **Test failures**: Analyze test output for specific failures +- **Integration test failures**: Check Docker containers, network issues +- **Timeout issues**: Look for hung tests or long-running operations +- **Flaky tests**: Identify intermittent failures and patterns + +Steps to troubleshoot: +1. **Identify the failed stage**: Build, test, or deployment +2. **Review logs**: Look for error messages, stack traces, or warnings +3. **Check for known issues**: Search recent PRs or issues +4. **Reproduce locally**: Try to run the same build/test locally +5. **Use pipeline tools**: + - Azure DevOps: `az pipelines runs show --id ` + - GitHub Actions: `gh run view ` + +Documentation: +- See `docs/development/CI/TroubleshootingCIFailures.md` for detailed guidance +- See `docs/development/CI/RunSmokeTestsLocally.md` for local testing + +Common solutions: +- Restart the pipeline if infrastructure issue +- Update test package versions if dependency issue +- Increase timeout for slow tests +- Fix test data or mocks for integration tests diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..c598c26 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,77 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:lucaspimentel/claude-code-plugins:plugins/dd-trace-dotnet", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "6a4a1df7e0301244aea9e8302a02443d08176cea", + "treeHash": "265d538e37ec7aad4caf24dd26d7082244cd3e0df648fbe1e11a0fb570b85ea4", + "generatedAt": "2025-11-28T10:20:22.494600Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "dd-trace-dotnet", + "description": "Datadog .NET APM Tracer development plugin with commands and context for the dd-trace-dotnet repository", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": ".mcp.json", + "sha256": "c4f2274e4b7ad5f3ea85c829d983bfa2662fd3641e7e1af55da7ff7c53961032" + }, + { + "path": "README.md", + "sha256": "2ae8bb68b84d5e1a53a20495292678cfdc3cf4c4c1b43cc46fc61dd81219ce43" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "963d84c8d02b3421021233e20a624c87c45b472233c7955b45bc66e82315648d" + }, + { + "path": "commands/run-tests.md", + "sha256": "7d666eea54824e0637d33ba603888be817de576b0397d0ff0a8abd167c223abf" + }, + { + "path": "commands/check-logs.md", + "sha256": "60d7a53d3f4d130e6664000217251a0c31c37bd723e25f12e57e73811ddc8f41" + }, + { + "path": "commands/find-integration.md", + "sha256": "7ca8d93424a79f16c9c08d0693a790490f54cd6aceb5a7dcf3fa67fd73c957d4" + }, + { + "path": "commands/review-and-comment.md", + "sha256": "df5f0c39f7b8f7a6c4b3856432e5b9ebe61613dfad8c1a09d163d883d12ba359" + }, + { + "path": "commands/create-integration.md", + "sha256": "cac43391c80999cfdcbfbf74b1c974fe87d4c0ac79220c20a2e0bd0905c39ded" + }, + { + "path": "commands/troubleshoot-ci.md", + "sha256": "e04142c7a250fa0e4acd0433f3e55bf871e149c58372dd45fb7a270b85d4b45a" + }, + { + "path": "commands/check-pr.md", + "sha256": "feb5d4fdc866a6c4abfcf491347df3d99e89f9a9601e6065096c9291528d0d8e" + }, + { + "path": "commands/build-tracer.md", + "sha256": "a116aa23a454140d05057a63eb96332246909a7ca0cd858ddd79f454ec700304" + } + ], + "dirSha256": "265d538e37ec7aad4caf24dd26d7082244cd3e0df648fbe1e11a0fb570b85ea4" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file