copyWithOverrides creates a copy of the config using values set in the overrides.
(o metricsGeneratorOverrides, userID string)
| 177 | |
| 178 | // copyWithOverrides creates a copy of the config using values set in the overrides. |
| 179 | func (cfg *ProcessorConfig) copyWithOverrides(o metricsGeneratorOverrides, userID string) (ProcessorConfig, error) { |
| 180 | copyCfg := *cfg |
| 181 | |
| 182 | if buckets := o.MetricsGeneratorProcessorServiceGraphsHistogramBuckets(userID); buckets != nil { |
| 183 | copyCfg.ServiceGraphs.HistogramBuckets = buckets |
| 184 | } |
| 185 | if dimensions := o.MetricsGeneratorProcessorServiceGraphsDimensions(userID); dimensions != nil { |
| 186 | copyCfg.ServiceGraphs.Dimensions = dimensions |
| 187 | } |
| 188 | if peerAttrs := o.MetricsGeneratorProcessorServiceGraphsPeerAttributes(userID); peerAttrs != nil { |
| 189 | copyCfg.ServiceGraphs.PeerAttributes = peerAttrs |
| 190 | } |
| 191 | if filterPolicies := o.MetricsGeneratorProcessorServiceGraphsFilterPolicies(userID); filterPolicies != nil { |
| 192 | copyCfg.ServiceGraphs.FilterPolicies = filterPolicies |
| 193 | } |
| 194 | if buckets := o.MetricsGeneratorProcessorSpanMetricsHistogramBuckets(userID); buckets != nil { |
| 195 | copyCfg.SpanMetrics.HistogramBuckets = buckets |
| 196 | } |
| 197 | if dimensions := o.MetricsGeneratorProcessorSpanMetricsDimensions(userID); dimensions != nil { |
| 198 | copyCfg.SpanMetrics.Dimensions = dimensions |
| 199 | } |
| 200 | if dimensions := o.MetricsGeneratorProcessorSpanMetricsIntrinsicDimensions(userID); dimensions != nil { |
| 201 | err := copyCfg.SpanMetrics.IntrinsicDimensions.ApplyFromMap(dimensions) |
| 202 | if err != nil { |
| 203 | return ProcessorConfig{}, fmt.Errorf("fail to apply overrides: %w", err) |
| 204 | } |
| 205 | } |
| 206 | if filterPolicies := o.MetricsGeneratorProcessorSpanMetricsFilterPolicies(userID); filterPolicies != nil { |
| 207 | copyCfg.SpanMetrics.FilterPolicies = filterPolicies |
| 208 | } |
| 209 | |
| 210 | if histograms := o.MetricsGeneratorGenerateNativeHistograms(userID); histograms != "" { |
| 211 | copyCfg.ServiceGraphs.HistogramOverride = registry.HistogramModeToValue[string(histograms)] |
| 212 | copyCfg.SpanMetrics.HistogramOverride = registry.HistogramModeToValue[string(histograms)] |
| 213 | } |
| 214 | |
| 215 | if dimensionMappings := o.MetricsGeneratorProcessorSpanMetricsDimensionMappings(userID); dimensionMappings != nil { |
| 216 | copyCfg.SpanMetrics.DimensionMappings = dimensionMappings |
| 217 | } |
| 218 | |
| 219 | if enableTargetInfo, ok := o.MetricsGeneratorProcessorSpanMetricsEnableTargetInfo(userID); ok { |
| 220 | copyCfg.SpanMetrics.EnableTargetInfo = enableTargetInfo |
| 221 | } |
| 222 | |
| 223 | if targetInfoExcludedDimensions := o.MetricsGeneratorProcessorSpanMetricsTargetInfoExcludedDimensions(userID); targetInfoExcludedDimensions != nil { |
| 224 | copyCfg.SpanMetrics.TargetInfoExcludedDimensions = targetInfoExcludedDimensions |
| 225 | } |
| 226 | |
| 227 | if EnableInstanceLabel, ok := o.MetricsGeneratorProcessorSpanMetricsEnableInstanceLabel(userID); ok { |
| 228 | copyCfg.SpanMetrics.EnableInstanceLabel = EnableInstanceLabel |
| 229 | } |
| 230 | |
| 231 | if enableClientServerPrefix := o.MetricsGeneratorProcessorServiceGraphsEnableClientServerPrefix(userID); enableClientServerPrefix { |
| 232 | copyCfg.ServiceGraphs.EnableClientServerPrefix = enableClientServerPrefix |
| 233 | } |
| 234 | |
| 235 | if enableMessagingSystemLatencyHistogram, ok := o.MetricsGeneratorProcessorServiceGraphsEnableMessagingSystemLatencyHistogram(userID); ok { |
| 236 | copyCfg.ServiceGraphs.EnableMessagingSystemLatencyHistogram = enableMessagingSystemLatencyHistogram |