Skip to content

[code-simplifier] Simplify instrumentation builder methods - #45

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/simplify-builder-extensions-4dbeb2357baa3f66
Draft

[code-simplifier] Simplify instrumentation builder methods#45
github-actions[bot] wants to merge 1 commit into
mainfrom
refactor/simplify-builder-extensions-4dbeb2357baa3f66

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Code Simplification - 2026-09-03

This PR simplifies recently added builder extension methods to improve clarity and reduce unnecessary branching while preserving all functionality.

Files Simplified

  • src/WitnessSharp/WitnessBuilderExtensions.cs - Eliminated redundant null-check branches in two instrumentation methods

Improvements Made

  1. Reduced Complexity

    • Removed if-else blocks in WithAspNetCoreInstrumentation() and WithHttpClientInstrumentation() methods
    • The OpenTelemetry SDK methods accept nullable configure delegates, making the branching unnecessary
    • Direct parameter passing is clearer and more maintainable
  2. Enhanced Clarity

    • Makes it immediately obvious that these are simple pass-throughs to the OTel SDK
    • Reduced from 17 lines to 7 lines per method (~59% reduction per method)
    • Eliminates cognitive overhead from conditional logic
  3. Applied Project Standards

    • Follows the pattern: delegate directly when the underlying method supports it
    • Maintains consistency with the project's preference for explicit, straightforward code over clever conditionals

Changes Based On

Initial commit of WitnessSharp repository (commit de160c1 - "Reduce bloat in README Recipes section #44")

Testing

  • ✅ All 180+ tests pass across both net8.0 and net10.0 target frameworks
  • ✅ No functional changes - behavior is identical
  • ✅ Configuration still works as expected with both explicit and default null configure parameters

Review Focus

Please verify:

  • Functionality is preserved (all tests pass)
  • Simplifications improve code quality and readability
  • The change aligns with the project's preference for explicit, straightforward code

Generated by Code Simplifier · ● 209.2K ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/code-simplifier.md@1c6668b751c51af8571f01204ceffb19362e0f66
  • expires on Sep 4, 2026, 2:52 PM UTC

Remove redundant null-check branches in WithAspNetCoreInstrumentation
and WithHttpClientInstrumentation methods. The OpenTelemetry SDK methods
accept nullable configure delegates, so we can pass the parameter directly
instead of branching on null.

- Reduces complexity by eliminating if-else blocks
- Makes intent clearer: these are simple pass-throughs
- Maintains identical behavior (all tests pass)
- Reduces lines of code by ~10 per method

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants