Optimize PowerShell script and restructure README - #8
Merged
Merged
Conversation
… comments Performance: - Compiled MetricProcessor via Add-Type (C#): ~44K-datapoint JSON loop runs at native .NET speed instead of interpreted PowerShell - Compiled GapProcessor via Add-Type (C#): ExpandToTickSet and ClassifyGaps replace interpreted loops for gap investigation - Shared HttpClient with connection pooling for per-resource metrics and gap investigation (replaces Invoke-WebRequest per-call overhead) - HashSet-based O(1) interval containment for suspect-minute classification - TryGetProperty hash lookup instead of EnumerateObject linear scan Bug fixes: - Per-resource ARM metric URL now includes metricnamespace parameter (fixes SQL databases showing 0 0 N/A) - Case-insensitive metric name comparisons in compiled C# (matching PowerShell -eq behavior) - Idempotent Add-Type guards: two independently guarded blocks so script can be re-run in the same session without 'type already exists' errors Code quality: - Added/improved comments on complex code blocks (classification logic, interval merging, gap counting, Step 7 assembly) - Updated section headers for consistency - README: added architecture notes for compiled GapProcessor, idempotent Add-Type guards, HttpClient coverage for gap investigation
Reorganized from 7 scattered sections into 3 clean sections:
1. Introduction (what it does, two implementations, key questions)
2. Usage (prerequisites, parameters, examples, output)
3. How it works (inventory, metrics, gap investigation, result assembly,
worked example, implementation notes)
Removed redundancies:
- Suspect=Faults+Excused+Unresolved invariant (was stated 3 times)
- Health History retention (was mentioned 4+ times)
- 90-day lookback constraint (intro, parameters, architecture notes)
- Storage zero-tx handling (Step 2, Step 4, separate subsection, arch notes)
- Customer-initiated detection fields (Step 3 + architecture notes)
- Conservative-on-failure (Step 3 + architecture notes)
- Batch API details (Step 2 + architecture notes)
- Native AOT, pipeline output (each mentioned twice)
Merged 'How it works' steps and 'Architecture notes' into a single
coherent technical section. Consolidated Parameters, Prerequisites,
Usage, and Output under a single 'Usage' heading. Trimmed duplicate
C#/PowerShell examples to representative subset.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Performance optimizations for the PowerShell script and a full README restructure to eliminate redundancies.
PowerShell script changes
Performance
Add-Type(C#): the ~44K-datapoint-per-resource JSON processing loop runs at native .NET speed instead of interpreted PowerShellAdd-Type(C#):ExpandToTickSetandClassifyGapsreplace interpreted loops for gap investigationInvoke-WebRequestTCP/TLS overhead)EnumerateObjectlinear scanBug fixes
metricnamespaceparameter (fixes SQL databases showing0 0 N/A)-eqbehavior)Add-Typeguards: two independently guarded blocks so the script can be re-run within the same PowerShell sessionCode quality
README changes
Restructured from 7 scattered sections into 3 clean sections:
Removed redundancies:
Suspect = Faults + Excused + Unresolvedinvariant (was stated 3 times)