@Test public void testResolveLogPathReferences() { Telemetry telemetry = new Telemetry(); Map<String, Object> fluentAttributes = new HashMap<>(); fluentAttributes.put(SERVICE_LOG_FOLDER_PREFIX, "/var/log"); fluentAttributes.put(SERVER_LOG_FOLDER_PREFIX, "/custom/log"); fluentAttributes.put(AGENT_LOG_FOLDER_PREFIX, "/grid/0/log"); telemetry.setFluentAttributes(fluentAttributes); List<VmLog> vmLogs = new ArrayList<>(); VmLog log1 = new VmLog(); log1.setPath("${serviceLogFolderPrefix}/mylog.log"); VmLog log2 = new VmLog(); log2.setPath("${agentLogFolderPrefix}/*"); VmLog log3 = new VmLog(); log3.setPath("/my/path${serverLogFolderPrefix}/*"); vmLogs.add(log1); vmLogs.add(log2); vmLogs.add(log3); underTest.resolveLogPathReferences(telemetry, vmLogs); assertEquals("/var/log/mylog.log", vmLogs.get(0).getPath()); assertEquals("/grid/0/log/*", vmLogs.get(1).getPath()); assertEquals("/my/path/custom/log/*", vmLogs.get(2).getPath()); }
@VisibleForTesting void resolveLogPathReferences(Telemetry telemetry, List<VmLog> logs) { Map<String, Object> fluentAttributes = telemetry.getFluentAttributes(); if (CollectionUtils.isNotEmpty(logs)) { Properties props = new Properties(); props.setProperty(SERVER_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVER_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(AGENT_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(AGENT_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(SERVICE_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVICE_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper("${", "}"); for (VmLog log : logs) { String resolvedPath = propertyPlaceholderHelper.replacePlaceholders(log.getPath(), props); log.setPath(resolvedPath); } } }
TelemetryCommonConfigService { @VisibleForTesting void resolveLogPathReferences(Telemetry telemetry, List<VmLog> logs) { Map<String, Object> fluentAttributes = telemetry.getFluentAttributes(); if (CollectionUtils.isNotEmpty(logs)) { Properties props = new Properties(); props.setProperty(SERVER_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVER_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(AGENT_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(AGENT_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(SERVICE_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVICE_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper("${", "}"); for (VmLog log : logs) { String resolvedPath = propertyPlaceholderHelper.replacePlaceholders(log.getPath(), props); log.setPath(resolvedPath); } } } }
TelemetryCommonConfigService { @VisibleForTesting void resolveLogPathReferences(Telemetry telemetry, List<VmLog> logs) { Map<String, Object> fluentAttributes = telemetry.getFluentAttributes(); if (CollectionUtils.isNotEmpty(logs)) { Properties props = new Properties(); props.setProperty(SERVER_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVER_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(AGENT_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(AGENT_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(SERVICE_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVICE_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper("${", "}"); for (VmLog log : logs) { String resolvedPath = propertyPlaceholderHelper.replacePlaceholders(log.getPath(), props); log.setPath(resolvedPath); } } } TelemetryCommonConfigService(AnonymizationRuleResolver anonymizationRuleResolver,
            @Value("${info.app.version:}") String version); }
TelemetryCommonConfigService { @VisibleForTesting void resolveLogPathReferences(Telemetry telemetry, List<VmLog> logs) { Map<String, Object> fluentAttributes = telemetry.getFluentAttributes(); if (CollectionUtils.isNotEmpty(logs)) { Properties props = new Properties(); props.setProperty(SERVER_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVER_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(AGENT_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(AGENT_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(SERVICE_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVICE_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper("${", "}"); for (VmLog log : logs) { String resolvedPath = propertyPlaceholderHelper.replacePlaceholders(log.getPath(), props); log.setPath(resolvedPath); } } } TelemetryCommonConfigService(AnonymizationRuleResolver anonymizationRuleResolver,
            @Value("${info.app.version:}") String version); TelemetryCommonConfigView createTelemetryCommonConfigs(Telemetry telemetry, List<VmLog> logs,
            String clusterType, String clusterCrn, String clusterName, String clusterOwner, String platform); }
TelemetryCommonConfigService { @VisibleForTesting void resolveLogPathReferences(Telemetry telemetry, List<VmLog> logs) { Map<String, Object> fluentAttributes = telemetry.getFluentAttributes(); if (CollectionUtils.isNotEmpty(logs)) { Properties props = new Properties(); props.setProperty(SERVER_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVER_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(AGENT_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(AGENT_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); props.setProperty(SERVICE_LOG_FOLDER_PREFIX, fluentAttributes.getOrDefault(SERVICE_LOG_FOLDER_PREFIX, LOG_FOLDER_DEFAULT).toString()); PropertyPlaceholderHelper propertyPlaceholderHelper = new PropertyPlaceholderHelper("${", "}"); for (VmLog log : logs) { String resolvedPath = propertyPlaceholderHelper.replacePlaceholders(log.getPath(), props); log.setPath(resolvedPath); } } } TelemetryCommonConfigService(AnonymizationRuleResolver anonymizationRuleResolver,
            @Value("${info.app.version:}") String version); TelemetryCommonConfigView createTelemetryCommonConfigs(Telemetry telemetry, List<VmLog> logs,
            String clusterType, String clusterCrn, String clusterName, String clusterOwner, String platform);  }