Skip to content

Added some production-default recommendations#1232

Open
Thorium wants to merge 8 commits intoCompositionalIT:masterfrom
Thorium:helpers-and-docs
Open

Added some production-default recommendations#1232
Thorium wants to merge 8 commits intoCompositionalIT:masterfrom
Thorium:helpers-and-docs

Conversation

@Thorium
Copy link
Copy Markdown
Contributor

@Thorium Thorium commented Nov 4, 2025

I did ask from Claude Sonnet what is in FsCDK (AWS) that Farmer (Azure) is missing, and it came up with this PR:

  • Farmer lacks best-practice safe settings for production ready environments.
  • So this build adds those

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?

@ninjarobot
Copy link
Copy Markdown
Collaborator

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:

  • Testing against a live Azure subscription to make sure the changes really work - this falls on the human to do (or you can give an agent access to your own subscription for testing).
  • Testing for backwards compatibility. This PR didn't do it, but some PR's go and change all the breaking tests, even when the breakage is there to catch compatibility issues.

Copy link
Copy Markdown
Collaborator

@ninjarobot ninjarobot left a comment

Choose a reason for hiding this comment

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

These changes look good from the standpoint of functionality and compatibility. All the documentation is definitely appreciated as well.

@Thorium
Copy link
Copy Markdown
Contributor Author

Thorium commented Dec 5, 2025

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?

@Thorium Thorium closed this Dec 5, 2025
@Thorium
Copy link
Copy Markdown
Contributor Author

Thorium commented Dec 5, 2025

Reopened: Actually, as documentation improvement, this might be valuable.

@Thorium Thorium reopened this Dec 5, 2025
@ninjarobot
Copy link
Copy Markdown
Collaborator

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.

@ninjarobot
Copy link
Copy Markdown
Collaborator

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?

@Thorium
Copy link
Copy Markdown
Contributor Author

Thorium commented Dec 5, 2025

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_defaults to the Functions builder (HTTPS-only, AlwaysOn for non-Consumption, and a Consumption scale cap default).
  • Added production_sampling / development_sampling to 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.

Comment on lines +52 to +56
// Production: 20% sampling (keeps all errors, samples successes)
let prodInsights = appInsights {
name "high-traffic-api-insights"
production_sampling
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread src/Farmer/Builders/Builders.Functions.fs Outdated
Comment thread src/Farmer/Builders/Builders.AppInsights.fs Outdated
Comment on lines +6 to +10
open Farmer
open Farmer.Builders
open Farmer.ProductionValidation
open Farmer.ProductionDefaults

Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +32
|> Functions.validateAndWarn // Show validation results

Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread docs/content/api-overview/resources/app-insights.md Outdated
Comment thread src/Farmer/Builders/Builders.AppInsights.fs Outdated
Comment thread docs/content/deployment-guidance/production-best-practices.md Outdated
Comment thread docs/content/deployment-guidance/production-best-practices.md Outdated
Comment on lines +163 to +170
### 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'
```
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Thorium and others added 6 commits April 23, 2026 15:07
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>
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.

4 participants