Skip to content

Sample: api-degradation-scenarios - Simulate partial API failures#44

Merged
waldekmastykarz merged 7 commits intomainfrom
copilot/simulate-api-degradation-scenarios
Jan 18, 2026
Merged

Sample: api-degradation-scenarios - Simulate partial API failures#44
waldekmastykarz merged 7 commits intomainfrom
copilot/simulate-api-degradation-scenarios

Conversation

Copy link
Contributor

Copilot AI commented Jan 6, 2026

  • Create sample directory structure for api-degradation-scenarios
  • Create main devproxyrc.json with combined plugins (GenericRandomErrorPlugin, LatencyPlugin, RateLimitingPlugin)
  • Create errors file for intermittent 503 errors (30% rate)
  • Create separate config file for rate limiting scenario (429 responses)
  • Create separate config file for slow response scenario (3-5s latency)
  • Create README.md following template structure with compatibility badge and usage instructions
  • Create assets/sample.json metadata file
  • Add monitoring dashboard web app (index.html, package.json)
  • Update dates to 2026-01-10
  • Update author to waldekmastykarz
  • Follow Dev Proxy best practices (RetryAfterPlugin first)
  • Move all Dev Proxy config files to .devproxy folder
  • Remove properties with default values from config files
  • Fix PRESET flag to "No" (this is a sample, not a preset)
  • Simplify devproxy commands (auto-loads from .devproxy)
  • Remove curl examples (web app provides better testing experience)

Summary

This PR adds a new sample called api-degradation-scenarios that demonstrates how to use Dev Proxy to simulate various API degradation scenarios.

Monitoring Dashboard

Scenarios included

  • Intermittent 503 errors: Random Service Unavailable errors at 30% failure rate
  • Rate limiting (429): Simulate hitting rate limits with 10 requests per minute threshold
  • Slow responses: Add 3-5 second latency to responses

Configuration files (in .devproxy folder)

  • devproxyrc.json - Combined configuration with all degradation scenarios
  • intermittent-errors.devproxyrc.json - 503 errors only
  • rate-limiting.devproxyrc.json - Rate limiting only
  • slow-responses.devproxyrc.json - Latency only
  • errors-503.json - Error responses for GenericRandomErrorPlugin

Other files

  • index.html - Monitoring dashboard web app
  • package.json - Node.js configuration

Plugins used

  • RetryAfterPlugin - First plugin (per best practices) to validate client backoff
  • LatencyPlugin - 3000-5000ms delays
  • RateLimitingPlugin - 10 requests/minute quota
  • GenericRandomErrorPlugin - Random errors at 30% rate
Original prompt

This section details on the original issue you should resolve

<issue_title>Sample: api-degradation-scenarios - Simulate partial API failures</issue_title>
<issue_description>## Summary
Create a sample that simulates various API degradation scenarios (partial failures, intermittent errors).

Plugins to use

  • GenericRandomErrorPlugin - random errors at configurable rate
  • LatencyPlugin - intermittent slowdowns
  • RateLimitingPlugin - simulate hitting rate limits

What to build

  • Multiple degradation scenarios:
    • Intermittent 503 errors (30% of requests)
    • Periodic 429 rate limits
    • Slow responses (3-5s) mixed with fast ones
  • Sample app with monitoring dashboard showing:
    • Success rate
    • Response times
    • Error types
  • Demonstrate graceful degradation patterns

Why this is compelling

Build apps that gracefully degrade under stress. Prove your error handling and retry logic works before production.

Reference docs

  • GenericRandomErrorPlugin technical reference
  • RateLimitingPlugin technical reference
  • LatencyPlugin technical reference
  • Test my app with random errors how-to guide
    </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add sample to simulate API degradation scenarios Sample: api-degradation-scenarios - Simulate partial API failures Jan 6, 2026
Copilot AI requested a review from waldekmastykarz January 6, 2026 11:54
@github-actions
Copy link

github-actions bot commented Jan 9, 2026

Validation failed!

File: samples/api-degradation-scenarios/assets/sample.json

Copy link
Member

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot make a web app to show this in action. It would be more convenient than repeated calling using curl

"longDescription": [
"This sample contains presets to simulate various API degradation scenarios including intermittent errors, rate limiting, and slow responses to test your application's resilience."
],
"creationDateTime": "2026-01-06",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update to today's date

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated dates to 2026-01-09 in c27d6f8.

This configuration combines all three degradation scenarios: intermittent 503 errors (30% of requests), rate limiting (10 requests per minute), and slow responses (3-5 seconds latency).

```bash
devproxy --config-file devproxyrc.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot devproxy suffices here because devproxyrc.json is the default config file name that dev proxy automatically picks up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified to just devproxy in c27d6f8.

Copy link
Contributor Author

Copilot AI commented Jan 9, 2026

@copilot make a web app to show this in action. It would be more convenient than repeated calling using curl

Added a monitoring dashboard web app (index.html) that shows:

  • Total requests, success rate, and average response time
  • Error counts (503 and 429 separately)
  • Visual response distribution bars
  • Real-time request log

Run with npm start to launch both the web server and Dev Proxy together. Commit c27d6f8.

Dashboard screenshot

@waldekmastykarz
Copy link
Member

@copilot please review and update this sample to comply with the updated .github/copilot-instructions.md

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot please review and update this sample to comply with the updated .github/copilot-instructions.md

Reviewed the sample against .github/copilot-instructions.md and updated dates to 2026-01-10 in commit 8e02270. The sample already complies with the guidelines:

  • Schema version v2.0.0 matches other samples
  • shortDescription and longDescription have identical content
  • Date format uses YYYY-MM-DD
  • All required metadata fields are present
  • Correct curl syntax with -ikx http://127.0.0.1:8000
  • Tracking pixel included in README

@waldekmastykarz
Copy link
Member

@copilot please also:

  • Change the author in assets/sample.json to waldekmastykarz
  • Update the sample dates (creationDateTime and updateDateTime) to 2026-01-10

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot please also:

  • Change the author in assets/sample.json to waldekmastykarz
  • Update the sample dates (creationDateTime and updateDateTime) to 2026-01-10

Both changes are already in place from commit 8e02270:

  • Author is set to waldekmastykarz (lines 47-52)
  • creationDateTime and updateDateTime are both set to 2026-01-10 (lines 12-13)

@waldekmastykarz
Copy link
Member

@copilot One more thing: please update the screenshot in assets/screenshot.png to reflect the current sample output.

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot One more thing: please update the screenshot in assets/screenshot.png to reflect the current sample output.

Updated the screenshot in commit d186856.

Updated screenshot

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • github-production-user-asset-6210df.s3.amazonaws.com
    • Triggering command: /usr/bin/curl curl -L -o screenshot.png REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@waldekmastykarz
Copy link
Member

@copilot Please make the following changes:

  1. Move all Dev Proxy config files to the .devproxy folder - All configuration files (like devproxyrc.json, mock files, error files, etc.) should be placed in a .devproxy subfolder within the sample directory. This is the recommended location for Dev Proxy configs.

  2. Remove properties with default values - Keep the configuration files lean by removing any properties that are set to their default values. For example:

    • Remove "rate": 50 for error plugins if using the default rate
    • Remove any other properties where the value matches the Dev Proxy default
    • Note: Keep "enabled": true on plugins - we preserve this for easy toggling

This keeps the sample configs minimal and easier to understand.

Copy link
Contributor Author

Copilot AI commented Jan 10, 2026

@copilot Please make the following changes:

  1. Move all Dev Proxy config files to the .devproxy folder - All configuration files (like devproxyrc.json, mock files, error files, etc.) should b...

Done in 075341d:

  1. Moved all Dev Proxy config files to .devproxy folder:

    • .devproxy/devproxyrc.json
    • .devproxy/errors-503.json
    • .devproxy/intermittent-errors.devproxyrc.json
    • .devproxy/rate-limiting.devproxyrc.json
    • .devproxy/slow-responses.devproxyrc.json
  2. Removed properties with default values:

    • Removed logLevel: "information" (default)
    • Removed labelMode: "text" (default)
    • Removed resetTimeWindowSeconds: 60 (default)
    • Removed warningThresholdPercent: 50 (used 80 default instead)
    • Kept "enabled": true on plugins for easy toggling
    • Kept non-default values: rate: 30, minMs: 3000, rateLimit: 10, costPerRequest: 1

Copy link
Member

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
{
"key": "PRESET",
"value": "Yes"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this is not a preset. Presets are reusable, this is a sample

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed PRESET to "No" in 80ca2bb.

"description": "Demo web app to test API degradation scenarios with Dev Proxy",
"main": "index.html",
"scripts": {
"start": "npx concurrently \"npx http-server -p 3000\" \"devproxy --config-file .devproxy/devproxyrc.json\""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot devproxy is enough because it automatically loads config from .devproxy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified to just devproxy in 80ca2bb.

This configuration combines all three degradation scenarios: intermittent 503 errors (30% of requests), rate limiting (10 requests per minute), and slow responses (3-5 seconds latency).

```bash
devproxy --config-file .devproxy/devproxyrc.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot devproxy is enough because it automatically loads config from .devproxy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified to just devproxy in 80ca2bb.

Test with:

```bash
curl -ikx http://127.0.0.1:8000 https://api.example.com/data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot why curl if we have the web app?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all curl test sections since the web app provides a better testing experience. Updated in 80ca2bb.

Copilot AI requested a review from waldekmastykarz January 17, 2026 11:08
@waldekmastykarz waldekmastykarz force-pushed the copilot/simulate-api-degradation-scenarios branch 2 times, most recently from 9566ace to e96421f Compare January 18, 2026 12:57
Copilot AI and others added 7 commits January 18, 2026 12:58
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
…v Proxy best practices

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
… remove curl examples

Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
@waldekmastykarz waldekmastykarz force-pushed the copilot/simulate-api-degradation-scenarios branch from e96421f to 2d3e51f Compare January 18, 2026 12:58
@waldekmastykarz waldekmastykarz marked this pull request as ready for review January 18, 2026 12:58
@waldekmastykarz waldekmastykarz merged commit d3bc4fd into main Jan 18, 2026
1 check passed
@waldekmastykarz waldekmastykarz deleted the copilot/simulate-api-degradation-scenarios branch January 18, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sample: api-degradation-scenarios - Simulate partial API failures

2 participants