Skip to content

Commit

Permalink
config update, make outputServer appendType as top appendType config (#…
Browse files Browse the repository at this point in the history
…244)

* config update, make outputServer appendType as top appendType config
* add user minimal config file description
  • Loading branch information
Oseenix authored Mar 11, 2022
1 parent 3bb128f commit b86a6f6
Show file tree
Hide file tree
Showing 17 changed files with 347 additions and 221 deletions.
15 changes: 8 additions & 7 deletions build/src/main/resources/agent.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ plugin.observability.global.tracing.enabled=true
plugin.observability.global.metric.enabled=true
plugin.observability.global.metric.interval=30
plugin.observability.global.metric.topic=application-meter
plugin.observability.global.metric.appendType=console
# plugin.observability.global.metric.appendType=console
## output by http
#plugin.observability.global.metric.appendType=http
# add service name to header enabled by name for easemesh
Expand Down Expand Up @@ -208,6 +208,7 @@ plugin.observability.mongodb.metric.url=/platform-metrics
## zipkin: [http|https]://127.0.0.1:8080/zipkin

reporter.outputServer.bootstrapServer=127.0.0.1:9092
reporter.outputServer.appendType=console
reporter.outputServer.timeout=1000

## enabled=false: disable output tracing and metric
Expand Down Expand Up @@ -237,18 +238,18 @@ reporter.log.output.messageTimeout=1000
## [http] send to http server
## [kafka] send to kafka
## [console] send to console
reporter.log.sender.appendType=console
## reporter.log.sender.appendType=console
## enabled=true:
reporter.log.sender.enabled=true
reporter.log.sender.url=/application-log
# reporter.log.sender.enabled=true
# reporter.log.sender.url=/application-log


## sender.appendType config
## [http] send to http server
## [kafka] send to kafka
## [console] send to console
#reporter.tracing.sender.appendType=http
reporter.tracing.sender.appendType=console
# reporter.tracing.sender.appendType=http
# reporter.tracing.sender.appendType=console

## enabled=true:
reporter.tracing.sender.enabled=true
Expand Down Expand Up @@ -283,7 +284,7 @@ reporter.tracing.output.messageTimeout=1000
## [metricKafka] send to kafka
## [console] send to console
#reporter.metric.sender.appendType=http
reporter.metric.sender.appendType=console
#reporter.metric.sender.appendType=console

## url is only used in http
## append to outputServer.bootstrapServer
Expand Down
41 changes: 41 additions & 0 deletions build/src/main/resources/user-minimal-cfg.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## This a minimal configuration required to start the EaseAgent.
## In most cases, this is all the configuration items that the normal user needs to be concerned about.
##
## When the user specifies a user configration file as this one, the items in user config file will override the default
## configuration in agent.properties packaged in easeagent.jar
##
## -Deaseagent.config.path=/path/to/user-cfg-file

name=demo-springweb
system=demo-system

###
### report configuration
###
reporter.outputServer.bootstrapServer=http://127.0.0.1:9411
reporter.outputServer.appendType=console

##
## Global metric configuration
## the appendType is same as outputServer, so comment out
# plugin.observability.global.metric.appendType=console

##
## tracing sender

## [http] send to http server
## [kafka] send to kafka
## [console] send to console
#
reporter.tracing.sender.appendType=
# reporter.tracing.sender.url=http://tempo:9411/api/v2/spans
reporter.tracing.sender.url=http://localhost:9411/api/v2/spans

## access log sender
## [http] send to http server
## [kafka] send to kafka
## [console] send to console
## the appendType is same as outputServer, so comment out
## reporter.log.sender.appendType=console


Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static String buildPluginProperty(String domain, String namespace, String
}

/**
* Convert config item with a fromPrefix to toPrefix for configuration Compatibility
* extract config item with a fromPrefix to and convert the prefix to 'toPrefix' for configuration Compatibility
*
* @param cfg config source map
* @param fromPrefix from
Expand All @@ -153,11 +153,9 @@ public static Map<String, String> extractAndConvertPrefix(Map<String, String> cf
convert.put(key, value);
}
});
keys.forEach(cfg::remove);

// override, new configuration KV override previous KV
convert.putAll(extractByPrefix(cfg, toPrefix));
cfg.putAll(convert);

return convert;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void updateConfigsNotNotify(Map<String, String> changes) {
}

public void updateConfigs(Map<String, String> changes) {
Map<String, String> dump = new HashMap<>(this.source);
Map<String, String> dump = new TreeMap<>(this.source);
List<ChangeItem> items = new LinkedList<>();
changes.forEach((name, value) -> {
String old = dump.get(name);
Expand All @@ -67,7 +67,7 @@ protected boolean hasText(String text) {

@Override
public Map<String, String> getConfigs() {
return new HashMap<>(this.source);
return new TreeMap<>(this.source);
}

public String toPrettyDisplay() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
import java.util.TreeMap;

public class GlobalConfigs extends Configs implements ConfigManagerMXBean {
Configs originalConfig;

public GlobalConfigs(Map<String, String> source) {
super();
this.originalConfig = new Configs(source);
// reporter adapter
Map<String, String> map = new TreeMap<>(source);
ReportConfigAdapter.convertConfig(map);
Expand All @@ -38,13 +40,28 @@ public GlobalConfigs(Map<String, String> source) {
this.notifier = new ConfigNotifier("");
}

public Configs getOriginalConfig() {
return this.originalConfig;
}

@Override
public void updateConfigsNotNotify(Map<String, String> changes) {
// update original config
this.originalConfig.updateConfigsNotNotify(changes);
super.updateConfigsNotNotify(changes);
}

@Override
public void updateConfigs(Map<String, String> changes) {
// update original config
Map<String, String> newGlobalCfg = new TreeMap<>(this.originalConfig.getConfigs());
newGlobalCfg.putAll(changes);
this.originalConfig.updateConfigsNotNotify(changes);

// report adapter
Map<String, String> changesMap = new HashMap<>(changes);
ReportConfigAdapter.convertConfig(changesMap);
ReportConfigAdapter.convertConfig(newGlobalCfg);

super.updateConfigs(changesMap);
super.updateConfigs(newGlobalCfg);
}

@Override
Expand Down
Loading

0 comments on commit b86a6f6

Please sign in to comment.