未验证 提交 803f6f28 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Add SW_NO_UPSTREAM_REAL_ADDRESS config doc (#5650)

* Add SW_NO_UPSTREAM_REAL_ADDRESS config doc

* Fix legal config issue.

* Update docs/en/setup/backend/configuration-vocabulary.md

* Add a test case to verify the module config initializer, which only supports 4 simple types.
Co-authored-by: Nkezhenxu94 <kezhenxu94@apache.org>
上级 bde07d7e
......@@ -138,6 +138,7 @@ core|default|role|Option values, `Mixed/Receiver/Aggregator`. **Receiver** mode
| - | - |slowDBAccessThreshold|The slow database access thresholds. Unit ms.|SW_SLOW_DB_THRESHOLD|default:200,mongodb:100|
| - | - |forceSampleErrorSegment|When sampling mechanism activated, this config would make the error status segment sampled, ignoring the sampling rate.|SW_FORCE_SAMPLE_ERROR_SEGMENT|true|
| - | - |segmentStatusAnalysisStrategy|Determine the final segment status from the status of spans. Available values are `FROM_SPAN_STATUS` , `FROM_ENTRY_SPAN` and `FROM_FIRST_SPAN`. `FROM_SPAN_STATUS` represents the segment status would be error if any span is in error status. `FROM_ENTRY_SPAN` means the segment status would be determined by the status of entry spans only. `FROM_FIRST_SPAN` means the segment status would be determined by the status of the first span only.|SW_SEGMENT_STATUS_ANALYSIS_STRATEGY|FROM_SPAN_STATUS|
| - | - |noUpstreamRealAddressAgents|Exit spans with the component in the list would not generate the client-side instance relation metrics. As some tracing plugins can't collect the real peer ip address, such as Nginx-LUA and Envoy. |SW_NO_UPSTREAM_REAL_ADDRESS|6000,9000|
| receiver-sharing-server|default| Sharing server provides new gRPC and restful servers for data collection. Ana make the servers in the core module working for internal communication only.| - | - |
| - | - | restHost| Binding IP of restful service. Services include GraphQL query and HTTP data report| - | - |
| - | - | restPort | Binding port of restful service | - | - |
......
......@@ -18,18 +18,21 @@
package org.apache.skywalking.oap.server.analyzer.provider;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.oap.server.analyzer.provider.trace.DBLatencyThresholdsAndWatcher;
import org.apache.skywalking.oap.server.analyzer.provider.trace.TraceSampleRateWatcher;
import org.apache.skywalking.oap.server.analyzer.provider.trace.UninstrumentedGatewaysConfig;
import org.apache.skywalking.oap.server.analyzer.provider.trace.parser.listener.strategy.SegmentStatusStrategy;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
import static org.apache.skywalking.oap.server.analyzer.provider.trace.parser.listener.strategy.SegmentStatusStrategy.FROM_SPAN_STATUS;
@Slf4j
public class AnalyzerModuleConfig extends ModuleConfig {
/**
* The sample rate precision is 1/10000. 10000 means 100% sample in default.
......@@ -44,7 +47,7 @@ public class AnalyzerModuleConfig extends ModuleConfig {
* Read component-libraries.yml for more details.
*/
@Getter
private final List<Integer> noUpstreamRealAddressAgents = Collections.singletonList(6000);
private String noUpstreamRealAddressAgents = Const.EMPTY_STRING;
/**
* The threshold used to check the slow database access. Unit, millisecond.
*/
......@@ -98,4 +101,26 @@ public class AnalyzerModuleConfig extends ModuleConfig {
@Setter
@Getter
private String segmentStatusAnalysisStrategy = FROM_SPAN_STATUS.name();
private List<Integer> virtualPeers;
/**
* @param componentId of the exit span
* @return true, means should not generate the instance relationship for the client-side exit span.
*/
public boolean shouldIgnorePeerIPDue2Virtual(int componentId) {
if (virtualPeers == null) {
virtualPeers = new ArrayList<>(20);
for (final String component : noUpstreamRealAddressAgents.split(",")) {
try {
virtualPeers.add(Integer.parseInt(component));
} catch (NumberFormatException e) {
log.warn("noUpstreamRealAddressAgents config {} includes illegal value {}",
noUpstreamRealAddressAgents, component
);
}
}
}
return virtualPeers.contains(componentId);
}
}
......@@ -31,7 +31,9 @@ import org.apache.skywalking.apm.network.language.agent.v3.SpanLayer;
import org.apache.skywalking.apm.network.language.agent.v3.SpanObject;
import org.apache.skywalking.apm.network.language.agent.v3.SpanType;
import org.apache.skywalking.apm.util.StringUtil;
import org.apache.skywalking.oap.server.analyzer.provider.AnalyzerModuleConfig;
import org.apache.skywalking.oap.server.analyzer.provider.trace.DBLatencyThresholdsAndWatcher;
import org.apache.skywalking.oap.server.analyzer.provider.trace.parser.SpanTags;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
......@@ -47,8 +49,6 @@ import org.apache.skywalking.oap.server.core.source.RequestType;
import org.apache.skywalking.oap.server.core.source.ServiceInstanceRelation;
import org.apache.skywalking.oap.server.core.source.SourceReceiver;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.analyzer.provider.AnalyzerModuleConfig;
import org.apache.skywalking.oap.server.analyzer.provider.trace.parser.SpanTags;
import static org.apache.skywalking.oap.server.analyzer.provider.trace.parser.SpanTags.LOGIC_ENDPOINT;
......@@ -184,7 +184,7 @@ public class MultiScopesAnalysisListener implements EntryAnalysisListener, ExitA
* Some of the agent can not have the upstream real network address, such as https://github.com/apache/skywalking-nginx-lua.
* Keeping dest instance name as NULL makes no instance relation generate from this exit span.
*/
if (!config.getNoUpstreamRealAddressAgents().contains(span.getComponentId())) {
if (!config.shouldIgnorePeerIPDue2Virtual(span.getComponentId())) {
sourceBuilder.setDestServiceInstanceName(instanceIDDefinition.getName());
}
sourceBuilder.setDestNodeType(NodeType.Normal);
......
......@@ -181,6 +181,9 @@ agent-analyzer:
slowDBAccessThreshold: ${SW_SLOW_DB_THRESHOLD:default:200,mongodb:100} # The slow database access thresholds. Unit ms.
forceSampleErrorSegment: ${SW_FORCE_SAMPLE_ERROR_SEGMENT:true} # When sampling mechanism active, this config can open(true) force save some error segment. true is default.
segmentStatusAnalysisStrategy: ${SW_SEGMENT_STATUS_ANALYSIS_STRATEGY:FROM_SPAN_STATUS} # Determine the final segment status from the status of spans. Available values are `FROM_SPAN_STATUS` , `FROM_ENTRY_SPAN` and `FROM_FIRST_SPAN`. `FROM_SPAN_STATUS` represents the segment status would be error if any span is in error status. `FROM_ENTRY_SPAN` means the segment status would be determined by the status of entry spans only. `FROM_FIRST_SPAN` means the segment status would be determined by the status of the first span only.
# Nginx and Envoy agents can't get the real remote address.
# Exit spans with the component in the list would not generate the client-side instance relation metrics.
noUpstreamRealAddressAgents: ${SW_NO_UPSTREAM_REAL_ADDRESS:6000,9000}
receiver-sharing-server:
selector: ${SW_RECEIVER_SHARING_SERVER:default}
......
......@@ -19,6 +19,8 @@
package org.apache.skywalking.oap.server.library.module;
public class ModuleAProvider extends ModuleProvider {
private ModuleAProviderConfig config = new ModuleAProviderConfig();
@Override
public String name() {
return "P-A";
......@@ -26,7 +28,7 @@ public class ModuleAProvider extends ModuleProvider {
@Override
public ModuleConfig createConfigBeanIfAbsent() {
return null;
return config;
}
@Override
......
/*
* 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.library.module;
import lombok.Getter;
public class ModuleAProviderConfig extends ModuleConfig {
@Getter private String attr1;
@Getter private Integer attr2;
@Getter private Long attr3;
@Getter private boolean attr4;
}
......@@ -39,6 +39,29 @@ public class ModuleManagerTest {
Assert.assertTrue(serviceABusiness1 != null);
}
@Test
public void testModuleConfigInit() throws ModuleConfigException, ModuleNotFoundException, ModuleStartException {
ApplicationConfiguration configuration = new ApplicationConfiguration();
final Properties settings = new Properties();
settings.put("attr1", "abc");
settings.put("attr2", 123);
settings.put("attr3", 123L);
settings.put("attr4", true);
configuration.addModule("BaseA").addProviderConfiguration("P-A", settings);
ModuleManager manager = new ModuleManager();
manager.init(configuration);
final ModuleServiceHolder provider = manager.find("BaseA").provider();
Assert.assertTrue(provider instanceof ModuleAProvider);
final ModuleAProvider moduleAProvider = (ModuleAProvider) provider;
final ModuleAProviderConfig config = (ModuleAProviderConfig) moduleAProvider.createConfigBeanIfAbsent();
Assert.assertEquals("abc", config.getAttr1());
Assert.assertEquals(123, config.getAttr2().intValue());
Assert.assertEquals(123L, config.getAttr3().longValue());
Assert.assertEquals(true, config.isAttr4());
}
@Test(expected = ModuleNotFoundException.class)
public void testModuleMissing() throws ModuleConfigException, ModuleNotFoundException, ModuleStartException {
ApplicationConfiguration configuration = new ApplicationConfiguration();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册