diff --git a/docs/en/setup/backend/configuration-vocabulary.md b/docs/en/setup/backend/configuration-vocabulary.md index 09a7c73b3..95b304565 100644 --- a/docs/en/setup/backend/configuration-vocabulary.md +++ b/docs/en/setup/backend/configuration-vocabulary.md @@ -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 | - | - | diff --git a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/AnalyzerModuleConfig.java b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/AnalyzerModuleConfig.java index 7fe30f233..760ec5d1b 100644 --- a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/AnalyzerModuleConfig.java +++ b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/AnalyzerModuleConfig.java @@ -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 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 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); + } } diff --git a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/trace/parser/listener/MultiScopesAnalysisListener.java b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/trace/parser/listener/MultiScopesAnalysisListener.java index 020a94b37..90854c744 100644 --- a/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/trace/parser/listener/MultiScopesAnalysisListener.java +++ b/oap-server/analyzer/agent-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/provider/trace/parser/listener/MultiScopesAnalysisListener.java @@ -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); diff --git a/oap-server/server-bootstrap/src/main/resources/application.yml b/oap-server/server-bootstrap/src/main/resources/application.yml index ddec44c70..cb3163d41 100755 --- a/oap-server/server-bootstrap/src/main/resources/application.yml +++ b/oap-server/server-bootstrap/src/main/resources/application.yml @@ -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} diff --git a/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleAProvider.java b/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleAProvider.java index 39349418c..a8a753d2d 100644 --- a/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleAProvider.java +++ b/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleAProvider.java @@ -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 diff --git a/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleAProviderConfig.java b/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleAProviderConfig.java new file mode 100644 index 000000000..088327a8a --- /dev/null +++ b/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleAProviderConfig.java @@ -0,0 +1,28 @@ +/* + * 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; +} diff --git a/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleManagerTest.java b/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleManagerTest.java index 8071f8b6c..16b53a2a5 100644 --- a/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleManagerTest.java +++ b/oap-server/server-library/library-module/src/test/java/org/apache/skywalking/oap/server/library/module/ModuleManagerTest.java @@ -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();