public SimpleSignalFlowProgramBuilder withScope(SignalFxCanaryScope canaryScope) { scopeKeys.addAll(Optional.ofNullable(canaryScope.getExtendedScopeParams()).orElse(new HashMap<>()) .keySet().stream().filter(key -> !key.startsWith("_")).collect(Collectors.toList())); canaryScope.setScopeKey(Optional.ofNullable(canaryScope.getScopeKey()) .orElseGet(() -> Optional.ofNullable(scopeConfiguration.getDefaultScopeKey()) .orElseThrow(() -> new IllegalArgumentException("The SignalFx account must define a default scope key or " + "it must be supplied in the extendedScopeParams in the `_scope_key` key")))); Optional.ofNullable(Optional.ofNullable(canaryScope.getLocationKey()) .orElse(Optional.ofNullable(scopeConfiguration.getDefaultLocationKey()).orElse(null))) .ifPresent( locationKey -> { canaryScope.setLocationKey(locationKey); scopeKeys.add(locationKey); }); scopeKeys.add(canaryScope.getScopeKey()); filterSegments.add(buildFilterSegmentFromScope(canaryScope)); return this; }
public SimpleSignalFlowProgramBuilder withScope(SignalFxCanaryScope canaryScope) { scopeKeys.addAll(Optional.ofNullable(canaryScope.getExtendedScopeParams()).orElse(new HashMap<>()) .keySet().stream().filter(key -> !key.startsWith("_")).collect(Collectors.toList())); canaryScope.setScopeKey(Optional.ofNullable(canaryScope.getScopeKey()) .orElseGet(() -> Optional.ofNullable(scopeConfiguration.getDefaultScopeKey()) .orElseThrow(() -> new IllegalArgumentException("The SignalFx account must define a default scope key or " + "it must be supplied in the extendedScopeParams in the `_scope_key` key")))); Optional.ofNullable(Optional.ofNullable(canaryScope.getLocationKey()) .orElse(Optional.ofNullable(scopeConfiguration.getDefaultLocationKey()).orElse(null))) .ifPresent( locationKey -> { canaryScope.setLocationKey(locationKey); scopeKeys.add(locationKey); }); scopeKeys.add(canaryScope.getScopeKey()); filterSegments.add(buildFilterSegmentFromScope(canaryScope)); return this; }