Added some production-default recommendations#1232
Added some production-default recommendations#1232Thorium wants to merge 8 commits intoCompositionalIT:masterfrom
Conversation
|
I had copilot do a few PR's, so no problem with that, but every change still needs to follow the requirements in the PR template. Two big areas that we have to watch for:
|
ninjarobot
left a comment
There was a problem hiding this comment.
These changes look good from the standpoint of functionality and compatibility. All the documentation is definitely appreciated as well.
|
This was rather question (with code attached) of do we want to take this direction, rather than a PR intended to be merged. We can close the PR but what you think about the idea? |
|
Reopened: Actually, as documentation improvement, this might be valuable. |
|
I'm good with the direction and I've been going through issues to see which ones are defined clearly enough to give to AI. It would definitely really help to tell it to focus on a feature at a time, though. Maintaining quality when there are huge change sets coming in from AI is really difficult. Breaking changes are incredibly detrimental to OSS projects - the last thing we want is for users to be concerned about taking upgrades. |
|
I had to do this for Copilot so it would fix up code to prevent fantomas failures. Is there something that could be added to the repo to make it easier for Claude as well? |
|
Generally working with all agents, you add AGENTS.md as general instructions and patterns how they should do things. You can ask e.g. Claude to generate you a template and then modify it by your needs. |
There was a problem hiding this comment.
Pull request overview
This PR introduces “production default” helper keywords and guidance aimed at making Azure Functions and Application Insights configurations safer/more cost-aware by default (HTTPS enforcement, scale caps, and sampling presets), along with tests and documentation/examples.
Changes:
- Added
production_defaultsto the Functions builder (HTTPS-only, AlwaysOn for non-Consumption, and a Consumption scale cap default). - Added
production_sampling/development_samplingto the App Insights builder, plus sampling validation tests. - Added new production guidance documentation and a “production-ready” example script.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Tests/Functions.fs | Adds tests covering production_defaults behavior and override behavior. |
| src/Tests/AppInsights.fs | Adds tests for sampling presets and sampling percentage validation. |
| src/Farmer/Builders/Builders.Functions.fs | Implements production_defaults and adds a runtime warning when Consumption has no scale limit. |
| src/Farmer/Builders/Builders.AppInsights.fs | Implements sampling presets and adds a runtime warning when sampling is 100%. |
| examples/production-ready-example.fsx | New script demonstrating intended “production-ready” usage (currently references missing APIs). |
| docs/content/deployment-guidance/production-best-practices.md | New best-practices guide for production deployments. |
| docs/content/api-overview/resources/functions.md | Documents the new production_defaults keyword and provides examples. |
| docs/content/api-overview/resources/app-insights.md | Documents the new sampling keywords and provides examples/notes. |
| // Production: 20% sampling (keeps all errors, samples successes) | ||
| let prodInsights = appInsights { | ||
| name "high-traffic-api-insights" | ||
| production_sampling | ||
| } |
There was a problem hiding this comment.
The example/commentary here says "keeps all errors" with production sampling. Please avoid an absolute guarantee about error retention under sampling (failed requests can still be sampled depending on telemetry type/sampling mode); reword more cautiously and link to the Azure sampling docs.
| open Farmer | ||
| open Farmer.Builders | ||
| open Farmer.ProductionValidation | ||
| open Farmer.ProductionDefaults | ||
|
|
There was a problem hiding this comment.
This example script imports Farmer.ProductionValidation and Farmer.ProductionDefaults, but those modules don't exist anywhere under src/ in this branch (search found no matches). As written, the script will not compile/run; either add the missing modules to the library, or remove/replace these open statements with existing APIs.
| |> Functions.validateAndWarn // Show validation results | ||
|
|
There was a problem hiding this comment.
The example calls Functions.validateAndWarn here, but no validateAndWarn exists under src/ (search returned no matches). Either implement this helper and expose it from a real module, or change the example to use existing APIs so it runs as-is.
| ### High Sampling Warning | ||
| ```fsharp | ||
| let fullSampling = appInsights { | ||
| name "my-ai" | ||
| sampling_percentage 100 | ||
| } | ||
| // Warning: [my-ai] App Insights sampling at 100%. For high-traffic production apps, consider 'production_sampling' | ||
| ``` |
There was a problem hiding this comment.
The "Helpful Warnings" section states Farmer will warn about sampling=100% "for production workloads", but the implementation warns unconditionally when sampling is 100% (including the default). Please align the docs with the actual behavior, or switch to an explicit/opt-in validation API where callers decide when to emit warnings.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
I did ask from Claude Sonnet what is in FsCDK (AWS) that Farmer (Azure) is missing, and it came up with this PR:
Farmer already has some opinionated approaches, but it doesn't really go into "production-environment-focus" (cost-efficiency, logging, hardened security, and so on).
Be suspicious about agents... Meanwhile this PR can be ready for merge, I'm not actually expecting that.
Rather the question is, would we want to take Farmer into this direction or no?