-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
123 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
.../main/java/com/transferwise/tasks/core/autoconfigure/TwTasksEnvironmentPostProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.transferwise.tasks.core.autoconfigure; | ||
|
||
import com.transferwise.tasks.helpers.CoreMetricsTemplate; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.env.EnvironmentPostProcessor; | ||
import org.springframework.core.env.ConfigurableEnvironment; | ||
import org.springframework.core.env.MapPropertySource; | ||
import org.springframework.core.env.PropertySource; | ||
|
||
@Slf4j | ||
public class TwTasksEnvironmentPostProcessor implements EnvironmentPostProcessor { | ||
|
||
private static final String PROPERTY_SOURCE_KEY = TwTasksEnvironmentPostProcessor.class.getName(); | ||
static final String TW_OBS_BASE_EXTREMUM_CONFIG_PATH = "transferwise.observability.base.metrics.local-extremum-gauge-names.tw-tasks"; | ||
|
||
@Override | ||
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { | ||
PropertySource<?> propertySource = environment.getPropertySources().get(PROPERTY_SOURCE_KEY); | ||
if (propertySource == null) { | ||
final HashMap<String, Object> map = new HashMap<>(); | ||
|
||
// Calculate last minute min/max using tw-observability-base local extremums. | ||
Set<String> gaugeNames = new HashSet<>(); | ||
gaugeNames.add(CoreMetricsTemplate.GAUGE_METRIC_PROCESSING_ONGOING_TASKS_GRABBINGS_COUNT); | ||
gaugeNames.add(CoreMetricsTemplate.GAUGE_PROCESSING_RUNNING_TASKS_COUNT); | ||
gaugeNames.add(CoreMetricsTemplate.GAUGE_PROCESSING_IN_PROGRESS_TASKS_GRABBING_COUNT); | ||
gaugeNames.add(CoreMetricsTemplate.GAUGE_TASKS_ONGOING_PROCESSINGS_COUNT); | ||
|
||
map.put(TW_OBS_BASE_EXTREMUM_CONFIG_PATH, gaugeNames); | ||
|
||
MapPropertySource mapPropertySource = new MapPropertySource(PROPERTY_SOURCE_KEY, map); | ||
environment.getPropertySources().addLast(mapPropertySource); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tw-tasks-core-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.transferwise.tasks.core.autoconfigure.TwTasksCoreAutoConfiguration | ||
org.springframework.context.ApplicationListener=com.transferwise.tasks.TwTasksApplicationListener | ||
org.springframework.boot.env.EnvironmentPostProcessor=com.transferwise.tasks.core.autoconfigure.TwTasksEnvironmentPostProcessor |
Oops, something went wrong.