Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion cmd/api/src/model/appcfg/parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
ReconciliationKey ParameterKey = "analysis.reconciliation"
ScheduledAnalysis ParameterKey = "analysis.scheduled"
SupportAccountProvisioningKey ParameterKey = "auth.support_account_provisioning"
ClientMetricsKey ParameterKey = "pipeline.client_metrics"

// The below keys are not intended to be user updatable, so should not be added to IsValidKey
TrustedProxiesConfig ParameterKey = "http.trusted_proxies"
Expand Down Expand Up @@ -92,7 +93,7 @@ func (s *Parameter) Map(value any) error {

func (s *Parameter) IsValidKey(parameterKey ParameterKey) bool {
switch parameterKey {
case PasswordExpirationWindow, Neo4jConfigs, PruneTTL, CitrixRDPSupportKey, ReconciliationKey, ScheduledAnalysis, SupportAccountProvisioningKey:
case PasswordExpirationWindow, Neo4jConfigs, PruneTTL, CitrixRDPSupportKey, ReconciliationKey, ScheduledAnalysis, SupportAccountProvisioningKey, ClientMetricsKey:
return true
default:
return false
Expand Down Expand Up @@ -155,6 +156,8 @@ func (s *Parameter) Validate() utils.Errors {
v = &EnvironmentTargetedAccessControlParameters{}
case SupportAccountProvisioningKey:
v = &SupportAccountProvisioningParameters{}
case ClientMetricsKey:
v = &ClientMetricsParameter{}
default:
return utils.Errors{errors.New("invalid key")}
}
Expand Down Expand Up @@ -624,3 +627,22 @@ func GetSupportAccountProvisioningParameters(ctx context.Context, service Parame

return result
}

type ClientMetricsParameter struct {
Enabled bool `json:"enabled,omitempty"`
}

func GetClientMetricsParameter(ctx context.Context, service ParameterService) ClientMetricsParameter {
result := ClientMetricsParameter{
Enabled: false,
}

if clientMetricsCfg, err := service.GetConfigurationParameter(ctx, ClientMetricsKey); err != nil {
slog.WarnContext(ctx, "Failed to fetch client metrics configuration; returning default values")
} else if err = clientMetricsCfg.Map(&result); err != nil {
slog.WarnContext(ctx, "Invalid client metrics configuration supplied; returning default values",
attr.Error(err))
}

return result
}
Loading