feat: add setting to use semconv metrics name#352
Conversation
WalkthroughAdded a per-deployment boolean setting Changes
Sequence DiagramsequenceDiagram
participant Handler as Deployment Handler
participant Chain as Mutator Chain
participant Mutator as withSemconvMetricsNames
participant Store as Setting Store
participant Deployment as Deployment Object
Handler->>Chain: run mutators (including withSemconvMetricsNames)
Chain->>Mutator: invoke
Mutator->>Store: read deployments.<name>.semconv-metrics-names
Store-->>Mutator: boolean value
alt enabled
Mutator->>Deployment: inject SEMCONV_METRICS_NAME=true into init containers
Mutator->>Deployment: inject SEMCONV_METRICS_NAME=true into regular containers
end
Mutator-->>Chain: return mutated deployment
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/resources/applications/application_test.go (1)
206-283: Consider calling the actual function for more robust unit testing.The test currently simulates the behavior manually rather than calling
app.withSemconvMetricsNames(ctx)(deployment). While the comments indicate integration tests cover the full behavior, the unit test would be more valuable if it actually invoked the function being tested.Compare with
TestWithNodeIP(line 171), which callsapp.withNodeIP(nil)(tc.deployment)directly. You could follow a similar pattern here, though you'd need to handle the context/settings dependency (perhaps with a mock or by accepting that the setting defaults to false).The current test does verify the env var injection logic correctly, so this is a nice-to-have improvement rather than a critical issue.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
docs/09-Configuration reference/01-Settings.md(1 hunks)internal/resources/applications/application.go(2 hunks)internal/resources/applications/application_test.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
internal/resources/applications/application_test.go (1)
internal/core/env.go (1)
Env(11-16)
internal/resources/applications/application.go (2)
internal/core/utils.go (1)
ObjectMutator(70-70)internal/resources/settings/helpers.go (1)
GetBoolOrFalse(244-246)
🔇 Additional comments (3)
docs/09-Configuration reference/01-Settings.md (1)
43-43: LGTM! Clear documentation for the new setting.The documentation entry is well-formatted and clearly describes the behavior of the new
semconv-metrics-namessetting. The description accurately reflects thatSEMCONV_METRICS_NAMEwill be injected into all containers when enabled.internal/resources/applications/application.go (2)
383-408: LGTM! Well-implemented mutator following established patterns.The
withSemconvMetricsNamesmethod correctly:
- Retrieves the per-deployment setting using the documented key structure
- Returns early when the setting is disabled (opt-in behavior)
- Injects
SEMCONV_METRICS_NAME=trueinto both init containers and regular containers- Follows the same pattern as
withJsonLoggingfor consistency
456-456: LGTM! Mutator correctly added to the chain.The new mutator is properly integrated into the deployment mutator chain alongside other environment variable mutators.
7ac674f to
b038fd8
Compare
Signed-off-by: Sylvain Rabot <sylvain@formance.com> Co-authored-by: Cursor <cursor@formancehq.com>
b038fd8 to
663cdf0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
docs/09-Configuration reference/01-Settings.md(1 hunks)internal/resources/applications/application.go(2 hunks)internal/resources/applications/application_test.go(2 hunks)internal/resources/applications/mock_test.go(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- internal/resources/applications/application.go
🧰 Additional context used
🧬 Code graph analysis (2)
internal/resources/applications/application_test.go (6)
api/formance.com/v1beta1/settings_types.go (2)
Settings(208-213)SettingsSpec(23-31)internal/resources/settings/helpers.go (1)
SplitKeywordWithDot(416-435)internal/core/context.go (1)
Context(10-16)internal/core/platform.go (1)
Platform(3-13)api/formance.com/v1beta1/ledger_types.go (2)
Ledger(47-53)LedgerSpec(23-28)internal/resources/applications/application.go (1)
Application(125-130)
internal/resources/applications/mock_test.go (3)
internal/tests/internal/bootstrap.go (1)
GetScheme(43-45)internal/core/platform.go (1)
Platform(3-13)internal/core/context.go (1)
Context(10-16)
No description provided.