chore: runtime configuration improvements#1661
Conversation
📝 WalkthroughWalkthroughAdds runtime secrets JSON loading from a configurable directory and enhances OpenTelemetry setup: new AppSettings properties for runtime directory and collector flag, exporter selection logic (Azure Monitor vs OTLP), and a trace filter excluding /health; includes unit tests for runtime config loading. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
test/Altinn.App.Api.Tests/Extensions/WebHostBuilderExtensionsTests.cs
Dismissed
Show dismissed
Hide dismissed
test/Altinn.App.Api.Tests/Extensions/WebHostBuilderExtensionsTests.cs
Dismissed
Show dismissed
Hide dismissed
| IHostEnvironment hostEnvironment | ||
| ) | ||
| { | ||
| const string secretsDirectory = "/mnt/app-secrets"; |
There was a problem hiding this comment.
Can we make this path configurable? I feel like this code should be unaware of our infrastructure(mount paths etc). What do you think?
There was a problem hiding this comment.
Very good point 🫡
There was a problem hiding this comment.
maybe a little strange to have a public member for this, could be just some env var as well
91b5a85 to
ea4d578
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/Altinn.App.Api/Extensions/ServiceCollectionExtensions.cs (1)
262-272:⚠️ Potential issue | 🟡 MinorSilent OTLP fallback when neither collector nor AppInsights is configured.
When
useOpenTelemetryCollectorisfalse/nullandappInsightsConnectionStringis empty, theelsebranch activates the OTLP exporter targeting the default endpoint (localhost:4317). In a non-test environment without an OTel collector running, this will silently fail or produce connection errors.Consider either:
- Logging a warning when falling back to OTLP without an explicit opt-in, or
- Skipping exporter registration entirely when no backend is configured.
This same pattern applies to metrics (Line 285) and logs (Line 307).
🧹 Nitpick comments (2)
src/Altinn.App.Api/Extensions/WebHostBuilderExtensions.cs (2)
101-143: Two-pass approach for override ordering is clear and correct.Non-override files load first (sorted), then override files load second (sorted), ensuring overrides always win regardless of alphabetical position. The
existingJsonFilePathscheck prevents double-loading files already registered (e.g., maskinporten settings). Well structured.One edge-case note: any file whose name contains the substring
"override"anywhere (e.g.,no-override-here.json) will be treated as an override file. If this is intentional, consider documenting the naming convention; if not, a stricter check (e.g., suffix.override.json) would be more predictable.
68-77: Consider logging when the secrets directory is absent.When the directory doesn't exist, the method silently returns. A debug/trace-level log here would help operators diagnose misconfigured mounts without adding noise in normal operation.
|


Description
/mnt/app-secrets/JSON files automatically added, so we can extend configuration over time without relying on app-lib changes for every little thingRelated Issue(s)
Verification
Documentation
Summary by CodeRabbit
New Features
Improvements
Tests