-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add apdex function to OAL * Add empty line * Setup config watcher * Add identifier type to function parameter * Add config test * Update score algorithm * Replace responseCode with status * Add comments about apdex score algorithm * Add docs * Add e2e test case * Update test case * Fix disptch class generating error * Update value name of apdex metric * Tuning threshold * Fix single tolerated point bug
- Loading branch information
Showing
19 changed files
with
597 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Apdex threshold | ||
|
||
Apdex is a measure of response time based against a set threshold. It measures the ratio of satisfactory response times | ||
to unsatisfactory response times. The response time is measured from an asset request to completed delivery back to | ||
the requestor. | ||
|
||
A user defines a response time threshold T. All responses handled in T or less time satisfy the user. | ||
|
||
For example, if T is 1.2 seconds and a response completes in 0.5 seconds, then the user is satisfied. All responses | ||
greater than 1.2 seconds dissatisfy the user. Responses greater than 4.8 seconds frustrate the user. | ||
|
||
The apdex threshold T can be configured in `service-apdex-threshold.yml` file or via [Dynamic Configuration](dynamic-config.md). | ||
The `default` item will be apply to a service isn't defined in this configuration as the default threshold. | ||
|
||
## Configuration Format | ||
|
||
The configuration content includes the service' names and their threshold: | ||
|
||
```yml | ||
# default threshold is 500ms | ||
default: 500 | ||
# example: | ||
# the threshold of service "tomcat" is 1s | ||
# tomcat: 1000 | ||
# the threshold of service "springboot1" is 50ms | ||
# springboot1: 50 | ||
``` |
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
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
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
36 changes: 36 additions & 0 deletions
36
oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/rt/parser/Argument.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,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.skywalking.oal.rt.parser; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** | ||
* Function argument. | ||
* | ||
* @author hongtaogao | ||
*/ | ||
@Getter | ||
@RequiredArgsConstructor | ||
public class Argument { | ||
|
||
private final int type; | ||
|
||
private final String text; | ||
} |
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
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
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
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
22 changes: 22 additions & 0 deletions
22
oap-server/server-bootstrap/src/main/resources/service-apdex-threshold.yml
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,22 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# default threshold is 500ms | ||
default: 500 | ||
# example: | ||
# the threshold of service "tomcat" is 1s | ||
# tomcat: 1000 | ||
# the threshold of service "springboot1" is 50ms | ||
# springboot1: 50 |
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
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
102 changes: 102 additions & 0 deletions
102
...re/src/main/java/org/apache/skywalking/oap/server/core/analysis/ApdexThresholdConfig.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,102 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.apache.skywalking.oap.server.core.analysis; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.Reader; | ||
import java.io.StringReader; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.skywalking.oap.server.configuration.api.ConfigChangeWatcher; | ||
import org.apache.skywalking.oap.server.core.Const; | ||
import org.apache.skywalking.oap.server.core.CoreModule; | ||
import org.apache.skywalking.oap.server.core.CoreModuleProvider; | ||
import org.apache.skywalking.oap.server.library.util.ResourceUtils; | ||
import org.yaml.snakeyaml.Yaml; | ||
|
||
/** | ||
* Apdex threshold configuration dictionary adapter. | ||
* Looking up a service apdex threshold from dynamic config service. | ||
* | ||
* @author hongtaogao | ||
*/ | ||
@Slf4j | ||
public class ApdexThresholdConfig extends ConfigChangeWatcher implements ConfigurationDictionary { | ||
|
||
private static final String CONFIG_FILE_NAME = "service-apdex-threshold.yml"; | ||
|
||
private static final int SYSTEM_RESERVED_THRESHOLD = 500; | ||
|
||
private Map<String, Integer> dictionary = Collections.emptyMap(); | ||
|
||
private String rawConfig = Const.EMPTY_STRING; | ||
|
||
public ApdexThresholdConfig(final CoreModuleProvider provider) { | ||
super(CoreModule.NAME, provider, "apdexThreshold"); | ||
try { | ||
updateConfig(ResourceUtils.read(CONFIG_FILE_NAME)); | ||
} catch (final FileNotFoundException e) { | ||
log.error("Cannot config from: {}", CONFIG_FILE_NAME, e); | ||
} | ||
} | ||
|
||
@Override public Number lookup(String name) { | ||
int t = dictionary.getOrDefault(name, -1); | ||
if (t < 0) { | ||
t = dictionary.getOrDefault("default", -1); | ||
} | ||
if (t < 0) { | ||
log.warn("Pick up system reserved threshold {}ms because of config missing", SYSTEM_RESERVED_THRESHOLD); | ||
return SYSTEM_RESERVED_THRESHOLD; | ||
} | ||
if (log.isDebugEnabled()) { | ||
log.debug("Apdex threshold of {} is {}ms", name, t); | ||
} | ||
return t; | ||
} | ||
|
||
@Override public void notify(ConfigChangeEvent value) { | ||
if (EventType.DELETE.equals(value.getEventType())) { | ||
activeSetting(""); | ||
} else { | ||
activeSetting(value.getNewValue()); | ||
} | ||
} | ||
|
||
@Override public String value() { | ||
return rawConfig; | ||
} | ||
|
||
private synchronized void activeSetting(String config) { | ||
if (log.isDebugEnabled()) { | ||
log.debug("Updating using new static config: {}", config); | ||
} | ||
rawConfig = config; | ||
updateConfig(new StringReader(config)); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private void updateConfig(final Reader contentRender) { | ||
dictionary = (Map<String, Integer>)new Yaml().load(contentRender); | ||
if (dictionary == null) { | ||
dictionary = Collections.emptyMap(); | ||
} | ||
} | ||
} |
Oops, something went wrong.