From 4474907fef809e2342b644a324da011834a55420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=9F=20Wu=20Sheng?= Date: Sat, 28 Mar 2020 22:51:41 +0800 Subject: [PATCH] [Inventory Design Change] Remove endpoint register and endpoint inventory (#4570) * Finish step one, source and entity changed. * Step 2, finish the basic and core DAO changes. * Step 3. Change all source codes of backend, and make project compiling successfully. * Make startup successful and persistence works. * Fix dead codes in the MySQLTableInstaller. * Fix mischange. * Fix MySQL storage bootstrap error. * Rollback dependency change. * Simply enable tailing logs from container no mater it's in CI or not * Fix segment table issue. * Fix MySQL Instanller. * Support Influxdb implementation of new endpoint traffic. * Set and modify timeout to 90mins * Remove unnecessary entity in the EndpointTraffic. * Fix wrong entity builder and make name more clear. * Fix 2 equal methods bug. * Fix InfluxDB identifier(name) conflict issue. * Fix endpoint topology query, endpoint id should be changed as a string. * Fix a missing change. * Fix a wrong commit. * Column name can't be changed, due to it affect the hybrid metadb(h2/mysql) query, change it explicitly with double quotation marks. * Fix formats. * Remove endpoint/operation register from the agent. and change the plugin tests(without local tests). operationId relation codes have been removed from agent too. * Try to fix the hytrix case. * Fix 3 cases. * Try to fix cases. * Fix 2. * Fix one. * Fix the serviceId type mis-change. * Fix int query * Fix hystrix case. * Fix a case. * Fix EndpointCallRelationDispatcher set the source/dest endpoint without id encoding. * Update documentation and add 2 test cases. Co-authored-by: kezhenxu94 --- .github/workflows/ci-it.yaml | 6 +- .github/workflows/docker-ci.yaml | 1 + .github/workflows/e2e.cluster.yaml | 2 + .github/workflows/e2e.jdk-versions.yaml | 2 + .github/workflows/e2e.php.yaml | 1 + .github/workflows/e2e.profiling.yaml | 1 + .github/workflows/e2e.storages.yaml | 2 + .github/workflows/e2e.ttl.yaml | 1 + .github/workflows/e2e.yaml | 3 + .../executor/ServiceResetCommandExecutor.java | 6 +- .../apm/agent/core/conf/Constants.java | 2 + .../agent/core/context/ContextCarrier.java | 8 - .../agent/core/context/TracingContext.java | 114 ++----------- .../core/context/trace/AbstractSpan.java | 4 - .../context/trace/AbstractTracingSpan.java | 39 +---- .../agent/core/context/trace/EntrySpan.java | 14 -- .../agent/core/context/trace/ExitSpan.java | 8 - .../agent/core/context/trace/LocalSpan.java | 12 -- .../agent/core/context/trace/NoopSpan.java | 10 -- .../context/trace/StackBasedTracingSpan.java | 30 ---- .../core/context/trace/TraceSegmentRef.java | 43 +---- .../core/dictionary/DictionaryManager.java | 7 - .../agent/core/dictionary/DictionaryUtil.java | 7 - .../dictionary/EndpointNameDictionary.java | 123 -------------- ...Client.java => ServiceRegisterClient.java} | 19 +-- ...skywalking.apm.agent.core.boot.BootService | 2 +- .../context/ContextCarrierV2HeaderTest.java | 8 +- .../core/context/ContextManagerTest.java | 1 - docs/en/guides/Plugin-test.md | 3 +- docs/en/protocols/README.md | 13 +- ...Process-Propagation-Headers-Protocol-v2.md | 26 +-- docs/en/setup/backend/backend-alarm.md | 12 +- .../exporter/provider/MetricFormatter.java | 6 +- .../provider/grpc/GRPCExporterProvider.java | 2 - .../grpc/GRPCExporterProviderTest.java | 2 - .../core/alarm/provider/NotifyHandler.java | 27 ++- .../src/main/proto/alarm-hook.proto | 4 +- .../provider/AlarmMessageFormatterTest.java | 16 +- .../alarm/provider/NotifyHandlerTest.java | 24 ++- .../core/alarm/provider/RunningRuleTest.java | 16 +- .../provider/grpc/GRPChookCallbackTest.java | 4 +- .../skywalking/oap/server/core/Const.java | 3 +- .../oap/server/core/CoreModule.java | 4 - .../oap/server/core/CoreModuleProvider.java | 15 +- .../oap/server/core/alarm/AlarmMessage.java | 4 +- .../oap/server/core/alarm/AlarmRecord.java | 8 +- .../core/alarm/EndpointMetaInAlarm.java | 9 +- .../oap/server/core/alarm/MetaInAlarm.java | 6 +- .../alarm/ServiceInstanceMetaInAlarm.java | 9 +- .../server/core/alarm/ServiceMetaInAlarm.java | 9 +- .../oap/server/core/analysis/Stream.java | 5 + .../analysis/manual/RelationDefineUtil.java | 66 ++++++-- .../manual/endpoint/EndpointTraffic.java} | 137 +++++++++++---- .../endpoint/EndpointTrafficDispatcher.java} | 24 ++- .../EndpointCallRelationDispatcher.java | 10 +- .../EndpointRelationServerSideMetrics.java | 68 ++++---- .../manual/log/AbstractLogRecord.java | 11 +- .../manual/log/HTTPAccessLogDispatcher.java | 1 + .../ServiceRelationClientSideMetrics.java | 6 +- .../ServiceRelationServerSideMetrics.java | 9 +- .../manual/segment/SegmentRecord.java | 4 +- .../worker/MetricsStreamProcessor.java | 37 ++-- .../core/cache/EndpointInventoryCache.java | 108 ------------ .../core/query/AggregationQueryService.java | 77 +++++---- .../server/core/query/LogQueryService.java | 32 ++-- .../core/query/MetadataQueryService.java | 34 ++-- .../core/query/ProfileTaskQueryService.java | 38 +---- .../query/ServiceInstanceTopologyBuilder.java | 19 +-- .../server/core/query/TopologyBuilder.java | 25 +-- .../core/query/TopologyQueryService.java | 25 +-- .../server/core/query/TraceQueryService.java | 55 +++--- .../oap/server/core/query/entity/Call.java | 12 +- .../server/core/query/entity/Endpoint.java | 2 +- .../core/query/entity/EndpointInfo.java | 2 +- .../oap/server/core/query/entity/Log.java | 2 +- .../oap/server/core/query/entity/Node.java | 2 +- .../service/EndpointInventoryRegister.java | 87 ---------- .../oap/server/core/source/AbstractLog.java | 3 +- .../core/source/DefaultScopeDefine.java | 2 +- .../oap/server/core/source/DetectPoint.java | 25 ++- .../oap/server/core/source/Endpoint.java | 9 +- .../server/core/source/EndpointRelation.java | 19 +-- .../oap/server/core/source/Segment.java | 2 +- .../server/core/storage/StorageModule.java | 2 - .../cache/IEndpointInventoryCacheDAO.java | 29 ---- .../core/storage/query/ILogQueryDAO.java | 2 +- .../core/storage/query/IMetadataQueryDAO.java | 2 +- .../core/storage/query/ITopologyQueryDAO.java | 2 +- .../core/storage/query/ITraceQueryDAO.java | 2 +- .../manual/RelationDefineUtilTest.java | 45 +++++ .../manual/endpoint/EndpointTrafficTest.java | 79 +++++++++ .../query/graphql/resolver/MetadataQuery.java | 10 +- .../query/graphql/resolver/TopologyQuery.java | 2 +- .../query/graphql/resolver/TraceQuery.java | 2 +- .../query/graphql/type/LogQueryCondition.java | 2 +- .../src/main/resources/query-protocol | 2 +- .../receiver/jaeger/JaegerGRPCHandler.java | 12 +- .../mesh/ServiceMeshMetricDataDecorator.java | 35 ++-- .../mesh/TelemetryDataDispatcher.java | 51 +++--- .../v6/grpc/RegisterServiceHandler.java | 35 +--- .../sharing/server/CoreRegisterLinker.java | 22 --- .../parser/decorator/ReferenceDecorator.java | 44 ----- .../parser/decorator/SpanDecorator.java | 15 -- .../endpoint/MultiScopesSpanListener.java | 34 ++-- .../listener/endpoint/SourceBuilder.java | 9 - .../listener/segment/SegmentSpanListener.java | 43 ++--- .../standardization/ReferenceIdExchanger.java | 76 +-------- .../parser/standardization/SpanExchanger.java | 33 ---- .../zipkin/handler/SpanProcessor.java | 8 +- .../zipkin/handler/SpanV1JettyHandler.java | 5 +- .../zipkin/handler/SpanV2JettyHandler.java | 5 +- .../receiver/zipkin/trace/SpanForward.java | 14 +- .../StorageModuleElasticsearchProvider.java | 4 - .../cache/EndpointInventoryCacheEsDAO.java | 80 --------- .../query/AggregationQueryEsDAO.java | 4 +- .../elasticsearch/query/LogQueryEsDAO.java | 22 ++- .../query/MetadataQueryEsDAO.java | 44 +++-- .../query/TopologyQueryEsDAO.java | 124 ++++++++++---- .../elasticsearch/query/TraceQueryEsDAO.java | 21 ++- .../StorageModuleElasticsearch7Provider.java | 4 - .../cache/EndpointInventoryCacheEs7DAO.java | 58 ------- .../elasticsearch7/query/LogQueryEs7DAO.java | 27 +-- .../query/MetadataQueryEs7DAO.java | 9 +- .../query/TraceQueryEs7DAO.java | 4 +- .../plugin/influxdb/InfluxModelConstants.java | 2 +- .../influxdb/InfluxStorageProvider.java | 15 +- .../plugin/influxdb/base/MetricsDAO.java | 19 ++- ...er.java => InfluxDBH2MetaDBInstaller.java} | 4 +- ...java => InfluxDBMySQLMetaDBInstaller.java} | 4 +- .../influxdb/query/AggregationQuery.java | 4 +- .../query/InfluxMetadataQueryDAO.java | 112 ++++++++++++ .../plugin/influxdb/query/LogQuery.java | 13 +- .../plugin/influxdb/query/TopologyQuery.java | 53 ++++-- .../plugin/influxdb/query/TraceQuery.java | 8 +- .../storage/plugin/jaeger/JaegerSpan.java | 2 +- .../plugin/jaeger/JaegerSpanRecord.java | 4 +- .../elasticsearch/JaegerTraceQueryEsDAO.java | 18 +- .../storage-jdbc-hikaricp-plugin/pom.xml | 10 +- .../plugin/jdbc/h2/H2StorageProvider.java | 18 +- .../jdbc/h2/dao/H2AggregationQueryDAO.java | 4 +- .../h2/dao/H2EndpointInventoryCacheDAO.java | 51 ------ .../plugin/jdbc/h2/dao/H2LogQueryDAO.java | 29 ++-- .../jdbc/h2/dao/H2MetadataQueryDAO.java | 72 +++++--- .../jdbc/h2/dao/H2TopologyQueryDAO.java | 159 ++++++++++++++---- .../plugin/jdbc/h2/dao/H2TraceQueryDAO.java | 4 +- .../jdbc/mysql/MySQLStorageProvider.java | 21 ++- .../jdbc/mysql/MySQLTableInstaller.java | 73 ++++---- .../storage/plugin/zipkin/ZipkinSpan.java | 2 +- .../plugin/zipkin/ZipkinSpanRecord.java | 4 +- .../elasticsearch/ZipkinTraceQueryEsDAO.java | 18 +- .../exporter/test/ProfileTraceDAO.java | 2 +- .../profile/core/MockCoreModuleProvider.java | 34 ++-- .../skywalking/e2e/SkyWalkingAnnotations.java | 2 +- .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 9 +- .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../avro-scenario/config/expectedData.yaml | 3 - .../canal-scenario/config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 3 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../feign-scenario/config/expectedData.yaml | 3 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../gateway-scenario/config/expectedData.yaml | 5 +- .../grpc-scenario/config/expectedData.yaml | 2 - .../gson-scenario/config/expectedData.yaml | 2 - .../h2-scenario/config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 3 - .../config/expectedData.yaml | 4 - .../hystrix-scenario/config/expectedData.yaml | 4 +- .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../jedis-scenario/config/expectedData.yaml | 2 - .../jetty-scenario/config/expectedData.yaml | 4 - .../kafka-scenario/config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../lettuce-scenario/config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../mysql-scenario/config/expectedData.yaml | 2 - .../config/expectedData.yaml | 3 - .../okhttp-scenario/config/expectedData.yaml | 6 +- .../oracle-scenario/config/expectedData.yaml | 2 - .../play-scenario/config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../pulsar-scenario/config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 3 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../sofarpc-scenario/config/expectedData.yaml | 3 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 4 - .../config/expectedData.yaml | 3 - .../config/expectedData.yaml | 4 - .../config/expectedData.yaml | 6 +- .../config/expectedData.yaml | 3 - .../config/expectedData.yaml | 3 - .../config/expectedData.yaml | 4 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 2 - .../config/expectedData.yaml | 7 +- .../webflux-scenario/config/expectedData.yaml | 3 - .../config/expectedData.yaml | 3 - 219 files changed, 1496 insertions(+), 2123 deletions(-) delete mode 100755 apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/EndpointNameDictionary.java rename apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/{ServiceAndEndpointRegisterClient.java => ServiceRegisterClient.java} (92%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/{register/EndpointInventory.java => analysis/manual/endpoint/EndpointTraffic.java} (51%) rename oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/{register/service/IEndpointInventoryRegister.java => analysis/manual/endpoint/EndpointTrafficDispatcher.java} (50%) delete mode 100644 oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cache/EndpointInventoryCache.java delete mode 100644 oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/EndpointInventoryRegister.java delete mode 100644 oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/cache/IEndpointInventoryCacheDAO.java create mode 100644 oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/manual/RelationDefineUtilTest.java create mode 100644 oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTrafficTest.java delete mode 100644 oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java delete mode 100644 oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/EndpointInventoryCacheEs7DAO.java rename oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/{H2Installer.java => InfluxDBH2MetaDBInstaller.java} (92%) rename oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/{MySQLInstaller.java => InfluxDBMySQLMetaDBInstaller.java} (92%) create mode 100644 oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/InfluxMetadataQueryDAO.java delete mode 100644 oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2EndpointInventoryCacheDAO.java diff --git a/.github/workflows/ci-it.yaml b/.github/workflows/ci-it.yaml index f489fee05d..667fd83b9b 100644 --- a/.github/workflows/ci-it.yaml +++ b/.github/workflows/ci-it.yaml @@ -28,7 +28,7 @@ on: jobs: CI: runs-on: ubuntu-18.04 - timeout-minutes: 180 + timeout-minutes: 90 strategy: fail-fast: true steps: @@ -52,7 +52,7 @@ jobs: CI-on-Windows: runs-on: Windows-latest - timeout-minutes: 180 + timeout-minutes: 90 strategy: fail-fast: true steps: @@ -74,7 +74,7 @@ jobs: CI-on-MacOS: runs-on: macos-latest - timeout-minutes: 180 + timeout-minutes: 90 strategy: fail-fast: true steps: diff --git a/.github/workflows/docker-ci.yaml b/.github/workflows/docker-ci.yaml index 99b3c1a606..c1202c7d68 100644 --- a/.github/workflows/docker-ci.yaml +++ b/.github/workflows/docker-ci.yaml @@ -24,6 +24,7 @@ env: jobs: build: runs-on: ubuntu-16.04 + timeout-minutes: 90 strategy: matrix: es: [es6, es7] diff --git a/.github/workflows/e2e.cluster.yaml b/.github/workflows/e2e.cluster.yaml index 8337feb834..1fbd3b3739 100644 --- a/.github/workflows/e2e.cluster.yaml +++ b/.github/workflows/e2e.cluster.yaml @@ -30,6 +30,7 @@ env: jobs: CoordinatorsStorage: name: Coordinators & Storage + timeout-minutes: 90 runs-on: ubuntu-latest strategy: matrix: @@ -59,6 +60,7 @@ jobs: Cluster: runs-on: ubuntu-latest + timeout-minutes: 90 needs: [CoordinatorsStorage] steps: - name: Call me by your name diff --git a/.github/workflows/e2e.jdk-versions.yaml b/.github/workflows/e2e.jdk-versions.yaml index ef5d6181ee..c96e0a4d85 100644 --- a/.github/workflows/e2e.jdk-versions.yaml +++ b/.github/workflows/e2e.jdk-versions.yaml @@ -31,6 +31,7 @@ jobs: JavaVersions: name: Agent Java Versions runs-on: ubuntu-latest + timeout-minutes: 90 strategy: matrix: jdk: [8, 9, 10, 11, 12, 13, 14] @@ -58,6 +59,7 @@ jobs: Single: runs-on: ubuntu-latest + timeout-minutes: 90 needs: [JavaVersions] steps: - name: Singles Bar diff --git a/.github/workflows/e2e.php.yaml b/.github/workflows/e2e.php.yaml index 383cad82cd..387c9a4456 100644 --- a/.github/workflows/e2e.php.yaml +++ b/.github/workflows/e2e.php.yaml @@ -32,6 +32,7 @@ jobs: PHPAgent: name: PHP runs-on: ubuntu-latest + timeout-minutes: 90 steps: - uses: actions/checkout@v2 - name: checkout submodules diff --git a/.github/workflows/e2e.profiling.yaml b/.github/workflows/e2e.profiling.yaml index d039bbb53d..235495a14b 100644 --- a/.github/workflows/e2e.profiling.yaml +++ b/.github/workflows/e2e.profiling.yaml @@ -31,6 +31,7 @@ jobs: Profiling: name: Profiling runs-on: ubuntu-latest + timeout-minutes: 90 strategy: matrix: storage: ['h2', 'mysql', 'es6', 'es7', 'influxdb'] diff --git a/.github/workflows/e2e.storages.yaml b/.github/workflows/e2e.storages.yaml index 0113e3642c..b1d4ac0b18 100644 --- a/.github/workflows/e2e.storages.yaml +++ b/.github/workflows/e2e.storages.yaml @@ -31,6 +31,7 @@ jobs: StoragePlugins: name: Storage runs-on: ubuntu-latest + timeout-minutes: 90 strategy: matrix: storage: ['mysql', 'es6', 'es7', 'influxdb'] @@ -57,6 +58,7 @@ jobs: Storage: runs-on: ubuntu-latest + timeout-minutes: 90 needs: [StoragePlugins] steps: - name: To pass or not pass diff --git a/.github/workflows/e2e.ttl.yaml b/.github/workflows/e2e.ttl.yaml index 58381ad2c9..cec82a10b1 100644 --- a/.github/workflows/e2e.ttl.yaml +++ b/.github/workflows/e2e.ttl.yaml @@ -31,6 +31,7 @@ jobs: TTL: name: Storage TTL runs-on: ubuntu-latest + timeout-minutes: 90 strategy: matrix: storage: ['es6', 'es7', 'influxdb'] diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 554f9b97b5..2f101fe3a1 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -32,6 +32,7 @@ jobs: FeatureGroup01: name: Feature runs-on: ubuntu-latest + timeout-minutes: 90 strategy: matrix: case: [auth, compatibility, ssl] @@ -59,6 +60,7 @@ jobs: FeatureGroup02: name: Agent Reboot & Lua Nginx runs-on: ubuntu-latest + timeout-minutes: 90 steps: - uses: actions/checkout@v2 - name: checkout submodules @@ -83,6 +85,7 @@ jobs: FeatureGroup03: name: Gateway runs-on: ubuntu-latest + timeout-minutes: 90 steps: - uses: actions/checkout@v2 - name: checkout submodules diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/commands/executor/ServiceResetCommandExecutor.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/commands/executor/ServiceResetCommandExecutor.java index 4443ffbb2c..57f639f7b8 100755 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/commands/executor/ServiceResetCommandExecutor.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/commands/executor/ServiceResetCommandExecutor.java @@ -22,11 +22,10 @@ import org.apache.skywalking.apm.agent.core.commands.CommandExecutionException; import org.apache.skywalking.apm.agent.core.commands.CommandExecutor; import org.apache.skywalking.apm.agent.core.conf.RemoteDownstreamConfig; import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil; -import org.apache.skywalking.apm.agent.core.dictionary.EndpointNameDictionary; import org.apache.skywalking.apm.agent.core.dictionary.NetworkAddressDictionary; import org.apache.skywalking.apm.agent.core.logging.api.ILog; import org.apache.skywalking.apm.agent.core.logging.api.LogManager; -import org.apache.skywalking.apm.agent.core.remote.ServiceAndEndpointRegisterClient; +import org.apache.skywalking.apm.agent.core.remote.ServiceRegisterClient; import org.apache.skywalking.apm.network.trace.component.command.BaseCommand; import org.apache.skywalking.apm.network.trace.component.command.ServiceResetCommand; @@ -40,13 +39,12 @@ public class ServiceResetCommandExecutor implements CommandExecutor { public void execute(final BaseCommand command) throws CommandExecutionException { LOGGER.warn("Received ServiceResetCommand, a re-register task is scheduled."); - ServiceManager.INSTANCE.findService(ServiceAndEndpointRegisterClient.class).coolDown(); + ServiceManager.INSTANCE.findService(ServiceRegisterClient.class).coolDown(); RemoteDownstreamConfig.Agent.SERVICE_ID = DictionaryUtil.nullValue(); RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID = DictionaryUtil.nullValue(); RemoteDownstreamConfig.Agent.INSTANCE_REGISTERED_TIME = DictionaryUtil.nullValue(); NetworkAddressDictionary.INSTANCE.clear(); - EndpointNameDictionary.INSTANCE.clear(); } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Constants.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Constants.java index 98baf0d6ef..4e3bcf4c9e 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Constants.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Constants.java @@ -22,4 +22,6 @@ public class Constants { public static String PATH_SEPARATOR = System.getProperty("file.separator", "/"); public static String LINE_SEPARATOR = System.getProperty("line.separator", "\n"); + + public static String EMPTY_STRING = ""; } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextCarrier.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextCarrier.java index d6281af3de..293265af61 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextCarrier.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ContextCarrier.java @@ -165,18 +165,10 @@ public class ContextCarrier implements Serializable { this.entryEndpointName = '#' + entryEndpointName; } - void setEntryEndpointId(int entryOperationId) { - this.entryEndpointName = entryOperationId + ""; - } - void setParentEndpointName(String parentEndpointName) { this.parentEndpointName = '#' + parentEndpointName; } - void setParentEndpointId(int parentOperationId) { - this.parentEndpointName = parentOperationId + ""; - } - public ID getTraceSegmentId() { return traceSegmentId; } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java index 509d98fcc0..0c36f2a380 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/TracingContext.java @@ -131,7 +131,8 @@ public class TracingContext implements AbstractTracerContext { if (PROFILE_TASK_EXECUTION_SERVICE == null) { PROFILE_TASK_EXECUTION_SERVICE = ServiceManager.INSTANCE.findService(ProfileTaskExecutionService.class); } - this.profileStatus = PROFILE_TASK_EXECUTION_SERVICE.addProfiling(this, segment.getTraceSegmentId(), firstOPName); + this.profileStatus = PROFILE_TASK_EXECUTION_SERVICE.addProfiling( + this, segment.getTraceSegmentId(), firstOPName); this.correlationContext = new CorrelationContext(); } @@ -184,56 +185,21 @@ public class TracingContext implements AbstractTracerContext { String firstSpanOperationName = firstSpan.getOperationName(); List refs = this.segment.getRefs(); - int operationId = DictionaryUtil.inexistence(); String operationName = ""; int entryApplicationInstanceId; if (refs != null && refs.size() > 0) { TraceSegmentRef ref = refs.get(0); - operationId = ref.getEntryEndpointId(); operationName = ref.getEntryEndpointName(); entryApplicationInstanceId = ref.getEntryServiceInstanceId(); } else { - if (firstSpan.isEntry()) { - /* - * Since 6.6.0, if first span is not entry span, then this is an internal segment(no RPC), - * rather than an endpoint. - */ - operationId = firstSpan.getOperationId(); - operationName = firstSpanOperationName; - } + operationName = firstSpanOperationName; entryApplicationInstanceId = this.segment.getApplicationInstanceId(); - - } - carrier.setEntryServiceInstanceId(entryApplicationInstanceId); - - if (operationId == DictionaryUtil.nullValue()) { - if (!StringUtil.isEmpty(operationName)) { - carrier.setEntryEndpointName(operationName); - } else { - /* - * Since 6.6.0, if first span is not entry span, then this is an internal segment(no RPC), - * rather than an endpoint. - */ - } - } else { - carrier.setEntryEndpointId(operationId); } - int parentOperationId = firstSpan.getOperationId(); - if (parentOperationId == DictionaryUtil.nullValue()) { - if (firstSpan.isEntry() && !StringUtil.isEmpty(firstSpanOperationName)) { - carrier.setParentEndpointName(firstSpanOperationName); - } else { - /* - * Since 6.6.0, if first span is not entry span, then this is an internal segment(no RPC), - * rather than an endpoint. - */ - carrier.setParentEndpointId(DictionaryUtil.inexistence()); - } - } else { - carrier.setParentEndpointId(parentOperationId); - } + carrier.setEntryServiceInstanceId(entryApplicationInstanceId); + carrier.setEntryEndpointName(operationName); + carrier.setParentEndpointName(firstSpanOperationName); carrier.setDistributedTraceIds(this.segment.getRelatedGlobalTraces()); @@ -267,7 +233,9 @@ public class TracingContext implements AbstractTracerContext { public ContextSnapshot capture() { List refs = this.segment.getRefs(); ContextSnapshot snapshot = new ContextSnapshot( - segment.getTraceSegmentId(), activeSpan().getSpanId(), segment.getRelatedGlobalTraces(), this.correlationContext); + segment.getTraceSegmentId(), activeSpan().getSpanId(), segment.getRelatedGlobalTraces(), + this.correlationContext + ); int entryOperationId; String entryOperationName = ""; int entryApplicationInstanceId; @@ -276,51 +244,16 @@ public class TracingContext implements AbstractTracerContext { if (refs != null && refs.size() > 0) { TraceSegmentRef ref = refs.get(0); - entryOperationId = ref.getEntryEndpointId(); entryOperationName = ref.getEntryEndpointName(); entryApplicationInstanceId = ref.getEntryServiceInstanceId(); } else { - if (firstSpan.isEntry()) { - entryOperationId = firstSpan.getOperationId(); - entryOperationName = firstSpanOperationName; - } else { - /* - * Since 6.6.0, if first span is not entry span, then this is an internal segment(no RPC), - * rather than an endpoint. - */ - entryOperationId = DictionaryUtil.inexistence(); - } + entryOperationName = firstSpanOperationName; entryApplicationInstanceId = this.segment.getApplicationInstanceId(); } snapshot.setEntryApplicationInstanceId(entryApplicationInstanceId); + snapshot.setEntryOperationName(entryOperationName); + snapshot.setParentOperationName(firstSpanOperationName); - if (entryOperationId == DictionaryUtil.nullValue()) { - if (!StringUtil.isEmpty(entryOperationName)) { - snapshot.setEntryOperationName(entryOperationName); - } else { - /* - * Since 6.6.0, if first span is not entry span, then this is an internal segment(no RPC), - * rather than an endpoint. - */ - } - } else { - snapshot.setEntryOperationId(entryOperationId); - } - - int parentOperationId = firstSpan.getOperationId(); - if (parentOperationId == DictionaryUtil.nullValue()) { - if (firstSpan.isEntry() && !StringUtil.isEmpty(firstSpanOperationName)) { - snapshot.setParentOperationName(firstSpanOperationName); - } else { - /* - * Since 6.6.0, if first span is not entry span, then this is an internal segment(no RPC), - * rather than an endpoint. - */ - snapshot.setParentOperationId(DictionaryUtil.inexistence()); - } - } else { - snapshot.setParentOperationId(parentOperationId); - } return snapshot; } @@ -368,25 +301,14 @@ public class TracingContext implements AbstractTracerContext { * as the operation name could be overrided. */ profilingRecheck(parentSpan, operationName); - entrySpan = (AbstractTracingSpan) DictionaryManager.findEndpointSection() - .findOnly(segment.getServiceId(), operationName) - .doInCondition( - parentSpan::setOperationId, () -> parentSpan - .setOperationName(operationName)); + parentSpan.setOperationName(operationName); + entrySpan = parentSpan; return entrySpan.start(); } else { - entrySpan = (AbstractTracingSpan) DictionaryManager.findEndpointSection() - .findOnly(segment.getServiceId(), operationName) - .doInCondition( - operationId -> new EntrySpan(spanIdGenerator++, - parentSpanId, - operationId, owner - ), () -> { - return new EntrySpan( - spanIdGenerator++, parentSpanId, - operationName, owner - ); - }); + entrySpan = new EntrySpan( + spanIdGenerator++, parentSpanId, + operationName, owner + ); entrySpan.start(); return push(entrySpan); } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractSpan.java index 75946d3aa2..01bb44257d 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractSpan.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractSpan.java @@ -110,12 +110,8 @@ public interface AbstractSpan extends AsyncSpan { */ int getSpanId(); - int getOperationId(); - String getOperationName(); - AbstractSpan setOperationId(int operationId); - /** * Reference other trace segment. * diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java index 001f934343..de593def63 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java @@ -43,7 +43,6 @@ public abstract class AbstractTracingSpan implements AbstractSpan { protected int parentSpanId; protected List tags; protected String operationName; - protected int operationId; protected SpanLayer layer; /** * The span has been tagged in async mode, required async stop to finish. @@ -90,15 +89,6 @@ public abstract class AbstractTracingSpan implements AbstractSpan { protected AbstractTracingSpan(int spanId, int parentSpanId, String operationName, TracingContext owner) { this.operationName = operationName; - this.operationId = DictionaryUtil.nullValue(); - this.spanId = spanId; - this.parentSpanId = parentSpanId; - this.owner = owner; - } - - protected AbstractTracingSpan(int spanId, int parentSpanId, int operationId, TracingContext owner) { - this.operationName = null; - this.operationId = operationId; this.spanId = spanId; this.parentSpanId = parentSpanId; this.owner = owner; @@ -167,7 +157,10 @@ public abstract class AbstractTracingSpan implements AbstractSpan { logs.add(new LogDataEntity.Builder().add(new KeyValuePair("event", "error")) .add(new KeyValuePair("error.kind", t.getClass().getName())) .add(new KeyValuePair("message", t.getMessage())) - .add(new KeyValuePair("stack", ThrowableTransformer.INSTANCE.convert2String(t, 4000))) + .add(new KeyValuePair( + "stack", + ThrowableTransformer.INSTANCE.convert2String(t, 4000) + )) .build(System.currentTimeMillis())); return this; } @@ -211,19 +204,6 @@ public abstract class AbstractTracingSpan implements AbstractSpan { @Override public AbstractTracingSpan setOperationName(String operationName) { this.operationName = operationName; - this.operationId = DictionaryUtil.nullValue(); - return this; - } - - /** - * Set the operation id, which compress by the name. - * - * @return span instance, for chaining. - */ - @Override - public AbstractTracingSpan setOperationId(int operationId) { - this.operationId = operationId; - this.operationName = null; return this; } @@ -232,11 +212,6 @@ public abstract class AbstractTracingSpan implements AbstractSpan { return spanId; } - @Override - public int getOperationId() { - return operationId; - } - @Override public String getOperationName() { return operationName; @@ -283,11 +258,7 @@ public abstract class AbstractTracingSpan implements AbstractSpan { spanBuilder.setParentSpanId(parentSpanId); spanBuilder.setStartTime(startTime); spanBuilder.setEndTime(endTime); - if (operationId != DictionaryUtil.nullValue()) { - spanBuilder.setOperationNameId(operationId); - } else { - spanBuilder.setOperationName(operationName); - } + spanBuilder.setOperationName(operationName); if (isEntry()) { spanBuilder.setSpanType(SpanType.Entry); } else if (isExit()) { diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/EntrySpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/EntrySpan.java index 70d0f42837..37ad142761 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/EntrySpan.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/EntrySpan.java @@ -41,11 +41,6 @@ public class EntrySpan extends StackBasedTracingSpan { this.currentMaxDepth = 0; } - public EntrySpan(int spanId, int parentSpanId, int operationId, TracingContext owner) { - super(spanId, parentSpanId, operationId, owner); - this.currentMaxDepth = 0; - } - /** * Set the {@link #startTime}, when the first start, which means the first service provided. */ @@ -102,15 +97,6 @@ public class EntrySpan extends StackBasedTracingSpan { } } - @Override - public AbstractTracingSpan setOperationId(int operationId) { - if (stackDepth == currentMaxDepth) { - return super.setOperationId(operationId); - } else { - return this; - } - } - @Override public EntrySpan log(Throwable t) { super.log(t); diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/ExitSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/ExitSpan.java index 345163fde1..d872a06735 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/ExitSpan.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/ExitSpan.java @@ -118,14 +118,6 @@ public class ExitSpan extends StackBasedTracingSpan implements ExitTypeSpan { } } - /** - * Illegal operation. Operation name id is the registered endpoint, only work for entry span. - */ - @Override - public AbstractTracingSpan setOperationId(int operationId) { - throw new UnsupportedOperationException("Exit span doesn't support operation id"); - } - @Override public int getPeerId() { return peerId; diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/LocalSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/LocalSpan.java index 91bc47f349..7bd6cbfc24 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/LocalSpan.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/LocalSpan.java @@ -25,10 +25,6 @@ import org.apache.skywalking.apm.agent.core.context.TracingContext; */ public class LocalSpan extends AbstractTracingSpan { - public LocalSpan(int spanId, int parentSpanId, int operationId, TracingContext owner) { - super(spanId, parentSpanId, operationId, owner); - } - public LocalSpan(int spanId, int parentSpanId, String operationName, TracingContext owner) { super(spanId, parentSpanId, operationName, owner); } @@ -47,12 +43,4 @@ public class LocalSpan extends AbstractTracingSpan { public AbstractSpan setPeer(String remotePeer) { return this; } - - /** - * Illegal operation. Operation name id is the registered endpoint, only work for entry span. - */ - @Override - public AbstractTracingSpan setOperationId(int operationId) { - throw new UnsupportedOperationException("Exit span doesn't support operation id"); - } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/NoopSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/NoopSpan.java index 234af2d721..422b5d85ac 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/NoopSpan.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/NoopSpan.java @@ -100,21 +100,11 @@ public class NoopSpan implements AbstractSpan { return 0; } - @Override - public int getOperationId() { - return 0; - } - @Override public String getOperationName() { return ""; } - @Override - public AbstractSpan setOperationId(int operationId) { - return this; - } - @Override public void ref(TraceSegmentRef ref) { } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/StackBasedTracingSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/StackBasedTracingSpan.java index d6ba150c63..55a0c779a1 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/StackBasedTracingSpan.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/StackBasedTracingSpan.java @@ -40,25 +40,6 @@ public abstract class StackBasedTracingSpan extends AbstractTracingSpan { this.peerId = DictionaryUtil.nullValue(); } - protected StackBasedTracingSpan(int spanId, int parentSpanId, int operationId, TracingContext owner) { - super(spanId, parentSpanId, operationId, owner); - this.stackDepth = 0; - this.peer = null; - this.peerId = DictionaryUtil.nullValue(); - } - - public StackBasedTracingSpan(int spanId, int parentSpanId, int operationId, int peerId, TracingContext owner) { - super(spanId, parentSpanId, operationId, owner); - this.peer = null; - this.peerId = peerId; - } - - public StackBasedTracingSpan(int spanId, int parentSpanId, int operationId, String peer, TracingContext owner) { - super(spanId, parentSpanId, operationId, owner); - this.peer = peer; - this.peerId = DictionaryUtil.nullValue(); - } - protected StackBasedTracingSpan(int spanId, int parentSpanId, String operationName, String peer, TracingContext owner) { super(spanId, parentSpanId, operationName, owner); @@ -89,17 +70,6 @@ public abstract class StackBasedTracingSpan extends AbstractTracingSpan { @Override public boolean finish(TraceSegment owner) { if (--stackDepth == 0) { - /* - * Since 6.6.0, only entry span requires the op name register, which is endpoint. - */ - if (this.isEntry()) { - if (this.operationId == DictionaryUtil.nullValue()) { - this.operationId = - (Integer) DictionaryManager.findEndpointSection() - .findOrPrepare4Register(owner.getServiceId(), operationName) - .doInCondition(value -> value, DictionaryUtil::nullValue); - } - } return super.finish(owner); } else { return false; diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java index cf4082ed03..384d79337c 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.agent.core.context.trace; +import org.apache.skywalking.apm.agent.core.conf.Constants; import org.apache.skywalking.apm.agent.core.conf.RemoteDownstreamConfig; import org.apache.skywalking.apm.agent.core.context.ContextCarrier; import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; @@ -47,13 +48,9 @@ public class TraceSegmentRef { private int parentServiceInstanceId; - private String entryEndpointName; + private String entryEndpointName = Constants.EMPTY_STRING; - private int entryEndpointId = DictionaryUtil.nullValue(); - - private String parentEndpointName; - - private int parentEndpointId = DictionaryUtil.nullValue(); + private String parentEndpointName = Constants.EMPTY_STRING; /** * Transform a {@link ContextCarrier} to the TraceSegmentRef @@ -76,16 +73,12 @@ public class TraceSegmentRef { if (!StringUtil.isEmpty(entryOperationName)) { if (entryOperationName.charAt(0) == '#') { this.entryEndpointName = entryOperationName.substring(1); - } else { - this.entryEndpointId = Integer.parseInt(entryOperationName); } } String parentOperationName = carrier.getParentEndpointName(); if (!StringUtil.isEmpty(parentOperationName)) { if (parentOperationName.charAt(0) == '#') { this.parentEndpointName = parentOperationName.substring(1); - } else { - this.parentEndpointId = Integer.parseInt(parentOperationName); } } } @@ -100,16 +93,12 @@ public class TraceSegmentRef { if (!StringUtil.isEmpty(entryOperationName)) { if (entryOperationName.charAt(0) == '#') { this.entryEndpointName = entryOperationName.substring(1); - } else { - this.entryEndpointId = Integer.parseInt(entryOperationName); } } String parentOperationName = snapshot.getParentOperationName(); if (!StringUtil.isEmpty(parentOperationName)) { if (parentOperationName.charAt(0) == '#') { this.parentEndpointName = parentOperationName.substring(1); - } else { - this.parentEndpointId = Integer.parseInt(parentOperationName); } } } @@ -118,10 +107,6 @@ public class TraceSegmentRef { return entryEndpointName; } - public int getEntryEndpointId() { - return entryEndpointId; - } - public int getEntryServiceInstanceId() { return entryServiceInstanceId; } @@ -143,25 +128,9 @@ public class TraceSegmentRef { refBuilder.setEntryServiceInstanceId(entryServiceInstanceId); refBuilder.setParentTraceSegmentId(traceSegmentId.transform()); refBuilder.setParentSpanId(spanId); - /* - * entryEndpointId/entryEndpointName and parentEndpointId/parentEndpointName could be empty at same time. - * This is accepted in v2 format. - * - */ - if (entryEndpointId == DictionaryUtil.nullValue()) { - if (!StringUtil.isEmpty(entryEndpointName)) { - refBuilder.setEntryEndpoint(entryEndpointName); - } - } else { - refBuilder.setEntryEndpointId(entryEndpointId); - } - if (parentEndpointId == DictionaryUtil.nullValue()) { - if (!StringUtil.isEmpty(parentEndpointName)) { - refBuilder.setParentEndpoint(parentEndpointName); - } - } else { - refBuilder.setParentEndpointId(parentEndpointId); - } + refBuilder.setEntryEndpoint(entryEndpointName); + refBuilder.setParentEndpoint(parentEndpointName); + return refBuilder.build(); } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java index b0fc1ab90a..5384104493 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryManager.java @@ -25,11 +25,4 @@ public class DictionaryManager { public static NetworkAddressDictionary findNetworkAddressSection() { return NetworkAddressDictionary.INSTANCE; } - - /** - * @return {@link EndpointNameDictionary} to find service id. - */ - public static EndpointNameDictionary findEndpointSection() { - return EndpointNameDictionary.INSTANCE; - } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryUtil.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryUtil.java index bf184b86d1..d02356528d 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryUtil.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/DictionaryUtil.java @@ -26,11 +26,4 @@ public class DictionaryUtil { public static boolean isNull(int id) { return id == nullValue(); } - - /** - * @return -1 represent the object doesn't exist. - */ - public static int inexistence() { - return -1; - } } diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/EndpointNameDictionary.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/EndpointNameDictionary.java deleted file mode 100755 index 721fb09b7e..0000000000 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/dictionary/EndpointNameDictionary.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.apm.agent.core.dictionary; - -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.ToString; -import org.apache.skywalking.apm.network.common.DetectPoint; -import org.apache.skywalking.apm.network.register.v2.Endpoint; -import org.apache.skywalking.apm.network.register.v2.EndpointMapping; -import org.apache.skywalking.apm.network.register.v2.EndpointMappingElement; -import org.apache.skywalking.apm.network.register.v2.Endpoints; -import org.apache.skywalking.apm.network.register.v2.RegisterGrpc; - -import static org.apache.skywalking.apm.agent.core.conf.Config.Dictionary.ENDPOINT_NAME_BUFFER_SIZE; - -public enum EndpointNameDictionary { - INSTANCE; - - private Map endpointDictionary = new ConcurrentHashMap<>(); - private Set unRegisterEndpoints = ConcurrentHashMap.newKeySet(); - - public PossibleFound findOrPrepare4Register(int serviceId, String endpointName) { - return find0(serviceId, endpointName, true); - } - - public PossibleFound findOnly(int serviceId, String endpointName) { - return find0(serviceId, endpointName, false); - } - - private PossibleFound find0(int serviceId, String endpointName, boolean registerWhenNotFound) { - if (endpointName == null || endpointName.length() == 0) { - return new NotFound(); - } - OperationNameKey key = new OperationNameKey(serviceId, endpointName); - Integer operationId = endpointDictionary.get(key); - if (operationId != null) { - return new Found(operationId); - } else { - if (registerWhenNotFound && endpointDictionary.size() + unRegisterEndpoints.size() < ENDPOINT_NAME_BUFFER_SIZE) { - unRegisterEndpoints.add(key); - } - return new NotFound(); - } - } - - public void syncRemoteDictionary(RegisterGrpc.RegisterBlockingStub serviceNameDiscoveryServiceBlockingStub) { - if (unRegisterEndpoints.size() > 0) { - Endpoints.Builder builder = Endpoints.newBuilder(); - for (OperationNameKey operationNameKey : unRegisterEndpoints) { - Endpoint endpoint = Endpoint.newBuilder() - .setServiceId(operationNameKey.getServiceId()) - .setEndpointName(operationNameKey.getEndpointName()) - .setFrom(DetectPoint.server) - .build(); - builder.addEndpoints(endpoint); - } - EndpointMapping serviceNameMappingCollection = serviceNameDiscoveryServiceBlockingStub.doEndpointRegister(builder - .build()); - if (serviceNameMappingCollection.getElementsCount() > 0) { - for (EndpointMappingElement element : serviceNameMappingCollection.getElementsList()) { - OperationNameKey key = new OperationNameKey(element.getServiceId(), element.getEndpointName()); - unRegisterEndpoints.remove(key); - endpointDictionary.put(key, element.getEndpointId()); - } - } - } - } - - public void clear() { - endpointDictionary.clear(); - } - - @Getter - @ToString - @RequiredArgsConstructor - private static class OperationNameKey { - private final int serviceId; - private final String endpointName; - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - OperationNameKey key = (OperationNameKey) o; - - boolean isServiceEndpointMatch = false; - if (serviceId == key.serviceId && endpointName.equals(key.endpointName)) { - isServiceEndpointMatch = true; - } - return isServiceEndpointMatch; - } - - @Override - public int hashCode() { - int result = serviceId; - result = 31 * result + endpointName.hashCode(); - return result; - } - } -} diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/ServiceAndEndpointRegisterClient.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/ServiceRegisterClient.java similarity index 92% rename from apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/ServiceAndEndpointRegisterClient.java rename to apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/ServiceRegisterClient.java index 6307c3b8ae..3af141dafb 100755 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/ServiceAndEndpointRegisterClient.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/remote/ServiceRegisterClient.java @@ -33,7 +33,6 @@ import org.apache.skywalking.apm.agent.core.commands.CommandService; import org.apache.skywalking.apm.agent.core.conf.Config; import org.apache.skywalking.apm.agent.core.conf.RemoteDownstreamConfig; import org.apache.skywalking.apm.agent.core.dictionary.DictionaryUtil; -import org.apache.skywalking.apm.agent.core.dictionary.EndpointNameDictionary; import org.apache.skywalking.apm.agent.core.dictionary.NetworkAddressDictionary; import org.apache.skywalking.apm.agent.core.logging.api.ILog; import org.apache.skywalking.apm.agent.core.logging.api.LogManager; @@ -57,15 +56,15 @@ import org.apache.skywalking.apm.util.StringUtil; import static org.apache.skywalking.apm.agent.core.conf.Config.Collector.GRPC_UPSTREAM_TIMEOUT; @DefaultImplementor -public class ServiceAndEndpointRegisterClient implements BootService, Runnable, GRPCChannelListener { - private static final ILog logger = LogManager.getLogger(ServiceAndEndpointRegisterClient.class); +public class ServiceRegisterClient implements BootService, Runnable, GRPCChannelListener { + private static final ILog logger = LogManager.getLogger(ServiceRegisterClient.class); private static String INSTANCE_UUID; private static List SERVICE_INSTANCE_PROPERTIES; private volatile GRPCChannelStatus status = GRPCChannelStatus.DISCONNECT; private volatile RegisterGrpc.RegisterBlockingStub registerBlockingStub; private volatile ServiceInstancePingGrpc.ServiceInstancePingBlockingStub serviceInstancePingStub; - private volatile ScheduledFuture applicationRegisterFuture; + private volatile ScheduledFuture serviceRegisterFuture; private volatile long coolDownStartTime = -1; @Override @@ -101,8 +100,8 @@ public class ServiceAndEndpointRegisterClient implements BootService, Runnable, @Override public void boot() { - applicationRegisterFuture = Executors.newSingleThreadScheduledExecutor( - new DefaultNamedThreadFactory("ServiceAndEndpointRegisterClient") + serviceRegisterFuture = Executors.newSingleThreadScheduledExecutor( + new DefaultNamedThreadFactory("ServiceRegisterClient") ).scheduleAtFixedRate( new RunnableWithExceptionProtection( this, @@ -118,12 +117,12 @@ public class ServiceAndEndpointRegisterClient implements BootService, Runnable, @Override public void shutdown() { - applicationRegisterFuture.cancel(true); + serviceRegisterFuture.cancel(true); } @Override public void run() { - logger.debug("ServiceAndEndpointRegisterClient running, status:{}.", status); + logger.debug("ServiceRegisterClient running, status:{}.", status); if (coolDownStartTime > 0) { final long coolDownDurationInMillis = TimeUnit.MINUTES.toMillis(Config.Agent.COOL_DOWN_THRESHOLD); @@ -201,14 +200,12 @@ public class ServiceAndEndpointRegisterClient implements BootService, Runnable, NetworkAddressDictionary.INSTANCE.syncRemoteDictionary( registerBlockingStub.withDeadlineAfter(GRPC_UPSTREAM_TIMEOUT, TimeUnit.SECONDS)); - EndpointNameDictionary.INSTANCE.syncRemoteDictionary( - registerBlockingStub.withDeadlineAfter(GRPC_UPSTREAM_TIMEOUT, TimeUnit.SECONDS)); ServiceManager.INSTANCE.findService(CommandService.class).receiveCommand(commands); } } } } catch (Throwable t) { - logger.error(t, "ServiceAndEndpointRegisterClient execute fail."); + logger.error(t, "ServiceRegisterClient execute fail."); ServiceManager.INSTANCE.findService(GRPCChannelManager.class).reportError(t); } } diff --git a/apm-sniffer/apm-agent-core/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.BootService b/apm-sniffer/apm-agent-core/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.BootService index 392600c769..d21536b5f1 100644 --- a/apm-sniffer/apm-agent-core/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.BootService +++ b/apm-sniffer/apm-agent-core/src/main/resources/META-INF/services/org.apache.skywalking.apm.agent.core.boot.BootService @@ -21,7 +21,7 @@ org.apache.skywalking.apm.agent.core.context.ContextManager org.apache.skywalking.apm.agent.core.sampling.SamplingService org.apache.skywalking.apm.agent.core.remote.GRPCChannelManager org.apache.skywalking.apm.agent.core.jvm.JVMService -org.apache.skywalking.apm.agent.core.remote.ServiceAndEndpointRegisterClient +org.apache.skywalking.apm.agent.core.remote.ServiceRegisterClient org.apache.skywalking.apm.agent.core.context.ContextManagerExtendService org.apache.skywalking.apm.agent.core.commands.CommandService org.apache.skywalking.apm.agent.core.commands.CommandExecutorService diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextCarrierV2HeaderTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextCarrierV2HeaderTest.java index 8bd53df8a3..19c9494d55 100644 --- a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextCarrierV2HeaderTest.java +++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextCarrierV2HeaderTest.java @@ -59,7 +59,7 @@ public class ContextCarrierV2HeaderTest { contextCarrier.setParentServiceInstanceId(1); contextCarrier.setPeerHost("127.0.0.1:8080"); contextCarrier.setEntryEndpointName("/portal"); - contextCarrier.setParentEndpointId(123); + contextCarrier.setParentEndpointName("/app"); contextCarrier.getCorrelationContext().put("test", "true"); @@ -72,7 +72,7 @@ public class ContextCarrierV2HeaderTest { * "1-3.4.5-1.2.3-4-1-1-#127.0.0.1:8080-#/portal-123" */ if (next.getHeadKey().equals(SW6CarrierItem.HEADER_NAME)) { - Assert.assertEquals("1-My40LjU=-MS4yLjM=-4-1-1-IzEyNy4wLjAuMTo4MDgw-Iy9wb3J0YWw=-MTIz", next.getHeadValue()); + Assert.assertEquals("1-My40LjU=-MS4yLjM=-4-1-1-IzEyNy4wLjAuMTo4MDgw-Iy9wb3J0YWw=-Iy9hcHA=", next.getHeadValue()); } else if (next.getHeadKey().equals(SW7CorrelationCarrierItem.HEADER_NAME)) { /** * customKey:customValue @@ -89,7 +89,7 @@ public class ContextCarrierV2HeaderTest { while (next.hasNext()) { next = next.next(); if (next.getHeadKey().equals(SW6CarrierItem.HEADER_NAME)) { - Assert.assertEquals("1-My40LjU=-MS4yLjM=-4-1-1-IzEyNy4wLjAuMTo4MDgw-Iy9wb3J0YWw=-MTIz", next.getHeadValue()); + Assert.assertEquals("1-My40LjU=-MS4yLjM=-4-1-1-IzEyNy4wLjAuMTo4MDgw-Iy9wb3J0YWw=-Iy9hcHA=", next.getHeadValue()); } else if (next.getHeadKey().equals(SW7CorrelationCarrierItem.HEADER_NAME)) { Assert.assertEquals("dGVzdA==:dHJ1ZQ==", next.getHeadValue()); } else { @@ -113,7 +113,7 @@ public class ContextCarrierV2HeaderTest { contextCarrier.setParentServiceInstanceId(1); contextCarrier.setPeerHost("127.0.0.1:8080"); contextCarrier.setEntryEndpointName("/portal"); - contextCarrier.setParentEndpointId(123); + contextCarrier.setParentEndpointName("/app"); contextCarrier.getCorrelationContext().put("test", "true"); diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextManagerTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextManagerTest.java index fc010ff425..f1d90069fc 100644 --- a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextManagerTest.java +++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/context/ContextManagerTest.java @@ -141,7 +141,6 @@ public class ContextManagerTest { TraceSegmentRef ref = actualSegment.getRefs().get(0); MatcherAssert.assertThat(TraceSegmentRefHelper.getPeerHost(ref), is("127.0.0.1:8080")); assertThat(ref.getEntryEndpointName(), is("/portal/")); - assertThat(ref.getEntryEndpointId(), is(0)); List spanList = SegmentHelper.getSpan(actualSegment); assertThat(spanList.size(), is(2)); diff --git a/docs/en/guides/Plugin-test.md b/docs/en/guides/Plugin-test.md index a739ebd0f1..168e355273 100644 --- a/docs/en/guides/Plugin-test.md +++ b/docs/en/guides/Plugin-test.md @@ -221,7 +221,6 @@ registryItems: - { SERVICE_CODE: INSTANCE_COUNT(int) } ... operationNames: - - SERVICE_CODE: [ ENTRY_SPAN_OPERATION(string), ... ] ... ``` @@ -230,7 +229,7 @@ registryItems: | --- | --- | services | The registered service codes. Normally, not 0 should be enough. | instances | The number of service instances exists in this test case. -| operationNames | Operation names of entry spans. Since 6.6.0, only these span name would do register, due to they are real endpoints. +| operationNames | Since 7.1.0, there is no operation name register. Ignore this. **Segment verify description format** diff --git a/docs/en/protocols/README.md b/docs/en/protocols/README.md index d1f5bb4e63..7ce29d2654 100644 --- a/docs/en/protocols/README.md +++ b/docs/en/protocols/README.md @@ -16,7 +16,8 @@ Service, Service Instance, Network address and Endpoint could do register to get ### Language based native agent protocol There is two types of protocols to make language agents work in distributed environments. -1. **Cross Process Propagation Headers Protocol** is in wire data format, agent/SDK usually uses HTTP/MQ/HTTP2 headers +1. **Cross Process Propagation Headers Protocol** and **Cross Process Correlation Headers Protocol** are in wire data format, +agent/SDK usually uses HTTP/MQ/HTTP2 headers to carry the data with rpc request. The remote agent will receive this in the request handler, and bind the context with this specific request. 1. **Trace Data Protocol** is out of wire data, agent/SDK uses this to send traces and metrics to skywalking or other @@ -25,10 +26,14 @@ compatible backend. [Cross Process Propagation Headers Protocol v2](Skywalking-Cross-Process-Propagation-Headers-Protocol-v2.md) is the new protocol for in-wire context propagation, started in 6.0.0-beta release, v1 is no longer supported. -Since SkyWalking v6.0.0-beta, SkyWalking agent and backend are using Trace Data Protocol v2. -[SkyWalking Trace Data Protocol v2](Trace-Data-Protocol-v2.md) defines the communication way and format between agent and backend. +[Cross Process Correlation Headers Protocol v1](Skywalking-Cross-Process-Correlation-Headers-Protocol-v1.md) is a new in-wire context propagation additional and optional protocols. +Please read SkyWalking language agents documentations to see whether it is supported. +This protocol defines the data format of transporting custom data with `Cross Process Propagation Headers Protocol v2`. +SkyWalking javaagent begins to support this since 7.1.0. + +Since SkyWalking v7.1.0, SkyWalking agent and backend are using Trace Data Protocol v2.1. +[SkyWalking Trace Data Protocol v2.1](Trace-Data-Protocol-v2.md) defines the communication way and format between agent and backend. -* [Cross Process Correlation Headers Protocol v1](Skywalking-Cross-Process-Correlation-Headers-Protocol-v1.md) is a new in-wire context propagation additional and optional protocols. Please read SkyWalking language agents documentations to see whether it is supported. This protocol defines the data format of transporting custom data with `Cross Process Propagation Headers Protocol v2`. SkyWalking javaagent begins to support this since 7.1.0. ### Service Mesh probe protocol The probe in sidecar or proxy could use this protocol to send data to backendEnd. This service provided by gRPC, requires diff --git a/docs/en/protocols/Skywalking-Cross-Process-Propagation-Headers-Protocol-v2.md b/docs/en/protocols/Skywalking-Cross-Process-Propagation-Headers-Protocol-v2.md index de40c4ce93..e782431813 100644 --- a/docs/en/protocols/Skywalking-Cross-Process-Propagation-Headers-Protocol-v2.md +++ b/docs/en/protocols/Skywalking-Cross-Process-Propagation-Headers-Protocol-v2.md @@ -1,5 +1,5 @@ # SkyWalking Cross Process Propagation Headers Protocol -* Version 2.0 +* Version 2.1 SkyWalking is more likely an APM system, rather than common distributed tracing system. The Headers is much more complex than them in order to improving analysis performance of collector. @@ -8,12 +8,6 @@ You can find many similar mechanism in other commercial APM system. (Some are ev ## Abstract SkyWalking Cross Process Propagation Headers Protocol v2 is also named as sw6 protocol, which is for context propagation. -## Differences from v1 -The major differences of v2 and v1, comes from SkyWalking's evolution, including -1. Mesh and languages are not same always, some info in headers should be optional. -1. BASE64 encoding required. -1. Sampling flag is included. - ## Header Item * Header Name: `sw6` * Header Value: Split by `-`, the parts are following. The length of header value should be less than 2k(default). @@ -36,13 +30,19 @@ service. _This value can use exchange/compress collector service to get the id(i - Optional(s) Optional values could not exist if the agent/SDK haven't those info or the length of header is over the threshold(2k default). -1. Entry endpoint of the trace. **String(BASE64 encoded)**. -_This value can use exchange/compress collector service to get the id(integer) to represent the string. If you use the string, it must start with `#`, others use integer directly._ -1. Parent endpoint of the parent service. **String(BASE64 encoded)**. -_This value can use exchange/compress collector service to get the id(integer) to represent the string. If you use the string, it must start with `#`, others use integer directly._ - -endpoint id = -1 and parent endpoint name is empty mean there is no real parent endpoint. Since 6.6.0 +1. Entry endpoint of the trace. Add `#` as the prefix. **String(BASE64 encoded)**. +1. Parent endpoint of the parent service. Add `#` as the prefix. **String(BASE64 encoded)**. ## Sample values 1. Short version, `1-TRACEID-SEGMENTID-3-5-2-IPPORT` 1. Complete version, `1-TRACEID-SEGMENTID-3-5-2-IPPORT-ENTRYURI-PARENTURI` + +## Differences from v2 +The entry and parent endpoints in the header doesn't support ID format. Always use the literal string. +[SkyWalking v2](https://github.com/apache/skywalking/blob/v7.0.0/docs/en/protocols/Trace-Data-Protocol-v2.md) + +## Differences from v1 +The major differences of v2 and v1, comes from SkyWalking's evolution, including +1. Mesh and languages are not same always, some info in headers should be optional. +1. BASE64 encoding required. +1. Sampling flag is included. diff --git a/docs/en/setup/backend/backend-alarm.md b/docs/en/setup/backend/backend-alarm.md index c1080d88de..b812036207 100644 --- a/docs/en/setup/backend/backend-alarm.md +++ b/docs/en/setup/backend/backend-alarm.md @@ -97,8 +97,8 @@ Example as following "scopeId": 1, "scope": "SERVICE", "name": "serviceA", - "id0": 12, - "id1": 0, + "id0": "12", + "id1": "", "ruleName": "service_resp_time_rule", "alarmMessage": "alarmMessage xxxx", "startTime": 1560524171000 @@ -106,8 +106,8 @@ Example as following "scopeId": 1, "scope": "SERVICE", "name": "serviceB", - "id0": 23, - "id1": 0, + "id0": "23", + "id1": "", "ruleName": "service_resp_time_rule", "alarmMessage": "alarmMessage yyy", "startTime": 1560524171000 @@ -124,8 +124,8 @@ message AlarmMessage { int64 scopeId = 1; string scope = 2; string name = 3; - int64 id0 = 4; - int64 id1 = 5; + string id0 = 4; + string id1 = 5; string ruleName = 6; string alarmMessage = 7; int64 startTime = 8; diff --git a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/MetricFormatter.java b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/MetricFormatter.java index 1060a7a122..138240166f 100644 --- a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/MetricFormatter.java +++ b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/MetricFormatter.java @@ -19,8 +19,8 @@ package org.apache.skywalking.oap.server.exporter.provider; import lombok.Setter; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.analysis.metrics.MetricsMetaInfo; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; @@ -29,7 +29,6 @@ import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; public class MetricFormatter { private ServiceInventoryCache serviceInventoryCache; private ServiceInstanceInventoryCache serviceInstanceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; protected String getEntityName(MetricsMetaInfo meta) { int scope = meta.getScope(); @@ -40,8 +39,7 @@ public class MetricFormatter { int entityId = Integer.valueOf(meta.getId()); return serviceInstanceInventoryCache.get(entityId).getName(); } else if (DefaultScopeDefine.inEndpointCatalog(scope)) { - int entityId = Integer.valueOf(meta.getId()); - return endpointInventoryCache.get(entityId).getName(); + return EndpointTraffic.splitID(meta.getId()).getEndpointName(); } else if (scope == DefaultScopeDefine.ALL) { return ""; } else { diff --git a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProvider.java b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProvider.java index b7875ee39d..bb74d1f474 100644 --- a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProvider.java +++ b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProvider.java @@ -19,7 +19,6 @@ package org.apache.skywalking.oap.server.exporter.provider.grpc; import org.apache.skywalking.oap.server.core.CoreModule; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.exporter.ExporterModule; @@ -67,7 +66,6 @@ public class GRPCExporterProvider extends ModuleProvider { ModuleServiceHolder serviceHolder = getManager().find(CoreModule.NAME).provider(); exporter.setServiceInventoryCache(serviceHolder.getService(ServiceInventoryCache.class)); exporter.setServiceInstanceInventoryCache(serviceHolder.getService(ServiceInstanceInventoryCache.class)); - exporter.setEndpointInventoryCache(serviceHolder.getService(EndpointInventoryCache.class)); exporter.initSubscriptionList(); } diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProviderTest.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProviderTest.java index 6590728e94..d809c24576 100644 --- a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProviderTest.java +++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProviderTest.java @@ -21,7 +21,6 @@ package org.apache.skywalking.oap.server.exporter.provider.grpc; import java.util.Iterator; import java.util.ServiceLoader; import org.apache.skywalking.oap.server.core.CoreModule; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.exporter.ExporterModule; @@ -97,7 +96,6 @@ public class GRPCExporterProviderTest { when(serviceHolder.getService(ServiceInventoryCache.class)).thenReturn(null); when(serviceHolder.getService(ServiceInstanceInventoryCache.class)).thenReturn(null); - when(serviceHolder.getService(EndpointInventoryCache.class)).thenReturn(null); doNothing().when(exporter).initSubscriptionList(); diff --git a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java index 2b4b547fa6..54f3e41006 100644 --- a/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java +++ b/oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandler.java @@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.alarm.provider; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.alarm.AlarmCallback; import org.apache.skywalking.oap.server.core.alarm.EndpointMetaInAlarm; @@ -29,22 +30,21 @@ import org.apache.skywalking.oap.server.core.alarm.MetricsNotify; import org.apache.skywalking.oap.server.core.alarm.ServiceInstanceMetaInAlarm; import org.apache.skywalking.oap.server.core.alarm.ServiceMetaInAlarm; import org.apache.skywalking.oap.server.core.alarm.provider.grpc.GRPCCallback; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.analysis.metrics.MetricsMetaInfo; import org.apache.skywalking.oap.server.core.analysis.metrics.WithMetadata; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; import org.apache.skywalking.oap.server.core.register.ServiceInventory; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; import org.apache.skywalking.oap.server.library.module.ModuleManager; +@Slf4j public class NotifyHandler implements MetricsNotify { private ServiceInventoryCache serviceInventoryCache; private ServiceInstanceInventoryCache serviceInstanceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; private final AlarmCore core; private final AlarmRulesWatcher alarmRulesWatcher; @@ -60,7 +60,8 @@ public class NotifyHandler implements MetricsNotify { MetricsMetaInfo meta = withMetadata.getMeta(); int scope = meta.getScope(); - if (!DefaultScopeDefine.inServiceCatalog(scope) && !DefaultScopeDefine.inServiceInstanceCatalog(scope) && !DefaultScopeDefine + if (!DefaultScopeDefine.inServiceCatalog(scope) && !DefaultScopeDefine.inServiceInstanceCatalog( + scope) && !DefaultScopeDefine .inEndpointCatalog(scope)) { return; } @@ -71,7 +72,7 @@ public class NotifyHandler implements MetricsNotify { ServiceInventory serviceInventory = serviceInventoryCache.get(serviceId); ServiceMetaInAlarm serviceMetaInAlarm = new ServiceMetaInAlarm(); serviceMetaInAlarm.setMetricsName(meta.getMetricsName()); - serviceMetaInAlarm.setId(serviceId); + serviceMetaInAlarm.setId(String.valueOf(serviceId)); serviceMetaInAlarm.setName(serviceInventory.getName()); metaInAlarm = serviceMetaInAlarm; } else if (DefaultScopeDefine.inServiceInstanceCatalog(scope)) { @@ -79,21 +80,18 @@ public class NotifyHandler implements MetricsNotify { ServiceInstanceInventory serviceInstanceInventory = serviceInstanceInventoryCache.get(serviceInstanceId); ServiceInstanceMetaInAlarm instanceMetaInAlarm = new ServiceInstanceMetaInAlarm(); instanceMetaInAlarm.setMetricsName(meta.getMetricsName()); - instanceMetaInAlarm.setId(serviceInstanceId); + instanceMetaInAlarm.setId(String.valueOf(serviceInstanceId)); instanceMetaInAlarm.setName(serviceInstanceInventory.getName()); metaInAlarm = instanceMetaInAlarm; } else if (DefaultScopeDefine.inEndpointCatalog(scope)) { - int endpointId = Integer.parseInt(meta.getId()); - EndpointInventory endpointInventory = endpointInventoryCache.get(endpointId); EndpointMetaInAlarm endpointMetaInAlarm = new EndpointMetaInAlarm(); endpointMetaInAlarm.setMetricsName(meta.getMetricsName()); - endpointMetaInAlarm.setId(endpointId); - int serviceId = endpointInventory.getServiceId(); - ServiceInventory serviceInventory = serviceInventoryCache.get(serviceId); - - String textName = endpointInventory.getName() + " in " + serviceInventory.getName(); + final EndpointTraffic.EndpointID endpointID = EndpointTraffic.splitID(meta.getId()); + ServiceInventory serviceInventory = serviceInventoryCache.get(endpointID.getServiceId()); + String textName = endpointID.getEndpointName() + " in " + serviceInventory.getName(); + endpointMetaInAlarm.setId(meta.getId()); endpointMetaInAlarm.setName(textName); metaInAlarm = endpointMetaInAlarm; } else { @@ -120,8 +118,5 @@ public class NotifyHandler implements MetricsNotify { serviceInstanceInventoryCache = moduleManager.find(CoreModule.NAME) .provider() .getService(ServiceInstanceInventoryCache.class); - endpointInventoryCache = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class); } } diff --git a/oap-server/server-alarm-plugin/src/main/proto/alarm-hook.proto b/oap-server/server-alarm-plugin/src/main/proto/alarm-hook.proto index 1e2e638781..1f3a34fd50 100644 --- a/oap-server/server-alarm-plugin/src/main/proto/alarm-hook.proto +++ b/oap-server/server-alarm-plugin/src/main/proto/alarm-hook.proto @@ -30,8 +30,8 @@ message AlarmMessage { int64 scopeId = 1; string scope = 2; string name = 3; - int64 id0 = 4; - int64 id1 = 5; + string id0 = 4; + string id1 = 5; string ruleName = 6; string alarmMessage = 7; int64 startTime = 8; diff --git a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmMessageFormatterTest.java b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmMessageFormatterTest.java index 659147db92..9f61d2b498 100644 --- a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmMessageFormatterTest.java +++ b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/AlarmMessageFormatterTest.java @@ -49,13 +49,13 @@ public class AlarmMessageFormatterTest { } @Override - public int getId0() { - return 0; + public String getId0() { + return ""; } @Override - public int getId1() { - return 0; + public String getId1() { + return ""; } }); @@ -88,13 +88,13 @@ public class AlarmMessageFormatterTest { } @Override - public int getId0() { - return 1290; + public String getId0() { + return "1290"; } @Override - public int getId1() { - return 0; + public String getId1() { + return ""; } }); Assert.assertEquals("abc} words service - 1290 .. {", message); diff --git a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandlerTest.java b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandlerTest.java index cd211f45b4..6110683afa 100644 --- a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandlerTest.java +++ b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/NotifyHandlerTest.java @@ -25,16 +25,16 @@ import org.apache.skywalking.oap.server.core.alarm.EndpointMetaInAlarm; import org.apache.skywalking.oap.server.core.alarm.MetaInAlarm; import org.apache.skywalking.oap.server.core.alarm.ServiceInstanceMetaInAlarm; import org.apache.skywalking.oap.server.core.alarm.ServiceMetaInAlarm; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.analysis.metrics.MetricsMetaInfo; import org.apache.skywalking.oap.server.core.analysis.metrics.WithMetadata; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; import org.apache.skywalking.oap.server.core.register.ServiceInventory; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; +import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.library.module.ModuleProviderHolder; import org.apache.skywalking.oap.server.library.module.ModuleServiceHolder; @@ -76,8 +76,6 @@ public class NotifyHandlerTest { private ServiceInstanceInventoryCache serviceInstanceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; - private MockMetrics metrics; private MetricsMetaInfo metadata; @@ -96,16 +94,15 @@ public class NotifyHandlerTest { when(DefaultScopeDefine.inEndpointCatalog(0)).thenReturn(true); String endpointInventoryName = "endpoint-inventory-name"; - EndpointInventory endpointInventory = mock(EndpointInventory.class); - when(endpointInventory.getName()).thenReturn(endpointInventoryName); + EndpointTraffic endpointTraffic = mock(EndpointTraffic.class); + when(endpointTraffic.getName()).thenReturn(endpointInventoryName); String serviceInventoryName = "service-inventory-name"; ServiceInventory serviceInventory = mock(ServiceInventory.class); when(serviceInventory.getName()).thenReturn(serviceInventoryName); when(serviceInventoryCache.get(anyInt())).thenReturn(serviceInventory); - - when(endpointInventoryCache.get(anyInt())).thenReturn(endpointInventory); + when(metadata.getId()).thenReturn(EndpointTraffic.buildId(1, endpointInventoryName, DetectPoint.SERVER)); ArgumentCaptor metaCaptor = ArgumentCaptor.forClass(MetaInAlarm.class); @@ -115,7 +112,7 @@ public class NotifyHandlerTest { MetaInAlarm metaInAlarm = metaCaptor.getValue(); assertTrue(metaInAlarm instanceof EndpointMetaInAlarm); - assertEquals(mockId, metaInAlarm.getId0()); + assertEquals("1_ZW5kcG9pbnQtaW52ZW50b3J5LW5hbWU=_0", metaInAlarm.getId0()); assertEquals(DefaultScopeDefine.ENDPOINT_CATALOG_NAME, metaInAlarm.getScope()); assertEquals(metricsName, metaInAlarm.getMetricsName()); assertEquals(endpointInventoryName + " in " + serviceInventoryName, metaInAlarm.getName()); @@ -148,7 +145,7 @@ public class NotifyHandlerTest { assertTrue(metaInAlarm instanceof ServiceInstanceMetaInAlarm); assertEquals(metricsName, metaInAlarm.getMetricsName()); - assertEquals(mockId, metaInAlarm.getId0()); + assertEquals(mockId + "", metaInAlarm.getId0()); assertEquals(DefaultScopeDefine.SERVICE_INSTANCE_CATALOG_NAME, metaInAlarm.getScope()); assertEquals(instanceInventoryName, metaInAlarm.getName()); assertEquals(DefaultScopeDefine.SERVICE_INSTANCE, metaInAlarm.getScopeId()); @@ -177,7 +174,7 @@ public class NotifyHandlerTest { assertTrue(metaInAlarm instanceof ServiceMetaInAlarm); assertEquals(metricsName, metaInAlarm.getMetricsName()); - assertEquals(mockId, metaInAlarm.getId0()); + assertEquals(mockId + "", metaInAlarm.getId0()); assertEquals(DefaultScopeDefine.SERVICE_CATALOG_NAME, metaInAlarm.getScope()); assertEquals(serviceInventoryName, metaInAlarm.getName()); assertEquals(DefaultScopeDefine.SERVICE, metaInAlarm.getScopeId()); @@ -238,11 +235,10 @@ public class NotifyHandlerTest { serviceInventoryCache = mock(ServiceInventoryCache.class); serviceInstanceInventoryCache = mock(ServiceInstanceInventoryCache.class); - endpointInventoryCache = mock(EndpointInventoryCache.class); when(moduleServiceHolder.getService(ServiceInventoryCache.class)).thenReturn(serviceInventoryCache); - when(moduleServiceHolder.getService(ServiceInstanceInventoryCache.class)).thenReturn(serviceInstanceInventoryCache); - when(moduleServiceHolder.getService(EndpointInventoryCache.class)).thenReturn(endpointInventoryCache); + when(moduleServiceHolder.getService(ServiceInstanceInventoryCache.class)).thenReturn( + serviceInstanceInventoryCache); AlarmCore core = mock(AlarmCore.class); diff --git a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRuleTest.java b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRuleTest.java index ef57dff800..d2187c5ace 100644 --- a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRuleTest.java +++ b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRuleTest.java @@ -23,6 +23,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; +import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.alarm.AlarmCallback; import org.apache.skywalking.oap.server.core.alarm.AlarmMessage; import org.apache.skywalking.oap.server.core.alarm.MetaInAlarm; @@ -143,8 +144,9 @@ public class RunningRuleTest { // check at 201808301442 alarmMessages = runningRule.check(); Assert.assertEquals(1, alarmMessages.size()); - Assert.assertEquals("response percentile of endpoint Service_123 is lower than expected values", alarmMessages.get(0) - .getAlarmMessage()); + Assert.assertEquals( + "response percentile of endpoint Service_123 is lower than expected values", alarmMessages.get(0) + .getAlarmMessage()); } @Test @@ -283,19 +285,19 @@ public class RunningRuleTest { } @Override - public int getId0() { - return id; + public String getId0() { + return "" + id; } @Override - public int getId1() { - return 0; + public String getId1() { + return Const.EMPTY_STRING; } @Override public boolean equals(Object o) { MetaInAlarm target = (MetaInAlarm) o; - return id == target.getId0(); + return (id + "").equals(target.getId0()); } @Override diff --git a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/grpc/GRPChookCallbackTest.java b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/grpc/GRPChookCallbackTest.java index 5af3e2a12e..e5cc052199 100644 --- a/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/grpc/GRPChookCallbackTest.java +++ b/oap-server/server-alarm-plugin/src/test/java/org/apache/skywalking/oap/server/core/alarm/provider/grpc/GRPChookCallbackTest.java @@ -66,8 +66,8 @@ public class GRPChookCallbackTest { private void mockAlarmMessage() { AlarmMessage alarmMessage = new AlarmMessage(); - alarmMessage.setId0(1); - alarmMessage.setId1(2); + alarmMessage.setId0("1"); + alarmMessage.setId1("2"); alarmMessage.setScope(Scope.Service.name()); alarmMessage.setName("mock alarm message"); alarmMessage.setAlarmMessage("message"); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/Const.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/Const.java index 213f482d59..cc1f2c84b7 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/Const.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/Const.java @@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core; public class Const { public static final int NONE = 0; public static final String ID_SPLIT = "_"; + public static final String ID_PARSER_SPLIT = "\\_"; public static final String LINE = "-"; public static final String SPACE = " "; public static final String KEY_VALUE_SPLIT = ","; @@ -28,7 +29,7 @@ public class Const { public static final String ARRAY_PARSER_SPLIT = "\\|"; public static final int USER_SERVICE_ID = 1; public static final int USER_INSTANCE_ID = 1; - public static final int USER_ENDPOINT_ID = 1; + public static final String USER_ENDPOINT_NAME = "User"; public static final int INEXISTENCE_ENDPOINT_ID = -1; public static final String USER_CODE = "User"; public static final String SEGMENT_SPAN_SPLIT = "S"; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java index e7fa4af64c..1260903683 100755 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModule.java @@ -20,7 +20,6 @@ package org.apache.skywalking.oap.server.core; import java.util.ArrayList; import java.util.List; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.NetworkAddressInventoryCache; import org.apache.skywalking.oap.server.core.cache.ProfileTaskCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; @@ -39,7 +38,6 @@ import org.apache.skywalking.oap.server.core.query.ProfileTaskQueryService; import org.apache.skywalking.oap.server.core.query.TopNRecordsQueryService; import org.apache.skywalking.oap.server.core.query.TopologyQueryService; import org.apache.skywalking.oap.server.core.query.TraceQueryService; -import org.apache.skywalking.oap.server.core.register.service.IEndpointInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.INetworkAddressInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInstanceInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInventoryRegister; @@ -122,14 +120,12 @@ public class CoreModule extends ModuleDefine { private void addRegisterService(List classes) { classes.add(IServiceInventoryRegister.class); classes.add(IServiceInstanceInventoryRegister.class); - classes.add(IEndpointInventoryRegister.class); classes.add(INetworkAddressInventoryRegister.class); } private void addCacheService(List classes) { classes.add(ServiceInventoryCache.class); classes.add(ServiceInstanceInventoryCache.class); - classes.add(EndpointInventoryCache.class); classes.add(NetworkAddressInventoryCache.class); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java index cd4c63946f..b7d0fa5c8a 100755 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java @@ -30,7 +30,6 @@ import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProces import org.apache.skywalking.oap.server.core.analysis.worker.TopNStreamProcessor; import org.apache.skywalking.oap.server.core.annotation.AnnotationScan; import org.apache.skywalking.oap.server.core.cache.CacheUpdateTimer; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.NetworkAddressInventoryCache; import org.apache.skywalking.oap.server.core.cache.ProfileTaskCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; @@ -55,8 +54,6 @@ import org.apache.skywalking.oap.server.core.query.ProfileTaskQueryService; import org.apache.skywalking.oap.server.core.query.TopNRecordsQueryService; import org.apache.skywalking.oap.server.core.query.TopologyQueryService; import org.apache.skywalking.oap.server.core.query.TraceQueryService; -import org.apache.skywalking.oap.server.core.register.service.EndpointInventoryRegister; -import org.apache.skywalking.oap.server.core.register.service.IEndpointInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.INetworkAddressInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInstanceInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInventoryRegister; @@ -170,7 +167,8 @@ public class CoreModuleProvider extends ModuleProvider { if (moduleConfig.isGRPCSslEnabled()) { grpcServer = new GRPCServer(moduleConfig.getGRPCHost(), moduleConfig.getGRPCPort(), Paths.get(moduleConfig.getGRPCSslCertChainPath()).toFile(), - Paths.get(moduleConfig.getGRPCSslKeyPath()).toFile()); + Paths.get(moduleConfig.getGRPCSslKeyPath()).toFile() + ); } else { grpcServer = new GRPCServer(moduleConfig.getGRPCHost(), moduleConfig.getGRPCPort()); } @@ -222,11 +220,6 @@ public class CoreModuleProvider extends ModuleProvider { this.registerServiceImplementation( IServiceInstanceInventoryRegister.class, new ServiceInstanceInventoryRegister(getManager())); - this.registerServiceImplementation( - EndpointInventoryCache.class, new EndpointInventoryCache(getManager(), moduleConfig)); - this.registerServiceImplementation( - IEndpointInventoryRegister.class, new EndpointInventoryRegister(getManager())); - this.registerServiceImplementation( NetworkAddressInventoryCache.class, new NetworkAddressInventoryCache(getManager(), moduleConfig)); this.registerServiceImplementation( @@ -254,7 +247,9 @@ public class CoreModuleProvider extends ModuleProvider { if (moduleConfig.isGRPCSslEnabled()) { this.remoteClientManager = new RemoteClientManager(getManager(), moduleConfig.getRemoteTimeout(), - Paths.get(moduleConfig.getGRPCSslTrustedCAPath()).toFile()); + Paths.get(moduleConfig.getGRPCSslTrustedCAPath()) + .toFile() + ); } else { this.remoteClientManager = new RemoteClientManager(getManager(), moduleConfig.getRemoteTimeout()); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmMessage.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmMessage.java index 0ee654f2a7..e47503a588 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmMessage.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmMessage.java @@ -34,8 +34,8 @@ public class AlarmMessage { private int scopeId; private String scope; private String name; - private int id0; - private int id1; + private String id0; + private String id1; private String ruleName; private String alarmMessage; private long startTime; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmRecord.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmRecord.java index 18093940c4..2632234ba2 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmRecord.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/AlarmRecord.java @@ -57,9 +57,9 @@ public class AlarmRecord extends Record { @Column(columnName = NAME) private String name; @Column(columnName = ID0) - private int id0; + private String id0; @Column(columnName = ID1) - private int id1; + private String id1; @Column(columnName = START_TIME) private long startTime; @Column(columnName = ALARM_MESSAGE, matchQuery = true) @@ -85,8 +85,8 @@ public class AlarmRecord extends Record { AlarmRecord record = new AlarmRecord(); record.setScope(((Number) dbMap.get(SCOPE)).intValue()); record.setName((String) dbMap.get(NAME)); - record.setId0(((Number) dbMap.get(ID0)).intValue()); - record.setId1(((Number) dbMap.get(ID1)).intValue()); + record.setId0((String) dbMap.get(ID0)); + record.setId1((String) dbMap.get(ID1)); record.setAlarmMessage((String) dbMap.get(ALARM_MESSAGE)); record.setStartTime(((Number) dbMap.get(START_TIME)).longValue()); record.setTimeBucket(((Number) dbMap.get(TIME_BUCKET)).longValue()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/EndpointMetaInAlarm.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/EndpointMetaInAlarm.java index 1b0d769b8b..cccd674d66 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/EndpointMetaInAlarm.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/EndpointMetaInAlarm.java @@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.alarm; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; +import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; @Getter(AccessLevel.PUBLIC) @@ -28,7 +29,7 @@ import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; public class EndpointMetaInAlarm extends MetaInAlarm { private String metricsName; - private int id; + private String id; private String name; private String[] tags; private String[] properties; @@ -44,12 +45,12 @@ public class EndpointMetaInAlarm extends MetaInAlarm { } @Override - public int getId0() { + public String getId0() { return id; } @Override - public int getId1() { - return 0; + public String getId1() { + return Const.EMPTY_STRING; } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetaInAlarm.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetaInAlarm.java index c94dcae7fc..56d2cf570b 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetaInAlarm.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/MetaInAlarm.java @@ -36,12 +36,12 @@ public abstract class MetaInAlarm { * * @return the primary id. */ - public abstract int getId0(); + public abstract String getId0(); /** * Only exist in multiple IDs case, Such as ServiceRelation, id1 represents the dest service id */ - public abstract int getId1(); + public abstract String getId1(); @Override public boolean equals(Object o) { @@ -50,7 +50,7 @@ public abstract class MetaInAlarm { if (o == null || getClass() != o.getClass()) return false; MetaInAlarm that = (MetaInAlarm) o; - return getId0() == that.getId0() && getId1() == that.getId1(); + return getId0().equals(that.getId0()) && getId1().equals(that.getId1()); } @Override diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceInstanceMetaInAlarm.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceInstanceMetaInAlarm.java index 76518fb15c..e78d441dc3 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceInstanceMetaInAlarm.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceInstanceMetaInAlarm.java @@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.alarm; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; +import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; @Getter(AccessLevel.PUBLIC) @@ -28,7 +29,7 @@ import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; public class ServiceInstanceMetaInAlarm extends MetaInAlarm { private String metricsName; - private int id; + private String id; private String name; private String[] tags; private String[] properties; @@ -44,12 +45,12 @@ public class ServiceInstanceMetaInAlarm extends MetaInAlarm { } @Override - public int getId0() { + public String getId0() { return id; } @Override - public int getId1() { - return 0; + public String getId1() { + return Const.EMPTY_STRING; } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceMetaInAlarm.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceMetaInAlarm.java index d03022535e..c5698a0069 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceMetaInAlarm.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/alarm/ServiceMetaInAlarm.java @@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.alarm; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; +import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; @Getter(AccessLevel.PUBLIC) @@ -28,7 +29,7 @@ import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; public class ServiceMetaInAlarm extends MetaInAlarm { private String metricsName; - private int id; + private String id; private String name; private String[] tags; private String[] properties; @@ -44,12 +45,12 @@ public class ServiceMetaInAlarm extends MetaInAlarm { } @Override - public int getId0() { + public String getId0() { return id; } @Override - public int getId1() { - return 0; + public String getId1() { + return Const.EMPTY_STRING; } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/Stream.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/Stream.java index 0cf0f38f31..35fd888ce8 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/Stream.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/Stream.java @@ -59,4 +59,9 @@ public @interface Stream { * InventoryStreamProcessor}, {@link TopNStreamProcessor} and {@link NoneStreamingProcessor} for more details. */ Class processor(); + + /** + * @return true if this metrics stream support down sampling. + */ + boolean supportDownSampling() default true; } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/RelationDefineUtil.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/RelationDefineUtil.java index 9aa698e9dd..7efd78f27f 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/RelationDefineUtil.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/RelationDefineUtil.java @@ -18,12 +18,20 @@ package org.apache.skywalking.oap.server.core.analysis.manual; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import lombok.EqualsAndHashCode; import lombok.Getter; +import lombok.RequiredArgsConstructor; import org.apache.skywalking.oap.server.core.Const; +import org.apache.skywalking.oap.server.core.UnexpectedException; public class RelationDefineUtil { + /** + * @return the service or instance relationship string id. + */ public static String buildEntityId(RelationDefine define) { - return String.valueOf(define.source) + Const.ID_SPLIT + String.valueOf(define.dest) + Const.ID_SPLIT + String.valueOf(define.componentId); + return define.source + Const.ID_SPLIT + define.dest + Const.ID_SPLIT + define.componentId; } /** @@ -37,16 +45,54 @@ public class RelationDefineUtil { return new RelationDefine(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2])); } + /** + * @return the endpoint relationship string id. + */ + public static String buildEndpointRelationEntityId(EndpointRelationDefine define) { + return define.sourceServiceId + + Const.ID_SPLIT + + new String( + Base64.getEncoder().encode(define.source.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8) + + Const.ID_SPLIT + + define.destServiceId + + Const.ID_SPLIT + + new String( + Base64.getEncoder().encode(define.dest.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8) + + Const.ID_SPLIT + + define.componentId; + } + + public static EndpointRelationDefine splitEndpointRelationEntityId(String entityId) { + String[] parts = entityId.split(Const.ID_SPLIT); + if (parts.length != 5) { + throw new UnexpectedException("Illegal endpoint Relation entity id, " + entityId); + } + return new EndpointRelationDefine( + Integer.parseInt(parts[0]), + new String(Base64.getDecoder().decode(parts[1]), StandardCharsets.UTF_8), + Integer.parseInt(parts[2]), + new String(Base64.getDecoder().decode(parts[3]), StandardCharsets.UTF_8), + Integer.parseInt(parts[4]) + ); + } + + @RequiredArgsConstructor @Getter + @EqualsAndHashCode public static class RelationDefine { - private int source; - private int dest; - private int componentId; - - public RelationDefine(int source, int dest, int componentId) { - this.source = source; - this.dest = dest; - this.componentId = componentId; - } + private final int source; + private final int dest; + private final int componentId; + } + + @RequiredArgsConstructor + @Getter + @EqualsAndHashCode + public static class EndpointRelationDefine { + private final int sourceServiceId; + private final String source; + private final int destServiceId; + private final String dest; + private final int componentId; } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/EndpointInventory.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTraffic.java similarity index 51% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/EndpointInventory.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTraffic.java index d4ad3fe1fd..230e973612 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/EndpointInventory.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTraffic.java @@ -16,29 +16,37 @@ * */ -package org.apache.skywalking.oap.server.core.register; +package org.apache.skywalking.oap.server.core.analysis.manual.endpoint; import com.google.common.base.Strings; +import java.nio.charset.StandardCharsets; +import java.util.Base64; import java.util.HashMap; import java.util.Map; import lombok.Getter; +import lombok.RequiredArgsConstructor; import lombok.Setter; import org.apache.skywalking.oap.server.core.Const; +import org.apache.skywalking.oap.server.core.UnexpectedException; import org.apache.skywalking.oap.server.core.analysis.Stream; -import org.apache.skywalking.oap.server.core.register.worker.InventoryStreamProcessor; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; +import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor; import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine; +import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.core.source.ScopeDeclaration; import org.apache.skywalking.oap.server.core.storage.StorageBuilder; import org.apache.skywalking.oap.server.core.storage.annotation.Column; -import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.ENDPOINT_INVENTORY; +import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.ENDPOINT_TRAFFIC; -@ScopeDeclaration(id = ENDPOINT_INVENTORY, name = "EndpointInventory") -@Stream(name = EndpointInventory.INDEX_NAME, scopeId = DefaultScopeDefine.ENDPOINT_INVENTORY, builder = EndpointInventory.Builder.class, processor = InventoryStreamProcessor.class) -public class EndpointInventory extends RegisterSource { +@ScopeDeclaration(id = ENDPOINT_TRAFFIC, name = "EndpointTraffic") +@Stream(name = EndpointTraffic.INDEX_NAME, scopeId = DefaultScopeDefine.ENDPOINT_TRAFFIC, + builder = EndpointTraffic.Builder.class, processor = MetricsStreamProcessor.class, + supportDownSampling = false) +public class EndpointTraffic extends Metrics { - public static final String INDEX_NAME = "endpoint_inventory"; + public static final String INDEX_NAME = "endpoint_traffic"; public static final String SERVICE_ID = "service_id"; public static final String NAME = "name"; @@ -57,21 +65,59 @@ public class EndpointInventory extends RegisterSource { @Column(columnName = DETECT_POINT) private int detectPoint; - public static String buildId(int serviceId, String endpointName, int detectPoint) { - return serviceId + Const.ID_SPLIT + endpointName + Const.ID_SPLIT + detectPoint; + public static String buildId(int serviceId, String endpointName, DetectPoint detectPoint) { + return buildId(serviceId, endpointName, detectPoint.value()); + } + + public static String buildId(EndpointTraffic endpointTraffic) { + return buildId(endpointTraffic.serviceId, endpointTraffic.name, endpointTraffic.detectPoint); + } + + private static String buildId(int serviceId, String endpointName, int detectPoint) { + return serviceId + Const.ID_SPLIT + + new String( + Base64.getEncoder().encode(endpointName.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8) + + Const.ID_SPLIT + detectPoint; + } + + /** + * @param id in the storage of endpoint traffic + * @return [serviceId, endpointName, detectPoint] + */ + public static EndpointID splitID(String id) { + final String[] strings = id.split(Const.ID_PARSER_SPLIT); + if (strings.length != 3) { + throw new UnexpectedException("Can't split endpoint id into 3 parts, " + id); + } + return new EndpointID( + Integer.parseInt(strings[0]), new String(Base64.getDecoder().decode(strings[1]), StandardCharsets.UTF_8), + DetectPoint.valueOf(Integer.parseInt(strings[2])) + ); + } + + @RequiredArgsConstructor + public static class EndpointID { + @Getter + private final int serviceId; + @Getter + private final String endpointName; + @Getter + private final DetectPoint detectPoint; } @Override public String id() { - return buildId(serviceId, name, detectPoint); + // Downgrade the time bucket to day level only. + // supportDownSampling == false for this entity. + String splitJointId = String.valueOf(getTimeBucket() / 10000); + splitJointId += Const.ID_SPLIT + buildId(this); + return splitJointId; } @Override public int hashCode() { int result = 17; - result = 31 * result + serviceId; - result = 31 * result + name.hashCode(); - result = 31 * result + detectPoint; + result = 31 * result + buildId(this).hashCode(); return result; } @@ -84,7 +130,7 @@ public class EndpointInventory extends RegisterSource { if (getClass() != obj.getClass()) return false; - EndpointInventory source = (EndpointInventory) obj; + EndpointTraffic source = (EndpointTraffic) obj; if (serviceId != source.getServiceId()) return false; if (!name.equals(source.getName())) @@ -95,13 +141,10 @@ public class EndpointInventory extends RegisterSource { @Override public RemoteData.Builder serialize() { RemoteData.Builder remoteBuilder = RemoteData.newBuilder(); - remoteBuilder.addDataIntegers(getSequence()); remoteBuilder.addDataIntegers(serviceId); remoteBuilder.addDataIntegers(detectPoint); - remoteBuilder.addDataLongs(getRegisterTime()); - remoteBuilder.addDataLongs(getHeartbeatTime()); - remoteBuilder.addDataLongs(getLastUpdateTime()); + remoteBuilder.addDataLongs(getTimeBucket()); remoteBuilder.addDataStrings(Strings.isNullOrEmpty(name) ? Const.EMPTY_STRING : name); return remoteBuilder; @@ -109,47 +152,67 @@ public class EndpointInventory extends RegisterSource { @Override public void deserialize(RemoteData remoteData) { - setSequence(remoteData.getDataIntegers(0)); - setServiceId(remoteData.getDataIntegers(1)); - setDetectPoint(remoteData.getDataIntegers(2)); + setServiceId(remoteData.getDataIntegers(0)); + setDetectPoint(remoteData.getDataIntegers(1)); - setRegisterTime(remoteData.getDataLongs(0)); - setHeartbeatTime(remoteData.getDataLongs(1)); - setLastUpdateTime(remoteData.getDataLongs(2)); + setTimeBucket(remoteData.getDataLongs(0)); setName(remoteData.getDataStrings(0)); } @Override public int remoteHashCode() { - return 0; + int result = 17; + result = 31 * result + serviceId; + result = 31 * result + name.hashCode(); + result = 31 * result + detectPoint; + return result; + } + + @Override + public void combine(final Metrics metrics) { + + } + + @Override + public void calculate() { + + } + + @Override + public Metrics toHour() { + return null; + } + + @Override + public Metrics toDay() { + return null; + } + + @Override + public Metrics toMonth() { + return null; } - public static class Builder implements StorageBuilder { + public static class Builder implements StorageBuilder { @Override - public EndpointInventory map2Data(Map dbMap) { - EndpointInventory inventory = new EndpointInventory(); - inventory.setSequence(((Number) dbMap.get(SEQUENCE)).intValue()); + public EndpointTraffic map2Data(Map dbMap) { + EndpointTraffic inventory = new EndpointTraffic(); inventory.setServiceId(((Number) dbMap.get(SERVICE_ID)).intValue()); inventory.setName((String) dbMap.get(NAME)); inventory.setDetectPoint(((Number) dbMap.get(DETECT_POINT)).intValue()); - inventory.setRegisterTime(((Number) dbMap.get(REGISTER_TIME)).longValue()); - inventory.setHeartbeatTime(((Number) dbMap.get(HEARTBEAT_TIME)).longValue()); - inventory.setLastUpdateTime(((Number) dbMap.get(LAST_UPDATE_TIME)).longValue()); + inventory.setTimeBucket(((Number) dbMap.get(TIME_BUCKET)).longValue()); return inventory; } @Override - public Map data2Map(EndpointInventory storageData) { + public Map data2Map(EndpointTraffic storageData) { Map map = new HashMap<>(); - map.put(SEQUENCE, storageData.getSequence()); map.put(SERVICE_ID, storageData.getServiceId()); map.put(NAME, storageData.getName()); map.put(DETECT_POINT, storageData.getDetectPoint()); - map.put(REGISTER_TIME, storageData.getRegisterTime()); - map.put(HEARTBEAT_TIME, storageData.getHeartbeatTime()); - map.put(LAST_UPDATE_TIME, storageData.getLastUpdateTime()); + map.put(TIME_BUCKET, storageData.getTimeBucket()); return map; } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/IEndpointInventoryRegister.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTrafficDispatcher.java similarity index 50% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/IEndpointInventoryRegister.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTrafficDispatcher.java index 581f8d03e4..95db3645ae 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/IEndpointInventoryRegister.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTrafficDispatcher.java @@ -16,16 +16,26 @@ * */ -package org.apache.skywalking.oap.server.core.register.service; +package org.apache.skywalking.oap.server.core.analysis.manual.endpoint; +import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher; +import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor; import org.apache.skywalking.oap.server.core.source.DetectPoint; -import org.apache.skywalking.oap.server.library.module.Service; +import org.apache.skywalking.oap.server.core.source.Endpoint; -public interface IEndpointInventoryRegister extends Service { +public class EndpointTrafficDispatcher implements SourceDispatcher { - int getOrCreate(int serviceId, String endpointName, DetectPoint detectPoint); + @Override + public void dispatch(final Endpoint source) { + generateTraffic(source); + } - int get(int serviceId, String endpointName, DetectPoint detectPoint); - - void heartbeat(int endpointId, long heartBeatTime); + public void generateTraffic(final Endpoint source) { + EndpointTraffic traffic = new EndpointTraffic(); + traffic.setTimeBucket(source.getTimeBucket()); + traffic.setName(source.getName()); + traffic.setServiceId(source.getServiceId()); + traffic.setDetectPoint(DetectPoint.SERVER.value()); + MetricsStreamProcessor.getInstance().in(traffic); + } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointCallRelationDispatcher.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointCallRelationDispatcher.java index f72e94896f..0120eb0522 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointCallRelationDispatcher.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/endpointrelation/EndpointCallRelationDispatcher.java @@ -19,7 +19,9 @@ package org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation; import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor; +import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.core.source.EndpointRelation; public class EndpointCallRelationDispatcher implements SourceDispatcher { @@ -36,10 +38,12 @@ public class EndpointCallRelationDispatcher implements SourceDispatcher dbMap) { EndpointRelationServerSideMetrics metrics = new EndpointRelationServerSideMetrics(); - metrics.setSourceEndpointId(((Number) dbMap.get(SOURCE_ENDPOINT_ID)).intValue()); - metrics.setDestEndpointId(((Number) dbMap.get(DEST_ENDPOINT_ID)).intValue()); + metrics.setSourceEndpoint((String) dbMap.get(SOURCE_ENDPOINT)); + metrics.setDestEndpoint((String) dbMap.get(DEST_ENDPOINT)); metrics.setComponentId(((Number) dbMap.get(COMPONENT_ID)).intValue()); metrics.setTimeBucket(((Number) dbMap.get(TIME_BUCKET)).longValue()); metrics.setEntityId((String) dbMap.get(ENTITY_ID)); @@ -201,8 +191,8 @@ public class EndpointRelationServerSideMetrics extends Metrics { @Override public Map data2Map(EndpointRelationServerSideMetrics storageData) { Map map = new HashMap<>(); - map.put(SOURCE_ENDPOINT_ID, storageData.getSourceEndpointId()); - map.put(DEST_ENDPOINT_ID, storageData.getDestEndpointId()); + map.put(SOURCE_ENDPOINT, storageData.getSourceEndpoint()); + map.put(DEST_ENDPOINT, storageData.getDestEndpoint()); map.put(COMPONENT_ID, storageData.getComponentId()); map.put(TIME_BUCKET, storageData.getTimeBucket()); map.put(ENTITY_ID, storageData.getEntityId()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/log/AbstractLogRecord.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/log/AbstractLogRecord.java index a11b53e255..a35da2ba06 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/log/AbstractLogRecord.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/log/AbstractLogRecord.java @@ -32,6 +32,7 @@ public abstract class AbstractLogRecord extends Record { public static final String SERVICE_ID = "service_id"; public static final String SERVICE_INSTANCE_ID = "service_instance_id"; + public static final String ENDPOINT_NAME = "endpoint_name"; public static final String ENDPOINT_ID = "endpoint_id"; public static final String TRACE_ID = "trace_id"; public static final String IS_ERROR = "is_error"; @@ -51,7 +52,11 @@ public abstract class AbstractLogRecord extends Record { @Setter @Getter @Column(columnName = ENDPOINT_ID) - private int endpointId; + private String endpointId; + @Setter + @Getter + @Column(columnName = ENDPOINT_NAME) + private String endpointName; @Setter @Getter @Column(columnName = TRACE_ID) @@ -86,7 +91,8 @@ public abstract class AbstractLogRecord extends Record { protected void map2Data(T record, Map dbMap) { record.setServiceId(((Number) dbMap.get(SERVICE_ID)).intValue()); record.setServiceInstanceId(((Number) dbMap.get(SERVICE_INSTANCE_ID)).intValue()); - record.setEndpointId(((Number) dbMap.get(ENDPOINT_ID)).intValue()); + record.setEndpointId((String) dbMap.get(ENDPOINT_ID)); + record.setEndpointName((String) dbMap.get(ENDPOINT_NAME)); record.setIsError(((Number) dbMap.get(IS_ERROR)).intValue()); record.setTraceId((String) dbMap.get(TRACE_ID)); record.setStatusCode((String) dbMap.get(STATUS_CODE)); @@ -102,6 +108,7 @@ public abstract class AbstractLogRecord extends Record { map.put(SERVICE_ID, record.getServiceId()); map.put(SERVICE_INSTANCE_ID, record.getServiceInstanceId()); map.put(ENDPOINT_ID, record.getEndpointId()); + map.put(ENDPOINT_NAME, record.getEndpointName()); map.put(TRACE_ID, record.getTraceId()); map.put(IS_ERROR, record.getIsError()); map.put(STATUS_CODE, record.getStatusCode()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/log/HTTPAccessLogDispatcher.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/log/HTTPAccessLogDispatcher.java index f92eced2d4..0bbde3fbec 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/log/HTTPAccessLogDispatcher.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/log/HTTPAccessLogDispatcher.java @@ -32,6 +32,7 @@ public class HTTPAccessLogDispatcher implements SourceDispatcher record.setServiceId(source.getServiceId()); record.setServiceInstanceId(source.getServiceInstanceId()); record.setEndpointId(source.getEndpointId()); + record.setEndpointName(source.getEndpointName()); record.setTraceId(source.getTraceId()); record.setIsError(source.getIsError()); record.setStatusCode(source.getStatusCode()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/relation/service/ServiceRelationClientSideMetrics.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/relation/service/ServiceRelationClientSideMetrics.java index 7782d59c99..cee1d36fd0 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/relation/service/ServiceRelationClientSideMetrics.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/relation/service/ServiceRelationClientSideMetrics.java @@ -71,10 +71,8 @@ public class ServiceRelationClientSideMetrics extends Metrics { } public void buildEntityId() { - String splitJointId = String.valueOf(sourceServiceId); - splitJointId += Const.ID_SPLIT + String.valueOf(destServiceId); - splitJointId += Const.ID_SPLIT + String.valueOf(componentId); - entityId = splitJointId; + entityId = RelationDefineUtil.buildEntityId( + new RelationDefineUtil.RelationDefine(sourceServiceId, destServiceId, componentId)); } @Override diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/relation/service/ServiceRelationServerSideMetrics.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/relation/service/ServiceRelationServerSideMetrics.java index bb2a562b52..52c175b921 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/relation/service/ServiceRelationServerSideMetrics.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/relation/service/ServiceRelationServerSideMetrics.java @@ -66,15 +66,14 @@ public class ServiceRelationServerSideMetrics extends Metrics { @Override public String id() { String splitJointId = String.valueOf(getTimeBucket()); - splitJointId += Const.ID_SPLIT + RelationDefineUtil.buildEntityId(new RelationDefineUtil.RelationDefine(sourceServiceId, destServiceId, componentId)); + splitJointId += Const.ID_SPLIT + RelationDefineUtil.buildEntityId( + new RelationDefineUtil.RelationDefine(sourceServiceId, destServiceId, componentId)); return splitJointId; } public void buildEntityId() { - String splitJointId = String.valueOf(sourceServiceId); - splitJointId += Const.ID_SPLIT + String.valueOf(destServiceId); - splitJointId += Const.ID_SPLIT + String.valueOf(componentId); - entityId = splitJointId; + entityId = RelationDefineUtil.buildEntityId( + new RelationDefineUtil.RelationDefine(sourceServiceId, destServiceId, componentId)); } @Override diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/segment/SegmentRecord.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/segment/SegmentRecord.java index b5f94ccf0c..a36e69cf26 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/segment/SegmentRecord.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/segment/SegmentRecord.java @@ -73,7 +73,7 @@ public class SegmentRecord extends Record { @Setter @Getter @Column(columnName = ENDPOINT_ID) - private int endpointId; + private String endpointId; @Setter @Getter @Column(columnName = START_TIME) @@ -137,7 +137,7 @@ public class SegmentRecord extends Record { record.setServiceId(((Number) dbMap.get(SERVICE_ID)).intValue()); record.setServiceInstanceId(((Number) dbMap.get(SERVICE_INSTANCE_ID)).intValue()); record.setEndpointName((String) dbMap.get(ENDPOINT_NAME)); - record.setEndpointId(((Number) dbMap.get(ENDPOINT_ID)).intValue()); + record.setEndpointId((String) dbMap.get(ENDPOINT_ID)); record.setStartTime(((Number) dbMap.get(START_TIME)).longValue()); record.setEndTime(((Number) dbMap.get(END_TIME)).longValue()); record.setLatency(((Number) dbMap.get(LATENCY)).intValue()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsStreamProcessor.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsStreamProcessor.java index 54c28612d2..6f4f6084c9 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsStreamProcessor.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsStreamProcessor.java @@ -113,24 +113,27 @@ public class MetricsStreamProcessor implements StreamProcessor { MetricsPersistentWorker dayPersistentWorker = null; MetricsPersistentWorker monthPersistentWorker = null; - if (configService.shouldToHour()) { - Model model = modelSetter.putIfAbsent( - metricsClass, stream.scopeId(), new Storage(stream.name(), true, true, Downsampling.Hour), false); - hourPersistentWorker = worker(moduleDefineHolder, metricsDAO, model); + MetricsTransWorker transWorker = null; + if (stream.supportDownSampling()) { + if (configService.shouldToHour()) { + Model model = modelSetter.putIfAbsent( + metricsClass, stream.scopeId(), new Storage(stream.name(), true, true, Downsampling.Hour), false); + hourPersistentWorker = worker(moduleDefineHolder, metricsDAO, model); + } + if (configService.shouldToDay()) { + Model model = modelSetter.putIfAbsent( + metricsClass, stream.scopeId(), new Storage(stream.name(), true, true, Downsampling.Day), false); + dayPersistentWorker = worker(moduleDefineHolder, metricsDAO, model); + } + if (configService.shouldToMonth()) { + Model model = modelSetter.putIfAbsent( + metricsClass, stream.scopeId(), new Storage(stream.name(), true, true, Downsampling.Month), false); + monthPersistentWorker = worker(moduleDefineHolder, metricsDAO, model); + } + + transWorker = new MetricsTransWorker( + moduleDefineHolder, stream.name(), hourPersistentWorker, dayPersistentWorker, monthPersistentWorker); } - if (configService.shouldToDay()) { - Model model = modelSetter.putIfAbsent( - metricsClass, stream.scopeId(), new Storage(stream.name(), true, true, Downsampling.Day), false); - dayPersistentWorker = worker(moduleDefineHolder, metricsDAO, model); - } - if (configService.shouldToMonth()) { - Model model = modelSetter.putIfAbsent( - metricsClass, stream.scopeId(), new Storage(stream.name(), true, true, Downsampling.Month), false); - monthPersistentWorker = worker(moduleDefineHolder, metricsDAO, model); - } - - MetricsTransWorker transWorker = new MetricsTransWorker( - moduleDefineHolder, stream.name(), hourPersistentWorker, dayPersistentWorker, monthPersistentWorker); Model model = modelSetter.putIfAbsent( metricsClass, stream.scopeId(), new Storage(stream.name(), true, true, Downsampling.Minute), false); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cache/EndpointInventoryCache.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cache/EndpointInventoryCache.java deleted file mode 100644 index 4181a5151f..0000000000 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cache/EndpointInventoryCache.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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.cache; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import java.util.Objects; -import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.CoreModuleConfig; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; -import org.apache.skywalking.oap.server.core.storage.StorageModule; -import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; -import org.apache.skywalking.oap.server.library.module.ModuleManager; -import org.apache.skywalking.oap.server.library.module.Service; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static java.util.Objects.isNull; -import static java.util.Objects.nonNull; - -public class EndpointInventoryCache implements Service { - - private static final Logger logger = LoggerFactory.getLogger(EndpointInventoryCache.class); - - private final ModuleManager moduleManager; - private final EndpointInventory userEndpoint; - private final Cache endpointNameCache; - private final Cache endpointIdCache; - - private IEndpointInventoryCacheDAO cacheDAO; - - public EndpointInventoryCache(ModuleManager moduleManager, CoreModuleConfig moduleConfig) { - this.moduleManager = moduleManager; - - this.userEndpoint = new EndpointInventory(); - this.userEndpoint.setSequence(Const.USER_ENDPOINT_ID); - this.userEndpoint.setName(Const.USER_CODE); - this.userEndpoint.setServiceId(Const.USER_SERVICE_ID); - - long initialSize = moduleConfig.getMaxSizeOfEndpointInventory() / 10L; - int initialCapacitySize = (int) (initialSize > Integer.MAX_VALUE ? Integer.MAX_VALUE : initialSize); - - endpointNameCache = CacheBuilder.newBuilder() - .initialCapacity(initialCapacitySize) - .maximumSize(moduleConfig.getMaxSizeOfEndpointInventory()) - .build(); - endpointIdCache = CacheBuilder.newBuilder() - .initialCapacity(initialCapacitySize) - .maximumSize(moduleConfig.getMaxSizeOfEndpointInventory()) - .build(); - } - - private IEndpointInventoryCacheDAO getCacheDAO() { - if (isNull(cacheDAO)) { - cacheDAO = moduleManager.find(StorageModule.NAME).provider().getService(IEndpointInventoryCacheDAO.class); - } - return cacheDAO; - } - - public int getEndpointId(int serviceId, String endpointName, int detectPoint) { - String id = EndpointInventory.buildId(serviceId, endpointName, detectPoint); - - Integer endpointId = endpointNameCache.getIfPresent(id); - - if (Objects.isNull(endpointId) || endpointId == Const.NONE) { - endpointId = getCacheDAO().getEndpointId(serviceId, endpointName, detectPoint); - if (endpointId != Const.NONE) { - endpointNameCache.put(id, endpointId); - } - } - return endpointId; - } - - public EndpointInventory get(int endpointId) { - if (Const.USER_ENDPOINT_ID == endpointId) { - return userEndpoint; - } - - EndpointInventory endpointInventory = endpointIdCache.getIfPresent(endpointId); - - if (isNull(endpointInventory)) { - endpointInventory = getCacheDAO().get(endpointId); - if (nonNull(endpointInventory)) { - endpointIdCache.put(endpointId, endpointInventory); - } else { - logger.warn("EndpointInventory id {} is not in cache and persistent storage.", endpointId); - } - } - - return endpointInventory; - } -} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AggregationQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AggregationQueryService.java index 7c8d644ac2..b0bf8e2209 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AggregationQueryService.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AggregationQueryService.java @@ -22,12 +22,11 @@ import java.io.IOException; import java.util.List; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.analysis.Downsampling; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.query.entity.Order; import org.apache.skywalking.oap.server.core.query.entity.TopNEntity; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; import org.apache.skywalking.oap.server.core.register.ServiceInventory; import org.apache.skywalking.oap.server.core.storage.StorageModule; @@ -55,8 +54,9 @@ public class AggregationQueryService implements Service { } public List getServiceTopN(final String indName, final int topN, final Downsampling downsampling, - final long startTB, final long endTB, final Order order) throws IOException { - List topNEntities = getAggregationQueryDAO().getServiceTopN(indName, ValueColumnMetadata.INSTANCE.getValueCName(indName), topN, downsampling, startTB, endTB, order); + final long startTB, final long endTB, final Order order) throws IOException { + List topNEntities = getAggregationQueryDAO().getServiceTopN( + indName, ValueColumnMetadata.INSTANCE.getValueCName(indName), topN, downsampling, startTB, endTB, order); for (TopNEntity entity : topNEntities) { ServiceInventory inventory = moduleManager.find(CoreModule.NAME) .provider() @@ -69,10 +69,15 @@ public class AggregationQueryService implements Service { return topNEntities; } - public List getAllServiceInstanceTopN(final String indName, final int topN, - final Downsampling downsampling, final long startTB, final long endTB, final Order order) throws IOException { - List topNEntities = getAggregationQueryDAO().getAllServiceInstanceTopN(indName, ValueColumnMetadata.INSTANCE - .getValueCName(indName), topN, downsampling, startTB, endTB, order); + public List getAllServiceInstanceTopN(final String indName, + final int topN, + final Downsampling downsampling, + final long startTB, + final long endTB, + final Order order) throws IOException { + List topNEntities = getAggregationQueryDAO().getAllServiceInstanceTopN( + indName, ValueColumnMetadata.INSTANCE + .getValueCName(indName), topN, downsampling, startTB, endTB, order); for (TopNEntity entity : topNEntities) { ServiceInstanceInventory inventory = moduleManager.find(CoreModule.NAME) .provider() @@ -85,10 +90,16 @@ public class AggregationQueryService implements Service { return topNEntities; } - public List getServiceInstanceTopN(final int serviceId, final String indName, final int topN, - final Downsampling downsampling, final long startTB, final long endTB, final Order order) throws IOException { - List topNEntities = getAggregationQueryDAO().getServiceInstanceTopN(serviceId, indName, ValueColumnMetadata.INSTANCE - .getValueCName(indName), topN, downsampling, startTB, endTB, order); + public List getServiceInstanceTopN(final int serviceId, + final String indName, + final int topN, + final Downsampling downsampling, + final long startTB, + final long endTB, + final Order order) throws IOException { + List topNEntities = getAggregationQueryDAO().getServiceInstanceTopN( + serviceId, indName, ValueColumnMetadata.INSTANCE + .getValueCName(indName), topN, downsampling, startTB, endTB, order); for (TopNEntity entity : topNEntities) { ServiceInstanceInventory inventory = moduleManager.find(CoreModule.NAME) .provider() @@ -101,33 +112,33 @@ public class AggregationQueryService implements Service { return topNEntities; } - public List getAllEndpointTopN(final String indName, final int topN, final Downsampling downsampling, - final long startTB, final long endTB, final Order order) throws IOException { - List topNEntities = getAggregationQueryDAO().getAllEndpointTopN(indName, ValueColumnMetadata.INSTANCE.getValueCName(indName), topN, downsampling, startTB, endTB, order); + public List getAllEndpointTopN(final String indName, + final int topN, + final Downsampling downsampling, + final long startTB, + final long endTB, + final Order order) throws IOException { + List topNEntities = getAggregationQueryDAO().getAllEndpointTopN( + indName, ValueColumnMetadata.INSTANCE.getValueCName(indName), topN, downsampling, startTB, endTB, order); + for (TopNEntity entity : topNEntities) { - EndpointInventory inventory = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class) - .get(Integer.parseInt(entity.getId())); - if (inventory != null) { - entity.setName(inventory.getName()); - } + entity.setName(EndpointTraffic.splitID(entity.getId()).getEndpointName()); } return topNEntities; } - public List getEndpointTopN(final int serviceId, final String indName, final int topN, - final Downsampling downsampling, final long startTB, final long endTB, final Order order) throws IOException { - List topNEntities = getAggregationQueryDAO().getEndpointTopN(serviceId, indName, ValueColumnMetadata.INSTANCE - .getValueCName(indName), topN, downsampling, startTB, endTB, order); + public List getEndpointTopN(final int serviceId, + final String indName, + final int topN, + final Downsampling downsampling, + final long startTB, + final long endTB, + final Order order) throws IOException { + List topNEntities = getAggregationQueryDAO().getEndpointTopN( + serviceId, indName, ValueColumnMetadata.INSTANCE + .getValueCName(indName), topN, downsampling, startTB, endTB, order); for (TopNEntity entity : topNEntities) { - EndpointInventory inventory = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class) - .get(Integer.parseInt(entity.getId())); - if (inventory != null) { - entity.setName(inventory.getName()); - } + entity.setName(EndpointTraffic.splitID(entity.getId()).getEndpointName()); } return topNEntities; } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java index 13b8631512..1444a76b9d 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java @@ -21,7 +21,6 @@ package org.apache.skywalking.oap.server.core.query; import java.io.IOException; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.CoreModule; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.query.entity.LogState; @@ -38,7 +37,6 @@ public class LogQueryService implements Service { private ILogQueryDAO logQueryDAO; private ServiceInventoryCache serviceInventoryCache; private ServiceInstanceInventoryCache serviceInstanceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; public LogQueryService(ModuleManager moduleManager) { this.moduleManager = moduleManager; @@ -69,21 +67,21 @@ public class LogQueryService implements Service { return serviceInstanceInventoryCache; } - private EndpointInventoryCache getEndpointInventoryCache() { - if (endpointInventoryCache == null) { - this.endpointInventoryCache = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class); - } - return endpointInventoryCache; - } - - public Logs queryLogs(final String metricName, int serviceId, int serviceInstanceId, int endpointId, String traceId, - LogState state, String stateCode, Pagination paging, final long startTB, final long endTB) throws IOException { + public Logs queryLogs(final String metricName, + int serviceId, + int serviceInstanceId, + String endpointId, + String traceId, + LogState state, + String stateCode, + Pagination paging, + final long startTB, + final long endTB) throws IOException { PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(paging); - Logs logs = getLogQueryDAO().queryLogs(metricName, serviceId, serviceInstanceId, endpointId, traceId, state, stateCode, paging, page - .getFrom(), page.getLimit(), startTB, endTB); + Logs logs = getLogQueryDAO().queryLogs( + metricName, serviceId, serviceInstanceId, endpointId, traceId, state, stateCode, paging, page + .getFrom(), page.getLimit(), startTB, endTB); logs.getLogs().forEach(log -> { if (log.getServiceId() != Const.NONE) { log.setServiceName(getServiceInventoryCache().get(log.getServiceId()).getName()); @@ -92,9 +90,7 @@ public class LogQueryService implements Service { log.setServiceInstanceName(getServiceInstanceInventoryCache().get(log.getServiceInstanceId()) .getName()); } - if (log.getEndpointId() != Const.NONE) { - log.setEndpointName(getEndpointInventoryCache().get(log.getEndpointId()).getName()); - } + log.setEndpointId(log.getEndpointId()); }); return logs; } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetadataQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetadataQueryService.java index bae70a7bc3..28af1e5f27 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetadataQueryService.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetadataQueryService.java @@ -21,7 +21,7 @@ package org.apache.skywalking.oap.server.core.query; import java.io.IOException; import java.util.List; import org.apache.skywalking.oap.server.core.CoreModule; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.query.entity.ClusterBrief; import org.apache.skywalking.oap.server.core.query.entity.Database; @@ -29,7 +29,6 @@ import org.apache.skywalking.oap.server.core.query.entity.Endpoint; import org.apache.skywalking.oap.server.core.query.entity.EndpointInfo; import org.apache.skywalking.oap.server.core.query.entity.Service; import org.apache.skywalking.oap.server.core.query.entity.ServiceInstance; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; import org.apache.skywalking.oap.server.core.register.NodeType; import org.apache.skywalking.oap.server.core.storage.StorageModule; import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO; @@ -40,7 +39,6 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li private final ModuleManager moduleManager; private IMetadataQueryDAO metadataQueryDAO; private ServiceInventoryCache serviceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; public MetadataQueryService(ModuleManager moduleManager) { this.moduleManager = moduleManager; @@ -62,15 +60,6 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li return serviceInventoryCache; } - private EndpointInventoryCache getEndpointInventoryCache() { - if (endpointInventoryCache == null) { - endpointInventoryCache = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class); - } - return endpointInventoryCache; - } - public ClusterBrief getGlobalBrief(final long startTimestamp, final long endTimestamp) throws IOException { ClusterBrief clusterBrief = new ClusterBrief(); clusterBrief.setNumOfService(getMetadataQueryDAO().numOfService(startTimestamp, endTimestamp)); @@ -94,17 +83,17 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li } public List searchServices(final long startTimestamp, final long endTimestamp, - final String keyword) throws IOException { + final String keyword) throws IOException { return getMetadataQueryDAO().searchServices(startTimestamp, endTimestamp, keyword); } public List getServiceInstances(final long startTimestamp, final long endTimestamp, - final String serviceId) throws IOException { + final String serviceId) throws IOException { return getMetadataQueryDAO().getServiceInstances(startTimestamp, endTimestamp, serviceId); } - public List searchEndpoint(final String keyword, final String serviceId, - final int limit) throws IOException { + public List searchEndpoint(final String keyword, final int serviceId, + final int limit) throws IOException { return getMetadataQueryDAO().searchEndpoint(keyword, serviceId, limit); } @@ -112,14 +101,15 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li return getMetadataQueryDAO().searchService(serviceCode); } - public EndpointInfo getEndpointInfo(final int endpointId) throws IOException { - EndpointInventory endpointInventory = getEndpointInventoryCache().get(endpointId); + public EndpointInfo getEndpointInfo(final String endpointId) throws IOException { + final EndpointTraffic.EndpointID endpointID = EndpointTraffic.splitID(endpointId); + int serviceId = endpointID.getServiceId(); EndpointInfo endpointInfo = new EndpointInfo(); - endpointInfo.setId(endpointInventory.getSequence()); - endpointInfo.setName(endpointInventory.getName()); - endpointInfo.setServiceId(endpointInventory.getServiceId()); - endpointInfo.setServiceName(getServiceInventoryCache().get(endpointInventory.getServiceId()).getName()); + endpointInfo.setId(endpointId); + endpointInfo.setName(endpointID.getEndpointName()); + endpointInfo.setServiceId(serviceId); + endpointInfo.setServiceName(getServiceInventoryCache().get(serviceId).getName()); return endpointInfo; } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java index 156e88f33f..dcc10e846a 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ProfileTaskQueryService.java @@ -24,13 +24,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; - import org.apache.skywalking.apm.network.language.agent.v2.SegmentObject; -import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.CoreModuleConfig; import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.NetworkAddressInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; @@ -45,7 +42,6 @@ import org.apache.skywalking.oap.server.core.query.entity.ProfileTask; import org.apache.skywalking.oap.server.core.query.entity.ProfileTaskLog; import org.apache.skywalking.oap.server.core.query.entity.ProfiledSegment; import org.apache.skywalking.oap.server.core.query.entity.ProfiledSpan; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; import org.apache.skywalking.oap.server.core.register.ServiceInventory; import org.apache.skywalking.oap.server.core.storage.StorageModule; @@ -57,7 +53,6 @@ import org.apache.skywalking.oap.server.library.module.Service; import org.apache.skywalking.oap.server.library.util.CollectionUtils; import static java.util.Objects.isNull; -import static java.util.Objects.nonNull; /** * handle profile task queries @@ -71,13 +66,15 @@ public class ProfileTaskQueryService implements Service { private ServiceInstanceInventoryCache serviceInstanceInventoryCache; private NetworkAddressInventoryCache networkAddressInventoryCache; private IComponentLibraryCatalogService componentLibraryCatalogService; - private EndpointInventoryCache endpointInventoryCache; private final ProfileAnalyzer profileAnalyzer; public ProfileTaskQueryService(ModuleManager moduleManager, CoreModuleConfig moduleConfig) { this.moduleManager = moduleManager; - this.profileAnalyzer = new ProfileAnalyzer(moduleManager, moduleConfig.getMaxPageSizeOfQueryProfileSnapshot(), moduleConfig.getMaxSizeOfAnalyzeProfileSnapshot()); + this.profileAnalyzer = new ProfileAnalyzer( + moduleManager, moduleConfig.getMaxPageSizeOfQueryProfileSnapshot(), + moduleConfig.getMaxSizeOfAnalyzeProfileSnapshot() + ); } private IProfileTaskQueryDAO getProfileTaskDAO() { @@ -143,15 +140,6 @@ public class ProfileTaskQueryService implements Service { return componentLibraryCatalogService; } - private EndpointInventoryCache getEndpointInventoryCache() { - if (endpointInventoryCache == null) { - this.endpointInventoryCache = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class); - } - return endpointInventoryCache; - } - /** * search profile task list * @@ -180,7 +168,8 @@ public class ProfileTaskQueryService implements Service { // filter all task logs task.setLogs(taskLogList.stream().filter(l -> Objects.equal(l.getTaskId(), task.getId())).map(l -> { // get instance name from cache - final ServiceInstanceInventory instanceInventory = serviceInstanceInventoryCache.get(l.getInstanceId()); + final ServiceInstanceInventory instanceInventory = serviceInstanceInventoryCache.get( + l.getInstanceId()); if (instanceInventory != null) { l.setInstanceName(instanceInventory.getName()); } @@ -199,7 +188,8 @@ public class ProfileTaskQueryService implements Service { return getProfileThreadSnapshotQueryDAO().queryProfiledSegments(taskId); } - public ProfileAnalyzation getProfileAnalyze(final String segmentId, final List timeRanges) throws IOException { + public ProfileAnalyzation getProfileAnalyze(final String segmentId, + final List timeRanges) throws IOException { return profileAnalyzer.analyze(segmentId, timeRanges); } @@ -228,6 +218,7 @@ public class ProfileTaskQueryService implements Service { span.setError(spanObject.getIsError()); span.setLayer(spanObject.getSpanLayer().name()); span.setType(spanObject.getSpanType().name()); + span.setEndpointName(spanObject.getOperationName()); if (spanObject.getPeerId() == 0) { span.setPeer(spanObject.getPeer()); @@ -235,17 +226,6 @@ public class ProfileTaskQueryService implements Service { span.setPeer(getNetworkAddressInventoryCache().get(spanObject.getPeerId()).getName()); } - String endpointName = spanObject.getOperationName(); - if (spanObject.getOperationNameId() != 0) { - EndpointInventory endpointInventory = getEndpointInventoryCache().get(spanObject.getOperationNameId()); - if (nonNull(endpointInventory)) { - endpointName = endpointInventory.getName(); - } else { - endpointName = Const.EMPTY_STRING; - } - } - span.setEndpointName(endpointName); - final ServiceInventory serviceInventory = getServiceInventoryCache().get(segmentObject.getServiceId()); if (serviceInventory != null) { span.setServiceCode(serviceInventory.getName()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ServiceInstanceTopologyBuilder.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ServiceInstanceTopologyBuilder.java index 486f486e19..895b725f1f 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ServiceInstanceTopologyBuilder.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/ServiceInstanceTopologyBuilder.java @@ -60,16 +60,14 @@ public class ServiceInstanceTopologyBuilder { ServiceInstanceTopology build(List serviceInstanceRelationClientCalls, List serviceInstanceRelationServerCalls) { - filterZeroSourceOrTargetReference(serviceInstanceRelationClientCalls); - filterZeroSourceOrTargetReference(serviceInstanceRelationServerCalls); Map nodes = new HashMap<>(); List calls = new LinkedList<>(); HashMap callMap = new HashMap<>(); for (Call.CallDetail clientCall : serviceInstanceRelationClientCalls) { - ServiceInstanceInventory sourceInstance = serviceInstanceInventoryCache.get(clientCall.getSource()); - ServiceInstanceInventory targetInstance = serviceInstanceInventoryCache.get(clientCall.getTarget()); + ServiceInstanceInventory sourceInstance = serviceInstanceInventoryCache.get(Integer.parseInt(clientCall.getSource())); + ServiceInstanceInventory targetInstance = serviceInstanceInventoryCache.get(Integer.parseInt(clientCall.getTarget())); if (isNull(sourceInstance) || isNull(targetInstance)) { continue; @@ -113,8 +111,8 @@ public class ServiceInstanceTopologyBuilder { } for (Call.CallDetail serverCall : serviceInstanceRelationServerCalls) { - ServiceInstanceInventory sourceInstance = serviceInstanceInventoryCache.get(serverCall.getSource()); - ServiceInstanceInventory targetInstance = serviceInstanceInventoryCache.get(serverCall.getTarget()); + ServiceInstanceInventory sourceInstance = serviceInstanceInventoryCache.get(Integer.parseInt(serverCall.getSource())); + ServiceInstanceInventory targetInstance = serviceInstanceInventoryCache.get(Integer.parseInt(serverCall.getTarget())); if (isNull(sourceInstance) || isNull(targetInstance)) { continue; @@ -202,13 +200,4 @@ public class ServiceInstanceTopologyBuilder { } return instanceNode; } - - private void filterZeroSourceOrTargetReference(List serviceRelationClientCalls) { - for (int i = serviceRelationClientCalls.size() - 1; i >= 0; i--) { - Call.CallDetail call = serviceRelationClientCalls.get(i); - if (call.getSource() == 0 || call.getTarget() == 0) { - serviceRelationClientCalls.remove(i); - } - } - } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyBuilder.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyBuilder.java index 8aeb8ad11b..2c6ad73374 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyBuilder.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyBuilder.java @@ -55,16 +55,14 @@ class TopologyBuilder { } Topology build(List serviceRelationClientCalls, List serviceRelationServerCalls) { - filterZeroSourceOrTargetReference(serviceRelationClientCalls); - filterZeroSourceOrTargetReference(serviceRelationServerCalls); Map nodes = new HashMap<>(); List calls = new LinkedList<>(); HashMap callMap = new HashMap<>(); for (Call.CallDetail clientCall : serviceRelationClientCalls) { - ServiceInventory source = serviceInventoryCache.get(clientCall.getSource()); - ServiceInventory target = serviceInventoryCache.get(clientCall.getTarget()); + ServiceInventory source = serviceInventoryCache.get(Integer.parseInt(clientCall.getSource())); + ServiceInventory target = serviceInventoryCache.get(Integer.parseInt(clientCall.getTarget())); if (isNull(source) || isNull(target)) { continue; @@ -107,8 +105,8 @@ class TopologyBuilder { } for (Call.CallDetail serverCall : serviceRelationServerCalls) { - ServiceInventory source = serviceInventoryCache.get(serverCall.getSource()); - ServiceInventory target = serviceInventoryCache.get(serverCall.getTarget()); + ServiceInventory source = serviceInventoryCache.get(Integer.parseInt(serverCall.getSource())); + ServiceInventory target = serviceInventoryCache.get(Integer.parseInt(serverCall.getTarget())); if (isNull(source) || isNull(target)) { continue; @@ -117,7 +115,7 @@ class TopologyBuilder { if (source.getSequence() == Const.USER_SERVICE_ID) { if (!nodes.containsKey(source.getSequence())) { Node visualUserNode = new Node(); - visualUserNode.setId(source.getSequence()); + visualUserNode.setId(String.valueOf(source.getSequence())); visualUserNode.setName(Const.USER_CODE); visualUserNode.setType(Const.USER_CODE.toUpperCase()); visualUserNode.setReal(false); @@ -128,7 +126,7 @@ class TopologyBuilder { if (BooleanUtils.valueToBoolean(source.getIsAddress())) { if (!nodes.containsKey(source.getSequence())) { Node conjecturalNode = new Node(); - conjecturalNode.setId(source.getSequence()); + conjecturalNode.setId(String.valueOf(source.getSequence())); conjecturalNode.setName(source.getName()); conjecturalNode.setType( componentLibraryCatalogService.getServerNameBasedOnComponent(serverCall.getComponentId())); @@ -178,7 +176,7 @@ class TopologyBuilder { private Node buildNode(ServiceInventory serviceInventory) { Node serviceNode = new Node(); - serviceNode.setId(serviceInventory.getSequence()); + serviceNode.setId(String.valueOf(serviceInventory.getSequence())); serviceNode.setName(serviceInventory.getName()); if (BooleanUtils.valueToBoolean(serviceInventory.getIsAddress())) { serviceNode.setReal(false); @@ -187,13 +185,4 @@ class TopologyBuilder { } return serviceNode; } - - private void filterZeroSourceOrTargetReference(List serviceRelationClientCalls) { - for (int i = serviceRelationClientCalls.size() - 1; i >= 0; i--) { - Call.CallDetail call = serviceRelationClientCalls.get(i); - if (call.getSource() == 0 || call.getTarget() == 0) { - serviceRelationClientCalls.remove(i); - } - } - } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java index 980a577f0f..c5db93b889 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java @@ -27,7 +27,7 @@ import java.util.Set; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.analysis.Downsampling; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogService; import org.apache.skywalking.oap.server.core.query.entity.Call; import org.apache.skywalking.oap.server.core.query.entity.Node; @@ -50,7 +50,6 @@ public class TopologyQueryService implements Service { private final ModuleManager moduleManager; private ITopologyQueryDAO topologyQueryDAO; private IMetadataQueryDAO metadataQueryDAO; - private EndpointInventoryCache endpointInventoryCache; private IComponentLibraryCatalogService componentLibraryCatalogService; public TopologyQueryService(ModuleManager moduleManager) { @@ -80,15 +79,6 @@ public class TopologyQueryService implements Service { return componentLibraryCatalogService; } - private EndpointInventoryCache getEndpointInventoryCache() { - if (endpointInventoryCache == null) { - endpointInventoryCache = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class); - } - return endpointInventoryCache; - } - public Topology getGlobalTopology(final Downsampling downsampling, final long startTB, final long endTB) throws IOException { logger.debug("Downsampling: {}, startTimeBucket: {}, endTimeBucket: {}", downsampling, startTB, endTB); @@ -121,7 +111,7 @@ public class TopologyQueryService implements Service { // Client side relationships exclude the given services(#serviceIds) // The given services(#serviceIds)'s component names have been included inside `serviceRelationServerCalls` if (!serviceIds.contains(call.getSource())) { - outScopeSourceServiceIds.add(call.getSource()); + outScopeSourceServiceIds.add(Integer.parseInt(call.getSource())); } }); if (CollectionUtils.isNotEmpty(outScopeSourceServiceIds)) { @@ -131,7 +121,7 @@ public class TopologyQueryService implements Service { topology.getNodes().forEach(node -> { if (Strings.isNullOrEmpty(node.getType())) { for (Call.CallDetail call : sourceCalls) { - if (node.getId() == call.getTarget()) { + if (node.getId().equals(call.getTarget())) { node.setType(getComponentLibraryCatalogService().getComponentName(call.getComponentId())); break; } @@ -163,7 +153,7 @@ public class TopologyQueryService implements Service { } public Topology getEndpointTopology(final Downsampling downsampling, final long startTB, final long endTB, - final int endpointId) throws IOException { + final String endpointId) throws IOException { List serverSideCalls = getTopologyQueryDAO().loadSpecifiedDestOfServerSideEndpointRelations( downsampling, startTB, endTB, endpointId); @@ -177,7 +167,7 @@ public class TopologyQueryService implements Service { topology.getCalls().add(call); }); - Set nodeIds = new HashSet<>(); + Set nodeIds = new HashSet<>(); serverSideCalls.forEach(call -> { if (!nodeIds.contains(call.getSource())) { topology.getNodes().add(buildEndpointNode(call.getSource())); @@ -192,10 +182,11 @@ public class TopologyQueryService implements Service { return topology; } - private Node buildEndpointNode(int endpointId) { + private Node buildEndpointNode(String endpointId) { Node node = new Node(); node.setId(endpointId); - node.setName(getEndpointInventoryCache().get(endpointId).getName()); + final EndpointTraffic.EndpointID endpointID = EndpointTraffic.splitID(endpointId); + node.setName(endpointID.getEndpointName()); node.setType(Const.EMPTY_STRING); node.setReal(true); return node; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java index a04347c8cd..940938bef2 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java @@ -30,7 +30,6 @@ import org.apache.skywalking.apm.network.language.agent.v2.SpanObjectV2; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.NetworkAddressInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogService; @@ -44,7 +43,6 @@ import org.apache.skywalking.oap.server.core.query.entity.Span; import org.apache.skywalking.oap.server.core.query.entity.Trace; import org.apache.skywalking.oap.server.core.query.entity.TraceBrief; import org.apache.skywalking.oap.server.core.query.entity.TraceState; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; import org.apache.skywalking.oap.server.core.register.ServiceInventory; import org.apache.skywalking.oap.server.core.storage.StorageModule; import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO; @@ -59,7 +57,6 @@ public class TraceQueryService implements Service { private final ModuleManager moduleManager; private ITraceQueryDAO traceQueryDAO; private ServiceInventoryCache serviceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; private NetworkAddressInventoryCache networkAddressInventoryCache; private IComponentLibraryCatalogService componentLibraryCatalogService; @@ -83,15 +80,6 @@ public class TraceQueryService implements Service { return serviceInventoryCache; } - private EndpointInventoryCache getEndpointInventoryCache() { - if (endpointInventoryCache == null) { - this.endpointInventoryCache = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class); - } - return endpointInventoryCache; - } - private NetworkAddressInventoryCache getNetworkAddressInventoryCache() { if (networkAddressInventoryCache == null) { this.networkAddressInventoryCache = moduleManager.find(CoreModule.NAME) @@ -110,14 +98,25 @@ public class TraceQueryService implements Service { return componentLibraryCatalogService; } - public TraceBrief queryBasicTraces(final int serviceId, final int serviceInstanceId, final int endpointId, - final String traceId, final String endpointName, final int minTraceDuration, int maxTraceDuration, - final TraceState traceState, final QueryOrder queryOrder, final Pagination paging, final long startTB, - final long endTB) throws IOException { + public TraceBrief queryBasicTraces(final int serviceId, + final int serviceInstanceId, + final String endpointId, + final String traceId, + final String endpointName, + final int minTraceDuration, + int maxTraceDuration, + final TraceState traceState, + final QueryOrder queryOrder, + final Pagination paging, + final long startTB, + final long endTB) throws IOException { PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(paging); - return getTraceQueryDAO().queryBasicTraces(startTB, endTB, minTraceDuration, maxTraceDuration, endpointName, serviceId, serviceInstanceId, endpointId, traceId, page - .getLimit(), page.getFrom(), traceState, queryOrder); + return getTraceQueryDAO().queryBasicTraces( + startTB, endTB, minTraceDuration, maxTraceDuration, endpointName, serviceId, serviceInstanceId, endpointId, + traceId, page + .getLimit(), page.getFrom(), traceState, queryOrder + ); } public Trace queryTrace(final String traceId) throws IOException { @@ -131,7 +130,9 @@ public class TraceQueryService implements Service { if (nonNull(segment)) { SegmentObject segmentObject = SegmentObject.parseFrom(segment.getDataBinary()); trace.getSpans() - .addAll(buildSpanV2List(traceId, segment.getSegmentId(), segment.getServiceId(), segmentObject.getSpansList())); + .addAll(buildSpanV2List(traceId, segment.getSegmentId(), segment.getServiceId(), + segmentObject.getSpansList() + )); } } } @@ -156,7 +157,7 @@ public class TraceQueryService implements Service { } private List buildSpanV2List(String traceId, String segmentId, int serviceId, - List spanObjects) { + List spanObjects) { List spans = new ArrayList<>(); spanObjects.forEach(spanObject -> { @@ -183,16 +184,7 @@ public class TraceQueryService implements Service { span.setPeer(getNetworkAddressInventoryCache().get(spanObject.getPeerId()).getName()); } - String endpointName = spanObject.getOperationName(); - if (spanObject.getOperationNameId() != 0) { - EndpointInventory endpointInventory = getEndpointInventoryCache().get(spanObject.getOperationNameId()); - if (nonNull(endpointInventory)) { - endpointName = endpointInventory.getName(); - } else { - endpointName = Const.EMPTY_STRING; - } - } - span.setEndpointName(endpointName); + span.setEndpointName(spanObject.getOperationName()); final ServiceInventory serviceInventory = getServiceInventoryCache().get(serviceId); if (serviceInventory != null) { @@ -228,7 +220,8 @@ public class TraceQueryService implements Service { .collect(Collectors.joining(".")); ref.setParentSegmentId(parentSegmentId); - span.setSegmentParentSpanId(ref.getParentSegmentId() + Const.SEGMENT_SPAN_SPLIT + ref.getParentSpanId()); + span.setSegmentParentSpanId( + ref.getParentSegmentId() + Const.SEGMENT_SPAN_SPLIT + ref.getParentSpanId()); span.getRefs().add(ref); }); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Call.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Call.java index e54f9a5b37..4f1da3d814 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Call.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Call.java @@ -29,8 +29,8 @@ import org.apache.skywalking.oap.server.core.source.DetectPoint; @Getter @Setter public class Call { - private Integer source; - private Integer target; + private String source; + private String target; private List sourceComponents; private List targetComponents; private String id; @@ -45,11 +45,11 @@ public class Call { detectPoints = new ArrayList<>(); } - public void setSource(int source) { + public void setSource(String source) { this.source = source; } - public void setTarget(int target) { + public void setTarget(String target) { this.target = target; } @@ -84,8 +84,8 @@ public class Call { public static class CallDetail { @Setter(AccessLevel.PRIVATE) private String id; - private Integer source; - private Integer target; + private String source; + private String target; private DetectPoint detectPoint; private Integer componentId; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Endpoint.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Endpoint.java index dc8696ccc0..73e5cf878b 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Endpoint.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Endpoint.java @@ -24,6 +24,6 @@ import lombok.Setter; @Getter @Setter public class Endpoint { - private int id; + private String id; private String name; } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/EndpointInfo.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/EndpointInfo.java index e9981f5f51..4554dde91e 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/EndpointInfo.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/EndpointInfo.java @@ -24,7 +24,7 @@ import lombok.Setter; @Getter @Setter public class EndpointInfo { - private int id; + private String id; private String name; private int serviceId; private String serviceName; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Log.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Log.java index a0192f6f44..b570cb3284 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Log.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Log.java @@ -28,8 +28,8 @@ public class Log { private int serviceId; private String serviceInstanceName; private int serviceInstanceId; + private String endpointId; private String endpointName; - private int endpointId; private String traceId; private String timestamp; private boolean isError; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Node.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Node.java index 4ee3afe68e..906a063852 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Node.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Node.java @@ -24,7 +24,7 @@ import lombok.Setter; @Getter @Setter public class Node { - private int id; + private String id; private String name; private String type; private boolean isReal; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/EndpointInventoryRegister.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/EndpointInventoryRegister.java deleted file mode 100644 index 330ee65179..0000000000 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/EndpointInventoryRegister.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.register.service; - -import java.util.Objects; -import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.CoreModule; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; -import org.apache.skywalking.oap.server.core.register.worker.InventoryStreamProcessor; -import org.apache.skywalking.oap.server.core.source.DetectPoint; -import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static java.util.Objects.isNull; - -public class EndpointInventoryRegister implements IEndpointInventoryRegister { - - private static final Logger logger = LoggerFactory.getLogger(EndpointInventoryRegister.class); - - private final ModuleDefineHolder moduleDefineHolder; - private EndpointInventoryCache cacheService; - - public EndpointInventoryRegister(ModuleDefineHolder moduleDefineHolder) { - this.moduleDefineHolder = moduleDefineHolder; - } - - private EndpointInventoryCache getCacheService() { - if (isNull(cacheService)) { - cacheService = moduleDefineHolder.find(CoreModule.NAME).provider().getService(EndpointInventoryCache.class); - } - return cacheService; - } - - @Override - public int getOrCreate(int serviceId, String endpointName, DetectPoint detectPoint) { - int endpointId = getCacheService().getEndpointId(serviceId, endpointName, detectPoint.ordinal()); - - if (endpointId == Const.NONE) { - EndpointInventory endpointInventory = new EndpointInventory(); - endpointInventory.setServiceId(serviceId); - endpointInventory.setName(endpointName); - endpointInventory.setDetectPoint(detectPoint.ordinal()); - - long now = System.currentTimeMillis(); - endpointInventory.setRegisterTime(now); - endpointInventory.setHeartbeatTime(now); - - InventoryStreamProcessor.getInstance().in(endpointInventory); - } - return endpointId; - } - - @Override - public int get(int serviceId, String endpointName, DetectPoint detectPoint) { - return getCacheService().getEndpointId(serviceId, endpointName, detectPoint.ordinal()); - } - - @Override - public void heartbeat(int endpointId, long heartBeatTime) { - EndpointInventory endpointInventory = getCacheService().get(endpointId); - if (Objects.nonNull(endpointInventory)) { - endpointInventory.setHeartbeatTime(heartBeatTime); - - InventoryStreamProcessor.getInstance().in(endpointInventory); - } else { - logger.warn("Endpoint {} heartbeat, but not found in storage.", endpointId); - } - } -} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/AbstractLog.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/AbstractLog.java index c91002b7f6..165e2d1685 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/AbstractLog.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/AbstractLog.java @@ -30,7 +30,8 @@ public abstract class AbstractLog extends Source { private long timestamp; private int serviceId; private int serviceInstanceId; - private int endpointId; + private String endpointId; + private String endpointName; private String traceId; private int isError; private String statusCode; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java index f6314b231e..bfc8f5d70c 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java @@ -54,7 +54,7 @@ public class DefaultScopeDefine { public static final int ALARM = 13; public static final int SERVICE_INVENTORY = 14; public static final int SERVICE_INSTANCE_INVENTORY = 15; - public static final int ENDPOINT_INVENTORY = 16; + public static final int ENDPOINT_TRAFFIC = 16; public static final int DATABASE_ACCESS = 17; public static final int DATABASE_SLOW_STATEMENT = 18; public static final int SERVICE_INSTANCE_CLR_CPU = 19; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DetectPoint.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DetectPoint.java index 9e40512896..e5d38d3d05 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DetectPoint.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DetectPoint.java @@ -18,10 +18,14 @@ package org.apache.skywalking.oap.server.core.source; +import lombok.RequiredArgsConstructor; import org.apache.skywalking.apm.network.language.agent.SpanType; +@RequiredArgsConstructor public enum DetectPoint { - SERVER, CLIENT, PROXY, UNRECOGNIZED; + SERVER(0), CLIENT(1), PROXY(2), UNRECOGNIZED(3); + + private final int value; public static DetectPoint fromSpanType(SpanType spanType) { switch (spanType) { @@ -36,17 +40,20 @@ public enum DetectPoint { } } - public static DetectPoint fromNetworkProtocolDetectPoint( - org.apache.skywalking.apm.network.common.DetectPoint detectPoint) { - switch (detectPoint) { - case client: - return CLIENT; - case server: + public static DetectPoint valueOf(int value) { + switch (value) { + case 0: return SERVER; - case proxy: - case UNRECOGNIZED: + case 1: + return CLIENT; + case 2: + return PROXY; default: return UNRECOGNIZED; } } + + public int value() { + return this.value; + } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Endpoint.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Endpoint.java index 370907b62e..821f768c54 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Endpoint.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Endpoint.java @@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.core.source; import lombok.Getter; import lombok.Setter; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.ENDPOINT; import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.ENDPOINT_CATALOG_NAME; @@ -32,14 +33,14 @@ public class Endpoint extends Source { return DefaultScopeDefine.ENDPOINT; } + /** + * @since 7.1.0 SkyWalking doesn't do endpoint register. Use name directly. + */ @Override public String getEntityId() { - return String.valueOf(id); + return EndpointTraffic.buildId(serviceId, name, DetectPoint.SERVER); } - @Getter - @Setter - private int id; @Getter @Setter @ScopeDefaultColumn.DefinedByField(columnName = "name", requireDynamicActive = true) diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EndpointRelation.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EndpointRelation.java index 5a87d30f5f..4536929c40 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EndpointRelation.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/EndpointRelation.java @@ -20,7 +20,7 @@ package org.apache.skywalking.oap.server.core.source; import lombok.Getter; import lombok.Setter; -import org.apache.skywalking.oap.server.core.Const; +import org.apache.skywalking.oap.server.core.analysis.manual.RelationDefineUtil; import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.ENDPOINT_RELATION; @@ -33,17 +33,19 @@ public class EndpointRelation extends Source { return DefaultScopeDefine.ENDPOINT_RELATION; } + /** + * @since 7.1.0 SkyWalking doesn't do endpoint register. Use name directly. + */ @Override public String getEntityId() { - return String.valueOf(endpointId) + Const.ID_SPLIT + String.valueOf(childEndpointId); + return RelationDefineUtil.buildEndpointRelationEntityId(new RelationDefineUtil.EndpointRelationDefine( + serviceId, endpoint, childServiceId, childEndpoint, componentId + )); } @Getter @Setter - private int endpointId; - @Getter - @Setter - @ScopeDefaultColumn.DefinedByField(columnName = "source_endpoint_name", requireDynamicActive = true) + @ScopeDefaultColumn.DefinedByField(columnName = "source_endpoint_name") private String endpoint; @Getter @Setter @@ -62,10 +64,7 @@ public class EndpointRelation extends Source { @Getter @Setter - private int childEndpointId; - @Getter - @Setter - @ScopeDefaultColumn.DefinedByField(columnName = "child_endpoint_name", requireDynamicActive = true) + @ScopeDefaultColumn.DefinedByField(columnName = "child_endpoint_name") private String childEndpoint; @Getter @Setter diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Segment.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Segment.java index 21bd7274b2..1660ba31ad 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Segment.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/Segment.java @@ -53,7 +53,7 @@ public class Segment extends Source { private String endpointName; @Setter @Getter - private int endpointId; + private String endpointId; @Setter @Getter private long startTime; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java index a3194b6e06..be4d34013b 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageModule.java @@ -18,7 +18,6 @@ package org.apache.skywalking.oap.server.core.storage; -import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO; @@ -56,7 +55,6 @@ public class StorageModule extends ModuleDefine { IHistoryDeleteDAO.class, IServiceInventoryCacheDAO.class, IServiceInstanceInventoryCacheDAO.class, - IEndpointInventoryCacheDAO.class, INetworkAddressInventoryCacheDAO.class, ITopologyQueryDAO.class, IMetricsQueryDAO.class, diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/cache/IEndpointInventoryCacheDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/cache/IEndpointInventoryCacheDAO.java deleted file mode 100644 index 6afa34aad3..0000000000 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/cache/IEndpointInventoryCacheDAO.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.storage.cache; - -import org.apache.skywalking.oap.server.core.register.EndpointInventory; -import org.apache.skywalking.oap.server.core.storage.DAO; - -public interface IEndpointInventoryCacheDAO extends DAO { - - int getEndpointId(int serviceId, String endpointName, int detectPoint); - - EndpointInventory get(int endpointId); -} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java index 0dc122f6f7..69b5e6f7bb 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java @@ -25,7 +25,7 @@ import org.apache.skywalking.oap.server.core.query.entity.Pagination; import org.apache.skywalking.oap.server.library.module.Service; public interface ILogQueryDAO extends Service { - Logs queryLogs(final String metricName, int serviceId, int serviceInstanceId, int endpointId, String traceId, + Logs queryLogs(final String metricName, int serviceId, int serviceInstanceId, String endpointId, String traceId, LogState state, String stateCode, Pagination paging, int from, int limit, final long startTB, final long endTB) throws IOException; } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java index 55ed3d01a8..dca92cd905 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java @@ -45,7 +45,7 @@ public interface IMetadataQueryDAO extends DAO { Service searchService(final String serviceCode) throws IOException; - List searchEndpoint(final String keyword, final String serviceId, final int limit) throws IOException; + List searchEndpoint(final String keyword, final int serviceId, final int limit) throws IOException; List getServiceInstances(final long startTimestamp, final long endTimestamp, final String serviceId) throws IOException; diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITopologyQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITopologyQueryDAO.java index ba2618f7ca..0dbdde7193 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITopologyQueryDAO.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITopologyQueryDAO.java @@ -79,5 +79,5 @@ public interface ITopologyQueryDAO extends Service { List loadSpecifiedDestOfServerSideEndpointRelations(Downsampling downsampling, long startTB, long endTB, - int destEndpointId) throws IOException; + String destEndpointId) throws IOException; } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITraceQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITraceQueryDAO.java index 693f0a1546..b47d2fa8d7 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITraceQueryDAO.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITraceQueryDAO.java @@ -30,7 +30,7 @@ import org.apache.skywalking.oap.server.library.module.Service; public interface ITraceQueryDAO extends Service { TraceBrief queryBasicTraces(long startSecondTB, long endSecondTB, long minDuration, long maxDuration, - String endpointName, int serviceId, int serviceInstanceId, int endpointId, String traceId, int limit, int from, + String endpointName, int serviceId, int serviceInstanceId, String endpointId, String traceId, int limit, int from, TraceState traceState, QueryOrder queryOrder) throws IOException; List queryByTraceId(String traceId) throws IOException; diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/manual/RelationDefineUtilTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/manual/RelationDefineUtilTest.java new file mode 100644 index 0000000000..b4322a7ce5 --- /dev/null +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/manual/RelationDefineUtilTest.java @@ -0,0 +1,45 @@ +/* + * 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.manual; + +import org.junit.Assert; +import org.junit.Test; + +public class RelationDefineUtilTest { + @Test + public void testRelationID() { + RelationDefineUtil.RelationDefine define = new RelationDefineUtil.RelationDefine(1, 2, 0); + final RelationDefineUtil.RelationDefine relationDefine = RelationDefineUtil.splitEntityId( + RelationDefineUtil.buildEntityId(define)); + Assert.assertEquals(define, relationDefine); + } + + @Test + public void testEndpointRelationID() { + final RelationDefineUtil.EndpointRelationDefine endpointRelationDefine = new RelationDefineUtil.EndpointRelationDefine( + 1, "/source/endpoint", + 2, "/dest/endpoint", + 0 + ); + final RelationDefineUtil.EndpointRelationDefine anotherRelation = RelationDefineUtil.splitEndpointRelationEntityId( + RelationDefineUtil.buildEndpointRelationEntityId(endpointRelationDefine)); + Assert.assertEquals(endpointRelationDefine, anotherRelation); + + } +} diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTrafficTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTrafficTest.java new file mode 100644 index 0000000000..9bf3d06dad --- /dev/null +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/manual/endpoint/EndpointTrafficTest.java @@ -0,0 +1,79 @@ +/* + * 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.manual.endpoint; + +import org.apache.skywalking.oap.server.core.source.DetectPoint; +import org.junit.Assert; +import org.junit.Test; + +public class EndpointTrafficTest { + @Test + public void testBuildID() { + int serviceId = 4; + String endpointName = "/endpoint-123"; + DetectPoint detectPoint = DetectPoint.SERVER; + + EndpointTraffic endpointTraffic = new EndpointTraffic(); + endpointTraffic.setServiceId(serviceId); + endpointTraffic.setName(endpointName); + endpointTraffic.setDetectPoint(detectPoint.value()); + + Assert.assertEquals( + EndpointTraffic.buildId(serviceId, endpointName, detectPoint), EndpointTraffic.buildId(endpointTraffic)); + + final EndpointTraffic.EndpointID endpointID = EndpointTraffic.splitID(EndpointTraffic.buildId(endpointTraffic)); + Assert.assertEquals(endpointName, endpointID.getEndpointName()); + } + + @Test + public void testSerialization() { + int serviceId = 4; + String endpointName = "/endpoint-123"; + DetectPoint detectPoint = DetectPoint.SERVER; + + EndpointTraffic endpointTraffic = new EndpointTraffic(); + endpointTraffic.setTimeBucket(202003281420L); + endpointTraffic.setServiceId(serviceId); + endpointTraffic.setName(endpointName); + endpointTraffic.setDetectPoint(detectPoint.value()); + + EndpointTraffic another = new EndpointTraffic(); + another.deserialize(endpointTraffic.serialize().build()); + + Assert.assertEquals(endpointTraffic, another); + } + + @Test + public void testPersistence() { + int serviceId = 4; + String endpointName = "/endpoint-123"; + DetectPoint detectPoint = DetectPoint.SERVER; + + EndpointTraffic endpointTraffic = new EndpointTraffic(); + endpointTraffic.setTimeBucket(202003281420L); + endpointTraffic.setServiceId(serviceId); + endpointTraffic.setName(endpointName); + endpointTraffic.setDetectPoint(detectPoint.value()); + + final EndpointTraffic.Builder builder = new EndpointTraffic.Builder(); + final EndpointTraffic another = builder.map2Data(builder.data2Map(endpointTraffic)); + + Assert.assertEquals(endpointTraffic, another); + } +} diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQuery.java index bfe4adf276..aa8187db38 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQuery.java +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQuery.java @@ -77,7 +77,7 @@ public class MetadataQuery implements GraphQLQueryResolver { } public List searchServices(final Duration duration, - final String keyword) throws IOException, ParseException { + final String keyword) throws IOException, ParseException { long startTimestamp = DurationUtils.INSTANCE.startTimeToTimestamp(duration.getStep(), duration.getStart()); long endTimestamp = DurationUtils.INSTANCE.endTimeToTimestamp(duration.getStep(), duration.getEnd()); @@ -89,19 +89,19 @@ public class MetadataQuery implements GraphQLQueryResolver { } public List getServiceInstances(final Duration duration, - final String serviceId) throws IOException, ParseException { + final String serviceId) throws IOException, ParseException { long startTimestamp = DurationUtils.INSTANCE.startTimeToTimestamp(duration.getStep(), duration.getStart()); long endTimestamp = DurationUtils.INSTANCE.endTimeToTimestamp(duration.getStep(), duration.getEnd()); return getMetadataQueryService().getServiceInstances(startTimestamp, endTimestamp, serviceId); } - public List searchEndpoint(final String keyword, final String serviceId, - final int limit) throws IOException { + public List searchEndpoint(final String keyword, final int serviceId, + final int limit) throws IOException { return getMetadataQueryService().searchEndpoint(keyword, serviceId, limit); } - public EndpointInfo getEndpointInfo(final int endpointId) throws IOException { + public EndpointInfo getEndpointInfo(final String endpointId) throws IOException { return getMetadataQueryService().getEndpointInfo(endpointId); } diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java index 37ff28cb2f..e76e765b03 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java @@ -81,7 +81,7 @@ public class TopologyQuery implements GraphQLQueryResolver { ); } - public Topology getEndpointTopology(final int endpointId, final Duration duration) throws IOException { + public Topology getEndpointTopology(final String endpointId, final Duration duration) throws IOException { long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TraceQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TraceQuery.java index ce4c2e5be6..6e2b72cd7c 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TraceQuery.java +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TraceQuery.java @@ -75,7 +75,7 @@ public class TraceQuery implements GraphQLQueryResolver { int maxDuration = condition.getMaxTraceDuration(); String endpointName = condition.getEndpointName(); int serviceId = StringUtils.isEmpty(condition.getServiceId()) ? 0 : Integer.parseInt(condition.getServiceId()); - int endpointId = StringUtils.isEmpty(condition.getEndpointId()) ? 0 : Integer.parseInt(condition.getEndpointId()); + String endpointId = condition.getEndpointId(); int serviceInstanceId = StringUtils.isEmpty(condition.getServiceInstanceId()) ? 0 : Integer.parseInt(condition.getServiceInstanceId()); TraceState traceState = condition.getTraceState(); QueryOrder queryOrder = condition.getQueryOrder(); diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/LogQueryCondition.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/LogQueryCondition.java index d4a15c11ea..69ceaa09cf 100644 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/LogQueryCondition.java +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/type/LogQueryCondition.java @@ -29,7 +29,7 @@ public class LogQueryCondition { private String metricName; private int serviceId; private int serviceInstanceId; - private int endpointId; + private String endpointId; private String traceId; private LogState state; private String stateCode; diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol index 28f18ae8da..3bd7111b93 160000 --- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol +++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol @@ -1 +1 @@ -Subproject commit 28f18ae8dab49e60eb3d2e5cfd1a5c884a897ad0 +Subproject commit 3bd7111b9363033752d38982551ca7324a8dd74c diff --git a/oap-server/server-receiver-plugin/jaeger-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/jaeger/JaegerGRPCHandler.java b/oap-server/server-receiver-plugin/jaeger-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/jaeger/JaegerGRPCHandler.java index b18ebf8484..4f38fb7fc2 100644 --- a/oap-server/server-receiver-plugin/jaeger-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/jaeger/JaegerGRPCHandler.java +++ b/oap-server/server-receiver-plugin/jaeger-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/jaeger/JaegerGRPCHandler.java @@ -29,6 +29,7 @@ import java.util.Base64; import org.apache.skywalking.apm.util.StringUtil; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.analysis.TimeBucket; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.core.source.SourceReceiver; import org.apache.skywalking.oap.server.library.util.BooleanUtils; @@ -49,7 +50,7 @@ public class JaegerGRPCHandler extends CollectorServiceGrpc.CollectorServiceImpl } public void postSpans(Collector.PostSpansRequest request, - StreamObserver responseObserver) { + StreamObserver responseObserver) { request.getBatch().getSpansList().forEach(span -> { try { @@ -119,13 +120,8 @@ public class JaegerGRPCHandler extends CollectorServiceGrpc.CollectorServiceImpl if ("server".equals(kind) || "consumer".equals(kind)) { String endpointName = span.getOperationName(); jaegerSpan.setEndpointName(endpointName); - int endpointId = CoreRegisterLinker.getEndpointInventoryCache() - .getEndpointId(finalServiceId, endpointName, DetectPoint.SERVER - .ordinal()); - if (endpointId != Const.NONE) { - CoreRegisterLinker.getEndpointInventoryRegister() - .getOrCreate(finalServiceId, endpointName, DetectPoint.SERVER); - } + jaegerSpan.setEndpointId( + EndpointTraffic.buildId(finalServiceId, endpointName, DetectPoint.SERVER)); } } }); diff --git a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/ServiceMeshMetricDataDecorator.java b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/ServiceMeshMetricDataDecorator.java index 0e1d5f7754..0d04075679 100644 --- a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/ServiceMeshMetricDataDecorator.java +++ b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/ServiceMeshMetricDataDecorator.java @@ -19,7 +19,6 @@ package org.apache.skywalking.aop.server.receiver.mesh; import com.google.gson.JsonObject; -import org.apache.skywalking.apm.network.common.DetectPoint; import org.apache.skywalking.apm.network.servicemesh.ServiceMeshMetric; import org.apache.skywalking.apm.util.StringUtil; import org.apache.skywalking.oap.server.core.Const; @@ -30,7 +29,6 @@ public class ServiceMeshMetricDataDecorator { private ServiceMeshMetric origin; private ServiceMeshMetric rebuiltData; private ServiceMeshMetric.Builder newDataBuilder; - private int endpointId; public ServiceMeshMetricDataDecorator(ServiceMeshMetric origin) { this.origin = origin; @@ -60,9 +58,12 @@ public class ServiceMeshMetricDataDecorator { sourceServiceInstanceId = origin.getSourceServiceInstanceId(); if (sourceServiceId != Const.NONE && sourceServiceInstanceId == Const.NONE) { sourceServiceInstanceId = CoreRegisterLinker.getServiceInstanceInventoryRegister() - .getOrCreate(sourceServiceId, origin.getSourceServiceInstance(), origin - .getSourceServiceInstance(), origin.getEndTime(), getOSInfoForMesh(origin - .getSourceServiceInstance())); + .getOrCreate( + sourceServiceId, origin.getSourceServiceInstance(), origin + .getSourceServiceInstance(), origin.getEndTime(), + getOSInfoForMesh(origin + .getSourceServiceInstance()) + ); if (sourceServiceInstanceId != Const.NONE) { getNewDataBuilder().setSourceServiceInstanceId(sourceServiceInstanceId); } else { @@ -82,26 +83,18 @@ public class ServiceMeshMetricDataDecorator { destServiceInstanceId = origin.getDestServiceInstanceId(); if (destServiceId != Const.NONE && destServiceInstanceId == Const.NONE) { destServiceInstanceId = CoreRegisterLinker.getServiceInstanceInventoryRegister() - .getOrCreate(destServiceId, origin.getDestServiceInstance(), origin - .getDestServiceInstance(), origin.getEndTime(), getOSInfoForMesh(origin - .getDestServiceInstance())); + .getOrCreate( + destServiceId, origin.getDestServiceInstance(), origin + .getDestServiceInstance(), origin.getEndTime(), + getOSInfoForMesh(origin + .getDestServiceInstance()) + ); if (destServiceInstanceId != Const.NONE) { getNewDataBuilder().setDestServiceInstanceId(destServiceInstanceId); } else { isRegistered = false; } } - String endpoint = origin.getEndpoint(); - - // Service mesh doesn't register client side endpoint. - DetectPoint point = origin.getDetectPoint(); - if (DetectPoint.server.equals(point)) { - if (destServiceId != Const.NONE) { - endpointId = CoreRegisterLinker.getEndpointInventoryRegister() - .getOrCreate(destServiceId, endpoint, org.apache.skywalking.oap.server.core.source.DetectPoint - .fromNetworkProtocolDetectPoint(point)); - } - } return isRegistered; } @@ -117,10 +110,6 @@ public class ServiceMeshMetricDataDecorator { } } - public int getEndpointId() { - return endpointId; - } - private ServiceMeshMetric.Builder getNewDataBuilder() { if (newDataBuilder == null) { newDataBuilder = origin.toBuilder(); diff --git a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/TelemetryDataDispatcher.java b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/TelemetryDataDispatcher.java index 1023162486..8a550fcb2a 100644 --- a/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/TelemetryDataDispatcher.java +++ b/oap-server/server-receiver-plugin/skywalking-mesh-receiver-plugin/src/main/java/org/apache/skywalking/aop/server/receiver/mesh/TelemetryDataDispatcher.java @@ -78,7 +78,8 @@ public class TelemetryDataDispatcher { } public static void preProcess(ServiceMeshMetric data) { - String service = data.getDestServiceId() == Const.NONE ? data.getDestServiceName() : SERVICE_CACHE.get(data.getDestServiceId()) + String service = data.getDestServiceId() == Const.NONE ? data.getDestServiceName() : SERVICE_CACHE.get( + data.getDestServiceId()) .getName(); String endpointName = data.getEndpoint(); StringFormatGroup.FormatResult formatResult = EndpointNameFormater.format(service, endpointName); @@ -134,11 +135,13 @@ public class TelemetryDataDispatcher { if (Objects.nonNull(serviceInstanceInventory)) { if (metrics.getEndTime() - serviceInstanceInventory.getHeartbeatTime() > heartbeatCycle) { // trigger heartbeat every 10s. - SERVICE_INSTANCE_INVENTORY_REGISTER.heartbeat(metrics.getSourceServiceInstanceId(), metrics.getEndTime()); + SERVICE_INSTANCE_INVENTORY_REGISTER.heartbeat( + metrics.getSourceServiceInstanceId(), metrics.getEndTime()); SERVICE_INVENTORY_REGISTER.heartbeat(serviceInstanceInventory.getServiceId(), metrics.getEndTime()); } } else { - logger.warn("Can't found service by service instance id from cache, service instance id is: {}", instanceId); + logger.warn( + "Can't found service by service instance id from cache, service instance id is: {}", instanceId); } } @@ -152,7 +155,8 @@ public class TelemetryDataDispatcher { SERVICE_INVENTORY_REGISTER.heartbeat(serviceInstanceInventory.getServiceId(), metrics.getEndTime()); } } else { - logger.warn("Can't found service by service instance id from cache, service instance id is: {}", instanceId); + logger.warn( + "Can't found service by service instance id from cache, service instance id is: {}", instanceId); } } @@ -161,7 +165,8 @@ public class TelemetryDataDispatcher { All all = new All(); all.setTimeBucket(minuteTimeBucket); all.setName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); - all.setServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + all.setServiceInstanceName( + getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); all.setEndpointName(metrics.getEndpoint()); all.setLatency(metrics.getLatency()); all.setStatus(metrics.getStatus()); @@ -177,7 +182,8 @@ public class TelemetryDataDispatcher { service.setTimeBucket(minuteTimeBucket); service.setId(metrics.getDestServiceId()); service.setName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); - service.setServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + service.setServiceInstanceName( + getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); service.setEndpointName(metrics.getEndpoint()); service.setLatency(metrics.getLatency()); service.setStatus(metrics.getStatus()); @@ -192,13 +198,16 @@ public class TelemetryDataDispatcher { ServiceRelation serviceRelation = new ServiceRelation(); serviceRelation.setTimeBucket(minuteTimeBucket); serviceRelation.setSourceServiceId(metrics.getSourceServiceId()); - serviceRelation.setSourceServiceName(getServiceName(metrics.getSourceServiceId(), metrics.getSourceServiceName())); - serviceRelation.setSourceServiceInstanceName(getServiceInstanceName(metrics.getSourceServiceInstanceId(), metrics - .getSourceServiceInstance())); + serviceRelation.setSourceServiceName( + getServiceName(metrics.getSourceServiceId(), metrics.getSourceServiceName())); + serviceRelation.setSourceServiceInstanceName( + getServiceInstanceName(metrics.getSourceServiceInstanceId(), metrics + .getSourceServiceInstance())); serviceRelation.setDestServiceId(metrics.getDestServiceId()); serviceRelation.setDestServiceName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); - serviceRelation.setDestServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + serviceRelation.setDestServiceInstanceName( + getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); serviceRelation.setEndpoint(metrics.getEndpoint()); serviceRelation.setLatency(metrics.getLatency()); @@ -216,7 +225,8 @@ public class TelemetryDataDispatcher { ServiceInstance serviceInstance = new ServiceInstance(); serviceInstance.setTimeBucket(minuteTimeBucket); serviceInstance.setId(metrics.getDestServiceInstanceId()); - serviceInstance.setName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + serviceInstance.setName( + getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); serviceInstance.setServiceId(metrics.getDestServiceId()); serviceInstance.setServiceName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); serviceInstance.setEndpointName(metrics.getEndpoint()); @@ -233,13 +243,16 @@ public class TelemetryDataDispatcher { ServiceInstanceRelation serviceRelation = new ServiceInstanceRelation(); serviceRelation.setTimeBucket(minuteTimeBucket); serviceRelation.setSourceServiceInstanceId(metrics.getSourceServiceInstanceId()); - serviceRelation.setSourceServiceInstanceName(getServiceInstanceName(metrics.getSourceServiceInstanceId(), metrics - .getSourceServiceInstance())); + serviceRelation.setSourceServiceInstanceName( + getServiceInstanceName(metrics.getSourceServiceInstanceId(), metrics + .getSourceServiceInstance())); serviceRelation.setSourceServiceId(metrics.getSourceServiceId()); - serviceRelation.setSourceServiceName(getServiceName(metrics.getSourceServiceId(), metrics.getSourceServiceName())); + serviceRelation.setSourceServiceName( + getServiceName(metrics.getSourceServiceId(), metrics.getSourceServiceName())); serviceRelation.setDestServiceInstanceId(metrics.getDestServiceInstanceId()); - serviceRelation.setDestServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + serviceRelation.setDestServiceInstanceName( + getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); serviceRelation.setDestServiceId(metrics.getDestServiceId()); serviceRelation.setDestServiceName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); @@ -255,19 +268,15 @@ public class TelemetryDataDispatcher { } private static void toEndpoint(ServiceMeshMetricDataDecorator decorator, long minuteTimeBucket) { - if (decorator.getEndpointId() == Const.NONE) { - logger.warn("Received service mesh data {} with an id == 0", decorator); - return; - } ServiceMeshMetric metrics = decorator.getMetric(); Endpoint endpoint = new Endpoint(); endpoint.setTimeBucket(minuteTimeBucket); - endpoint.setId(decorator.getEndpointId()); endpoint.setName(metrics.getEndpoint()); endpoint.setServiceId(metrics.getDestServiceId()); endpoint.setServiceName(getServiceName(metrics.getDestServiceId(), metrics.getDestServiceName())); endpoint.setServiceInstanceId(metrics.getDestServiceInstanceId()); - endpoint.setServiceInstanceName(getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); + endpoint.setServiceInstanceName( + getServiceInstanceName(metrics.getDestServiceInstanceId(), metrics.getDestServiceInstance())); endpoint.setLatency(metrics.getLatency()); endpoint.setStatus(metrics.getStatus()); diff --git a/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/register/provider/handler/v6/grpc/RegisterServiceHandler.java b/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/register/provider/handler/v6/grpc/RegisterServiceHandler.java index 798ac67eda..a7385be536 100644 --- a/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/register/provider/handler/v6/grpc/RegisterServiceHandler.java +++ b/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/register/provider/handler/v6/grpc/RegisterServiceHandler.java @@ -27,7 +27,6 @@ import org.apache.skywalking.apm.network.common.KeyIntValuePair; import org.apache.skywalking.apm.network.common.KeyStringValuePair; import org.apache.skywalking.apm.network.common.ServiceType; import org.apache.skywalking.apm.network.register.v2.EndpointMapping; -import org.apache.skywalking.apm.network.register.v2.EndpointMappingElement; import org.apache.skywalking.apm.network.register.v2.Endpoints; import org.apache.skywalking.apm.network.register.v2.NetAddressMapping; import org.apache.skywalking.apm.network.register.v2.NetAddresses; @@ -45,11 +44,9 @@ import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.register.NodeType; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; import org.apache.skywalking.oap.server.core.register.ServiceInventory; -import org.apache.skywalking.oap.server.core.register.service.IEndpointInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.INetworkAddressInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInstanceInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInventoryRegister; -import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.library.server.grpc.GRPCHandler; import org.slf4j.Logger; @@ -76,7 +73,6 @@ public class RegisterServiceHandler extends RegisterGrpc.RegisterImplBase implem private final ServiceInstanceInventoryCache serviceInstanceInventoryCache; private final IServiceInventoryRegister serviceInventoryRegister; private final IServiceInstanceInventoryRegister serviceInstanceInventoryRegister; - private final IEndpointInventoryRegister inventoryService; private final INetworkAddressInventoryRegister networkAddressInventoryRegister; public RegisterServiceHandler(ModuleManager moduleManager) { @@ -92,9 +88,6 @@ public class RegisterServiceHandler extends RegisterGrpc.RegisterImplBase implem this.serviceInstanceInventoryRegister = moduleManager.find(CoreModule.NAME) .provider() .getService(IServiceInstanceInventoryRegister.class); - this.inventoryService = moduleManager.find(CoreModule.NAME) - .provider() - .getService(IEndpointInventoryRegister.class); this.networkAddressInventoryRegister = moduleManager.find(CoreModule.NAME) .provider() .getService(INetworkAddressInventoryRegister.class); @@ -199,31 +192,13 @@ public class RegisterServiceHandler extends RegisterGrpc.RegisterImplBase implem responseObserver.onCompleted(); } + /** + * @since 7.1.0 There is no endpoint / operation name register anymore. + */ + @Deprecated @Override public void doEndpointRegister(Endpoints request, StreamObserver responseObserver) { - EndpointMapping.Builder builder = EndpointMapping.newBuilder(); - - request.getEndpointsList().forEach(endpoint -> { - int serviceId = endpoint.getServiceId(); - String endpointName = endpoint.getEndpointName(); - - DetectPoint detectPoint = DetectPoint.fromNetworkProtocolDetectPoint(endpoint.getFrom()); - if (DetectPoint.SERVER.equals(detectPoint)) { - int endpointId = inventoryService.getOrCreate(serviceId, endpointName, detectPoint); - - if (endpointId != Const.NONE) { - builder.addElements(EndpointMappingElement.newBuilder() - .setServiceId(serviceId) - .setEndpointName(endpointName) - .setEndpointId(endpointId) - .setFrom(endpoint.getFrom())); - } - } else { - logger.warn("Unexpected endpoint register, endpoint isn't detected from server side. {}", request); - } - }); - - responseObserver.onNext(builder.build()); + responseObserver.onNext(EndpointMapping.newBuilder().build()); responseObserver.onCompleted(); } diff --git a/oap-server/server-receiver-plugin/skywalking-sharing-server-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/sharing/server/CoreRegisterLinker.java b/oap-server/server-receiver-plugin/skywalking-sharing-server-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/sharing/server/CoreRegisterLinker.java index 98316fb192..16777620f6 100644 --- a/oap-server/server-receiver-plugin/skywalking-sharing-server-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/sharing/server/CoreRegisterLinker.java +++ b/oap-server/server-receiver-plugin/skywalking-sharing-server-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/sharing/server/CoreRegisterLinker.java @@ -19,9 +19,7 @@ package org.apache.skywalking.oap.server.receiver.sharing.server; import org.apache.skywalking.oap.server.core.CoreModule; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; -import org.apache.skywalking.oap.server.core.register.service.IEndpointInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInstanceInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInventoryRegister; import org.apache.skywalking.oap.server.library.module.ModuleManager; @@ -30,9 +28,7 @@ public class CoreRegisterLinker { private static volatile ModuleManager MODULE_MANAGER; private static volatile IServiceInventoryRegister SERVICE_INVENTORY_REGISTER; private static volatile IServiceInstanceInventoryRegister SERVICE_INSTANCE_INVENTORY_REGISTER; - private static volatile IEndpointInventoryRegister ENDPOINT_INVENTORY_REGISTER; private static volatile ServiceInventoryCache SERVICE_INVENTORY_CACHE; - private static volatile EndpointInventoryCache ENDPOINT_INVENTORY_CACHE; public static void setModuleManager(ModuleManager moduleManager) { CoreRegisterLinker.MODULE_MANAGER = moduleManager; @@ -56,15 +52,6 @@ public class CoreRegisterLinker { return SERVICE_INSTANCE_INVENTORY_REGISTER; } - public static IEndpointInventoryRegister getEndpointInventoryRegister() { - if (ENDPOINT_INVENTORY_REGISTER == null) { - ENDPOINT_INVENTORY_REGISTER = MODULE_MANAGER.find(CoreModule.NAME) - .provider() - .getService(IEndpointInventoryRegister.class); - } - return ENDPOINT_INVENTORY_REGISTER; - } - public static ServiceInventoryCache getServiceInventoryCache() { if (SERVICE_INVENTORY_CACHE == null) { SERVICE_INVENTORY_CACHE = MODULE_MANAGER.find(CoreModule.NAME) @@ -73,13 +60,4 @@ public class CoreRegisterLinker { } return SERVICE_INVENTORY_CACHE; } - - public static EndpointInventoryCache getEndpointInventoryCache() { - if (ENDPOINT_INVENTORY_CACHE == null) { - ENDPOINT_INVENTORY_CACHE = MODULE_MANAGER.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class); - } - return ENDPOINT_INVENTORY_CACHE; - } } diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/decorator/ReferenceDecorator.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/decorator/ReferenceDecorator.java index 8ebfa21ab3..05c7156849 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/decorator/ReferenceDecorator.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/decorator/ReferenceDecorator.java @@ -38,21 +38,6 @@ public class ReferenceDecorator implements StandardBuilder { this.isOrigin = false; } - public int getEntryEndpointId() { - if (isOrigin) { - return referenceObjectV2.getEntryEndpointId(); - } else { - return referenceBuilderV2.getEntryEndpointId(); - } - } - - public void setEntryEndpointId(int value) { - if (isOrigin) { - toBuilder(); - } - referenceBuilderV2.setEntryEndpointId(value); - } - public String getEntryEndpointName() { if (isOrigin) { return referenceObjectV2.getEntryEndpoint(); @@ -61,13 +46,6 @@ public class ReferenceDecorator implements StandardBuilder { } } - public void setEntryEndpointName(String value) { - if (isOrigin) { - toBuilder(); - } - referenceBuilderV2.setEntryEndpoint(value); - } - public int getEntryServiceInstanceId() { if (isOrigin) { return referenceObjectV2.getEntryServiceInstanceId(); @@ -84,21 +62,6 @@ public class ReferenceDecorator implements StandardBuilder { } } - public int getParentEndpointId() { - if (isOrigin) { - return referenceObjectV2.getParentEndpointId(); - } else { - return referenceBuilderV2.getParentEndpointId(); - } - } - - public void setParentEndpointId(int value) { - if (isOrigin) { - toBuilder(); - } - referenceBuilderV2.setParentEndpointId(value); - } - public String getParentEndpointName() { if (isOrigin) { return referenceObjectV2.getParentEndpoint(); @@ -107,13 +70,6 @@ public class ReferenceDecorator implements StandardBuilder { } } - public void setParentEndpointName(String value) { - if (isOrigin) { - toBuilder(); - } - referenceBuilderV2.setParentEndpoint(value); - } - public int getNetworkAddressId() { if (isOrigin) { return referenceObjectV2.getNetworkAddressId(); diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/decorator/SpanDecorator.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/decorator/SpanDecorator.java index 8632ba6efe..620ca78b11 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/decorator/SpanDecorator.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/decorator/SpanDecorator.java @@ -158,21 +158,6 @@ public class SpanDecorator implements StandardBuilder { spanBuilderV2.setPeer(peer); } - public int getOperationNameId() { - if (isOrigin) { - return spanObjectV2.getOperationNameId(); - } else { - return spanBuilderV2.getOperationNameId(); - } - } - - public void setOperationNameId(int value) { - if (isOrigin) { - toBuilder(); - } - spanBuilderV2.setOperationNameId(value); - } - public String getOperationName() { if (isOrigin) { return spanObjectV2.getOperationName(); diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java index 68f9deb541..ec703985db 100755 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; - import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.apm.network.common.KeyStringValuePair; import org.apache.skywalking.apm.network.language.agent.SpanLayer; @@ -31,7 +30,6 @@ import org.apache.skywalking.apm.util.StringUtil; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.analysis.TimeBucket; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.NetworkAddressInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; @@ -66,7 +64,6 @@ public class MultiScopesSpanListener implements EntrySpanListener, ExitSpanListe private final SourceReceiver sourceReceiver; private final ServiceInstanceInventoryCache instanceInventoryCache; private final ServiceInventoryCache serviceInventoryCache; - private final EndpointInventoryCache endpointInventoryCache; private final List entrySourceBuilders; private final List exitSourceBuilders; @@ -88,9 +85,6 @@ public class MultiScopesSpanListener implements EntrySpanListener, ExitSpanListe this.serviceInventoryCache = moduleManager.find(CoreModule.NAME) .provider() .getService(ServiceInventoryCache.class); - this.endpointInventoryCache = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class); this.networkAddressInventoryCache = moduleManager.find(CoreModule.NAME) .provider() .getService(NetworkAddressInventoryCache.class); @@ -121,10 +115,10 @@ public class MultiScopesSpanListener implements EntrySpanListener, ExitSpanListe for (int i = 0; i < spanDecorator.getRefsCount(); i++) { ReferenceDecorator reference = spanDecorator.getRefs(i); SourceBuilder sourceBuilder = new SourceBuilder(); - if (reference.getParentEndpointId() == Const.INEXISTENCE_ENDPOINT_ID) { - sourceBuilder.setSourceEndpointId(Const.USER_ENDPOINT_ID); + if (StringUtil.isEmpty(reference.getParentEndpointName())) { + sourceBuilder.setSourceEndpointName(Const.USER_ENDPOINT_NAME); } else { - sourceBuilder.setSourceEndpointId(reference.getParentEndpointId()); + sourceBuilder.setSourceEndpointName(reference.getParentEndpointName()); } final int networkAddressId = reference.getNetworkAddressId(); @@ -142,7 +136,7 @@ public class MultiScopesSpanListener implements EntrySpanListener, ExitSpanListe sourceBuilder.setSourceServiceId(instanceInventoryCache.get(reference.getParentServiceInstanceId()) .getServiceId()); } - sourceBuilder.setDestEndpointId(spanDecorator.getOperationNameId()); + sourceBuilder.setDestEndpointName(spanDecorator.getOperationName()); sourceBuilder.setDestServiceInstanceId(segmentCoreInfo.getServiceInstanceId()); sourceBuilder.setDestServiceId(segmentCoreInfo.getServiceId()); sourceBuilder.setDetectPoint(DetectPoint.SERVER); @@ -152,10 +146,10 @@ public class MultiScopesSpanListener implements EntrySpanListener, ExitSpanListe } } else { SourceBuilder sourceBuilder = new SourceBuilder(); - sourceBuilder.setSourceEndpointId(Const.USER_ENDPOINT_ID); + sourceBuilder.setSourceEndpointName(Const.USER_ENDPOINT_NAME); sourceBuilder.setSourceServiceInstanceId(Const.USER_INSTANCE_ID); sourceBuilder.setSourceServiceId(Const.USER_SERVICE_ID); - sourceBuilder.setDestEndpointId(spanDecorator.getOperationNameId()); + sourceBuilder.setDestEndpointName(spanDecorator.getOperationName()); sourceBuilder.setDestServiceInstanceId(segmentCoreInfo.getServiceInstanceId()); sourceBuilder.setDestServiceId(segmentCoreInfo.getServiceId()); sourceBuilder.setDetectPoint(DetectPoint.SERVER); @@ -262,16 +256,9 @@ public class MultiScopesSpanListener implements EntrySpanListener, ExitSpanListe sourceBuilder.setSourceServiceInstanceName( instanceInventoryCache.get(sourceBuilder.getSourceServiceInstanceId()) .getName()); - if (sourceBuilder.getSourceEndpointId() != Const.NONE) { - sourceBuilder.setSourceEndpointName(endpointInventoryCache.get(sourceBuilder.getSourceEndpointId()) - .getName()); - } sourceBuilder.setDestServiceName(serviceInventoryCache.get(sourceBuilder.getDestServiceId()).getName()); sourceBuilder.setDestServiceInstanceName(instanceInventoryCache.get(sourceBuilder.getDestServiceInstanceId()) .getName()); - if (sourceBuilder.getDestEndpointId() != Const.NONE) { - sourceBuilder.setDestEndpointName(endpointInventoryCache.get(sourceBuilder.getDestEndpointId()).getName()); - } } @Override @@ -300,12 +287,10 @@ public class MultiScopesSpanListener implements EntrySpanListener, ExitSpanListe exitSourceBuilders.forEach(exitSourceBuilder -> { if (nonNull(entrySpanDecorator)) { - exitSourceBuilder.setSourceEndpointId(entrySpanDecorator.getOperationNameId()); + exitSourceBuilder.setSourceEndpointName(entrySpanDecorator.getOperationName()); } else { - exitSourceBuilder.setSourceEndpointId(Const.USER_ENDPOINT_ID); + exitSourceBuilder.setSourceEndpointName(Const.USER_ENDPOINT_NAME); } - exitSourceBuilder.setSourceEndpointName(endpointInventoryCache.get(exitSourceBuilder.getSourceEndpointId()) - .getName()); exitSourceBuilder.setTimeBucket(minuteTimeBucket); sourceReceiver.receive(exitSourceBuilder.toServiceRelation()); @@ -313,7 +298,8 @@ public class MultiScopesSpanListener implements EntrySpanListener, ExitSpanListe /* * Some of the agent can not have the upstream real network address, such as https://github.com/apache/skywalking-nginx-lua. */ - String sourceLanguage = instanceInventoryCache.getServiceInstanceLanguage(exitSourceBuilder.getSourceServiceInstanceId()); + String sourceLanguage = instanceInventoryCache.getServiceInstanceLanguage( + exitSourceBuilder.getSourceServiceInstanceId()); if (!config.getNoUpstreamRealAddressAgents().contains(sourceLanguage)) { sourceReceiver.receive(exitSourceBuilder.toServiceInstanceRelation()); } diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/SourceBuilder.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/SourceBuilder.java index f6483bea97..ff2ebb2888 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/SourceBuilder.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/SourceBuilder.java @@ -48,9 +48,6 @@ class SourceBuilder { private String sourceServiceInstanceName; @Getter @Setter - private int sourceEndpointId; - @Getter - @Setter private String sourceEndpointName; @Getter @Setter @@ -66,9 +63,6 @@ class SourceBuilder { private String destServiceInstanceName; @Getter @Setter - private int destEndpointId; - @Getter - @Setter private String destEndpointName; @Getter @Setter @@ -176,7 +170,6 @@ class SourceBuilder { Endpoint toEndpoint() { Endpoint endpoint = new Endpoint(); - endpoint.setId(destEndpointId); endpoint.setName(destEndpointName); endpoint.setServiceId(destServiceId); endpoint.setServiceName(destServiceName); @@ -195,13 +188,11 @@ class SourceBuilder { return null; } EndpointRelation endpointRelation = new EndpointRelation(); - endpointRelation.setEndpointId(sourceEndpointId); endpointRelation.setEndpoint(sourceEndpointName); endpointRelation.setServiceId(sourceServiceId); endpointRelation.setServiceName(sourceServiceName); endpointRelation.setServiceInstanceId(sourceServiceInstanceId); endpointRelation.setServiceInstanceName(sourceServiceInstanceName); - endpointRelation.setChildEndpointId(destEndpointId); endpointRelation.setChildEndpoint(destEndpointName); endpointRelation.setChildServiceId(destServiceId); endpointRelation.setChildServiceName(destServiceName); diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/segment/SegmentSpanListener.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/segment/SegmentSpanListener.java index bbb399b7ad..544d87ca87 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/segment/SegmentSpanListener.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/segment/SegmentSpanListener.java @@ -21,10 +21,10 @@ package org.apache.skywalking.oap.server.receiver.trace.provider.parser.listener import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.apm.network.language.agent.UniqueId; -import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.analysis.TimeBucket; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; +import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.core.source.Segment; import org.apache.skywalking.oap.server.core.source.SourceReceiver; import org.apache.skywalking.oap.server.library.module.ModuleManager; @@ -46,18 +46,13 @@ public class SegmentSpanListener implements FirstSpanListener, EntrySpanListener private final SourceReceiver sourceReceiver; private final TraceSegmentSampler sampler; private final Segment segment = new Segment(); - private final EndpointInventoryCache serviceNameCacheService; private SAMPLE_STATUS sampleStatus = SAMPLE_STATUS.UNKNOWN; - private int entryEndpointId = 0; - private int firstEndpointId = 0; - private String firstEndpointName = ""; + private String endpointId = ""; + private String endpointName = ""; private SegmentSpanListener(ModuleManager moduleManager, TraceSegmentSampler sampler) { this.sampler = sampler; this.sourceReceiver = moduleManager.find(CoreModule.NAME).provider().getService(SourceReceiver.class); - this.serviceNameCacheService = moduleManager.find(CoreModule.NAME) - .provider() - .getService(EndpointInventoryCache.class); } @Override @@ -84,13 +79,18 @@ public class SegmentSpanListener implements FirstSpanListener, EntrySpanListener segment.setDataBinary(segmentCoreInfo.getDataBinary()); segment.setVersion(segmentCoreInfo.getVersion().number()); - firstEndpointId = spanDecorator.getOperationNameId(); - firstEndpointName = spanDecorator.getOperationName(); + endpointId = EndpointTraffic.buildId(segmentCoreInfo.getServiceId(), spanDecorator.getOperationName(), + DetectPoint.fromSpanType(spanDecorator.getSpanType()) + ); + endpointName = spanDecorator.getOperationName(); } @Override public void parseEntry(SpanDecorator spanDecorator, SegmentCoreInfo segmentCoreInfo) { - entryEndpointId = spanDecorator.getOperationNameId(); + endpointId = EndpointTraffic.buildId(segmentCoreInfo.getServiceId(), spanDecorator.getOperationName(), + DetectPoint.fromSpanType(spanDecorator.getSpanType()) + ); + endpointName = spanDecorator.getOperationName(); } @Override @@ -121,23 +121,8 @@ public class SegmentSpanListener implements FirstSpanListener, EntrySpanListener return; } - if (entryEndpointId == Const.NONE) { - if (firstEndpointId != Const.NONE) { - /* - * Since 6.6.0, only entry span is treated as an endpoint. Other span's endpoint id == 0. - */ - segment.setEndpointId(firstEndpointId); - segment.setEndpointName(serviceNameCacheService.get(firstEndpointId).getName()); - } else { - /* - * Only fill first operation name for the trace list query, as no endpoint id. - */ - segment.setEndpointName(firstEndpointName); - } - } else { - segment.setEndpointId(entryEndpointId); - segment.setEndpointName(serviceNameCacheService.get(entryEndpointId).getName()); - } + segment.setEndpointId(endpointId); + segment.setEndpointName(endpointName); sourceReceiver.receive(segment); } diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/ReferenceIdExchanger.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/ReferenceIdExchanger.java index 5203b8627d..44e09f3211 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/ReferenceIdExchanger.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/ReferenceIdExchanger.java @@ -23,9 +23,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; -import org.apache.skywalking.oap.server.core.register.service.IEndpointInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.INetworkAddressInventoryRegister; -import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.receiver.trace.provider.parser.decorator.ReferenceDecorator; @@ -39,7 +37,6 @@ import org.apache.skywalking.oap.server.receiver.trace.provider.parser.decorator @Slf4j public class ReferenceIdExchanger implements IdExchanger { private static ReferenceIdExchanger EXCHANGER; - private final IEndpointInventoryRegister endpointInventoryRegister; private final ServiceInstanceInventoryCache serviceInstanceInventoryCache; private final INetworkAddressInventoryRegister networkAddressInventoryRegister; @@ -51,9 +48,6 @@ public class ReferenceIdExchanger implements IdExchanger { } private ReferenceIdExchanger(ModuleManager moduleManager) { - this.endpointInventoryRegister = moduleManager.find(CoreModule.NAME) - .provider() - .getService(IEndpointInventoryRegister.class); this.networkAddressInventoryRegister = moduleManager.find(CoreModule.NAME) .provider() .getService(INetworkAddressInventoryRegister.class); @@ -62,65 +56,13 @@ public class ReferenceIdExchanger implements IdExchanger { .getService(ServiceInstanceInventoryCache.class); } + /** + * @since 7.1.0 Endpoint doesn't register anymore. Therefore, exchange of ref only relates to the network address only. + */ @Override public boolean exchange(ReferenceDecorator standardBuilder, int serviceId) { boolean exchanged = true; - if (standardBuilder.getEntryEndpointId() == 0) { - String entryEndpointName = Strings.isNullOrEmpty( - standardBuilder.getEntryEndpointName()) ? Const.DOMAIN_OPERATION_NAME : standardBuilder - .getEntryEndpointName(); - int entryServiceId = serviceInstanceInventoryCache.get(standardBuilder.getEntryServiceInstanceId()) - .getServiceId(); - int entryEndpointId = getEndpointId(entryServiceId, entryEndpointName); - if (entryEndpointId == 0) { - if (log.isDebugEnabled()) { - log.debug( - "entry endpoint name: {} from service id: {} exchange failed", entryEndpointName, - entryServiceId - ); - } - - exchanged = false; - } else { - standardBuilder.toBuilder(); - standardBuilder.setEntryEndpointId(entryEndpointId); - standardBuilder.setEntryEndpointName(Const.EMPTY_STRING); - } - } else { - /** - * Since 6.6.0, endpoint id could be -1, as it is not an endpoint. Such as local span and exist span. - */ - } - - if (standardBuilder.getParentEndpointId() == 0) { - String parentEndpointName = Strings.isNullOrEmpty( - standardBuilder.getParentEndpointName()) ? Const.DOMAIN_OPERATION_NAME : standardBuilder - .getParentEndpointName(); - int parentServiceId = serviceInstanceInventoryCache.get(standardBuilder.getParentServiceInstanceId()) - .getServiceId(); - int parentEndpointId = getEndpointId(parentServiceId, parentEndpointName); - - if (parentEndpointId == 0) { - if (log.isDebugEnabled()) { - log.debug( - "parent endpoint name: {} from service id: {} exchange failed", parentEndpointName, - parentServiceId - ); - } - - exchanged = false; - } else { - standardBuilder.toBuilder(); - standardBuilder.setParentEndpointId(parentEndpointId); - standardBuilder.setParentEndpointName(Const.EMPTY_STRING); - } - } else { - /** - * Since 6.6.0, endpoint id could be -1, as it is not an endpoint. Such as local span and exist span. - */ - } - if (standardBuilder.getNetworkAddressId() == 0 && !Strings.isNullOrEmpty(standardBuilder.getNetworkAddress())) { int networkAddressId = networkAddressInventoryRegister.getOrCreate( standardBuilder.getNetworkAddress(), null); @@ -142,16 +84,4 @@ public class ReferenceIdExchanger implements IdExchanger { } return exchanged; } - - /** - * @since 6.6.0 The endpoint in the ref should be server endpoint only. The agent will/should use `-1`, when it can't - * find the endpoint of entry span in the current tracing context when build the ref. - * @since 5.0 Endpoint in ref could be local or exit span's operation name. Especially if it is local span operation - * name, * exchange may not happen at agent, such as Java agent, then put literal endpoint string in the header, - * Need to try * to get the id by assuming the endpoint name is detected at server, local or client. *

* If - * agent does the exchange, then always use endpoint id. - */ - private int getEndpointId(int serviceId, String endpointName) { - return endpointInventoryRegister.getOrCreate(serviceId, endpointName, DetectPoint.SERVER); - } } diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/SpanExchanger.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/SpanExchanger.java index c0383b2b12..c9489907b8 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/SpanExchanger.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/SpanExchanger.java @@ -24,7 +24,6 @@ import java.util.List; import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.apm.network.common.KeyStringValuePair; import org.apache.skywalking.apm.network.language.agent.SpanLayer; -import org.apache.skywalking.apm.network.language.agent.SpanType; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; @@ -33,11 +32,9 @@ import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogServ import org.apache.skywalking.oap.server.core.register.NodeType; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; import org.apache.skywalking.oap.server.core.register.ServiceInventory; -import org.apache.skywalking.oap.server.core.register.service.IEndpointInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.INetworkAddressInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInstanceInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInventoryRegister; -import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.receiver.trace.provider.parser.decorator.SpanDecorator; @@ -54,7 +51,6 @@ public class SpanExchanger implements IdExchanger { private final IServiceInventoryRegister serviceInventoryRegister; private final ServiceInstanceInventoryCache serviceInstanceInventoryCacheDAO; private final IServiceInstanceInventoryRegister serviceInstanceInventoryRegister; - private final IEndpointInventoryRegister endpointInventoryRegister; private final INetworkAddressInventoryRegister networkAddressInventoryRegister; private final IComponentLibraryCatalogService componentLibraryCatalogService; @@ -78,9 +74,6 @@ public class SpanExchanger implements IdExchanger { this.serviceInstanceInventoryRegister = moduleManager.find(CoreModule.NAME) .provider() .getService(IServiceInstanceInventoryRegister.class); - this.endpointInventoryRegister = moduleManager.find(CoreModule.NAME) - .provider() - .getService(IEndpointInventoryRegister.class); this.networkAddressInventoryRegister = moduleManager.find(CoreModule.NAME) .provider() .getService(INetworkAddressInventoryRegister.class); @@ -154,32 +147,6 @@ public class SpanExchanger implements IdExchanger { serviceInstanceInventoryRegister.update(newServiceInstanceInventory.getSequence(), nodeType, properties); } - if (standardBuilder.getOperationNameId() == Const.NONE) { - /** - * Only operation name of entry span is being treated as an endpoint, - * so, since 6.6.0, only it triggers register. - */ - if (SpanType.Entry.equals(standardBuilder.getSpanType())) { - String endpointName = Strings.isNullOrEmpty( - standardBuilder.getOperationName()) ? Const.DOMAIN_OPERATION_NAME : standardBuilder - .getOperationName(); - int endpointId = endpointInventoryRegister.getOrCreate( - serviceId, endpointName, DetectPoint.fromSpanType(standardBuilder - .getSpanType())); - - if (endpointId == 0) { - if (log.isDebugEnabled()) { - log.debug("endpoint name: {} from service id: {} exchange failed", endpointName, serviceId); - } - - exchanged = false; - } else { - standardBuilder.toBuilder(); - standardBuilder.setOperationNameId(endpointId); - standardBuilder.setOperationName(Const.EMPTY_STRING); - } - } - } return exchanged; } diff --git a/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanProcessor.java b/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanProcessor.java index f27c2a427c..a99c60941a 100644 --- a/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanProcessor.java +++ b/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanProcessor.java @@ -24,7 +24,6 @@ import java.io.InputStream; import java.util.List; import java.util.zip.GZIPInputStream; import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.source.SourceReceiver; import org.apache.skywalking.oap.server.receiver.zipkin.ZipkinReceiverConfig; @@ -36,14 +35,11 @@ import zipkin2.codec.SpanBytesDecoder; public class SpanProcessor { private SourceReceiver receiver; private ServiceInventoryCache serviceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; private int encode; - public SpanProcessor(SourceReceiver receiver, ServiceInventoryCache serviceInventoryCache, - EndpointInventoryCache endpointInventoryCache, int encode) { + public SpanProcessor(SourceReceiver receiver, ServiceInventoryCache serviceInventoryCache, int encode) { this.receiver = receiver; this.serviceInventoryCache = serviceInventoryCache; - this.endpointInventoryCache = endpointInventoryCache; this.encode = encode; } @@ -63,7 +59,7 @@ public class SpanProcessor { ZipkinSkyWalkingTransfer transfer = new ZipkinSkyWalkingTransfer(); transfer.doTransfer(config, spanList); } else { - SpanForward forward = new SpanForward(config, receiver, serviceInventoryCache, endpointInventoryCache, encode); + SpanForward forward = new SpanForward(config, receiver, serviceInventoryCache, encode); forward.send(spanList); } } diff --git a/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanV1JettyHandler.java b/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanV1JettyHandler.java index 2301102dce..4561d96c85 100644 --- a/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanV1JettyHandler.java +++ b/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanV1JettyHandler.java @@ -21,7 +21,6 @@ package org.apache.skywalking.oap.server.receiver.zipkin.handler; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.skywalking.oap.server.core.CoreModule; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.source.SourceReceiver; import org.apache.skywalking.oap.server.library.module.ModuleManager; @@ -37,12 +36,10 @@ public class SpanV1JettyHandler extends JettyHandler { private ZipkinReceiverConfig config; private SourceReceiver sourceReceiver; private ServiceInventoryCache serviceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; public SpanV1JettyHandler(ZipkinReceiverConfig config, ModuleManager manager) { sourceReceiver = manager.find(CoreModule.NAME).provider().getService(SourceReceiver.class); serviceInventoryCache = manager.find(CoreModule.NAME).provider().getService(ServiceInventoryCache.class); - endpointInventoryCache = manager.find(CoreModule.NAME).provider().getService(EndpointInventoryCache.class); this.config = config; } @@ -63,7 +60,7 @@ public class SpanV1JettyHandler extends JettyHandler { SpanBytesDecoder decoder = SpanEncode.isThrift(encode) ? SpanBytesDecoder.THRIFT : SpanBytesDecoder.JSON_V1; - SpanProcessor processor = new SpanProcessor(sourceReceiver, serviceInventoryCache, endpointInventoryCache, encode); + SpanProcessor processor = new SpanProcessor(sourceReceiver, serviceInventoryCache, encode); processor.convert(config, decoder, request); response.setStatus(202); diff --git a/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanV2JettyHandler.java b/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanV2JettyHandler.java index 09cf07a437..2a10b397b5 100644 --- a/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanV2JettyHandler.java +++ b/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanV2JettyHandler.java @@ -21,7 +21,6 @@ package org.apache.skywalking.oap.server.receiver.zipkin.handler; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.skywalking.oap.server.core.CoreModule; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.source.SourceReceiver; import org.apache.skywalking.oap.server.library.module.ModuleManager; @@ -37,12 +36,10 @@ public class SpanV2JettyHandler extends JettyHandler { private ZipkinReceiverConfig config; private SourceReceiver sourceReceiver; private ServiceInventoryCache serviceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; public SpanV2JettyHandler(ZipkinReceiverConfig config, ModuleManager manager) { sourceReceiver = manager.find(CoreModule.NAME).provider().getService(SourceReceiver.class); serviceInventoryCache = manager.find(CoreModule.NAME).provider().getService(ServiceInventoryCache.class); - endpointInventoryCache = manager.find(CoreModule.NAME).provider().getService(EndpointInventoryCache.class); this.config = config; } @@ -63,7 +60,7 @@ public class SpanV2JettyHandler extends JettyHandler { SpanBytesDecoder decoder = SpanEncode.isProto3(encode) ? SpanBytesDecoder.PROTO3 : SpanBytesDecoder.JSON_V2; - SpanProcessor processor = new SpanProcessor(sourceReceiver, serviceInventoryCache, endpointInventoryCache, encode); + SpanProcessor processor = new SpanProcessor(sourceReceiver, serviceInventoryCache, encode); processor.convert(config, decoder, request); response.setStatus(202); diff --git a/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/trace/SpanForward.java b/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/trace/SpanForward.java index 5d39bf9f61..1b1edbcd9f 100644 --- a/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/trace/SpanForward.java +++ b/oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/trace/SpanForward.java @@ -22,7 +22,7 @@ import java.util.List; import org.apache.skywalking.apm.util.StringUtil; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.analysis.TimeBucket; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache; import org.apache.skywalking.oap.server.core.source.DetectPoint; import org.apache.skywalking.oap.server.core.source.SourceReceiver; @@ -38,15 +38,13 @@ public class SpanForward { private ZipkinReceiverConfig config; private SourceReceiver receiver; private ServiceInventoryCache serviceInventoryCache; - private EndpointInventoryCache endpointInventoryCache; private int encode; public SpanForward(ZipkinReceiverConfig config, SourceReceiver receiver, - ServiceInventoryCache serviceInventoryCache, EndpointInventoryCache endpointInventoryCache, int encode) { + ServiceInventoryCache serviceInventoryCache, int encode) { this.config = config; this.receiver = receiver; this.serviceInventoryCache = serviceInventoryCache; - this.endpointInventoryCache = endpointInventoryCache; this.encode = encode; } @@ -76,13 +74,7 @@ public class SpanForward { case SERVER: case CONSUMER: if (!StringUtil.isEmpty(spanName) && serviceId != Const.NONE) { - int endpointId = endpointInventoryCache.getEndpointId(serviceId, spanName, DetectPoint.SERVER.ordinal()); - if (endpointId != Const.NONE) { - zipkinSpan.setEndpointId(endpointId); - } else if (config.isRegisterZipkinEndpoint()) { - CoreRegisterLinker.getEndpointInventoryRegister() - .getOrCreate(serviceId, spanName, DetectPoint.SERVER); - } + zipkinSpan.setEndpointId(EndpointTraffic.buildId(serviceId, spanName, DetectPoint.SERVER)); } } if (!StringUtil.isEmpty(spanName)) { diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java index af7c4bb401..e89eb09d04 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/StorageModuleElasticsearchProvider.java @@ -40,7 +40,6 @@ import org.apache.skywalking.oap.server.core.storage.IRegisterLockDAO; import org.apache.skywalking.oap.server.core.storage.StorageDAO; import org.apache.skywalking.oap.server.core.storage.StorageException; import org.apache.skywalking.oap.server.core.storage.StorageModule; -import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO; @@ -68,7 +67,6 @@ import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.Histor import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.StorageEsDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.StorageEsInstaller; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.TimeSeriesUtils; -import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.EndpointInventoryCacheEsDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.NetworkAddressInventoryCacheEsDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.ServiceInstanceInventoryCacheDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.ServiceInventoryCacheEsDAO; @@ -176,8 +174,6 @@ public class StorageModuleElasticsearchProvider extends ModuleProvider { this.registerServiceImplementation( IServiceInstanceInventoryCacheDAO.class, new ServiceInstanceInventoryCacheDAO(elasticSearchClient, config .getResultWindowMaxSize())); - this.registerServiceImplementation( - IEndpointInventoryCacheDAO.class, new EndpointInventoryCacheEsDAO(elasticSearchClient)); this.registerServiceImplementation( INetworkAddressInventoryCacheDAO.class, new NetworkAddressInventoryCacheEsDAO(elasticSearchClient, config .getResultWindowMaxSize())); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java deleted file mode 100644 index c41a623528..0000000000 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.storage.plugin.elasticsearch.cache; - -import org.apache.skywalking.oap.server.core.Const; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; -import org.apache.skywalking.oap.server.core.register.RegisterSource; -import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; -import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class EndpointInventoryCacheEsDAO extends EsDAO implements IEndpointInventoryCacheDAO { - - private static final Logger logger = LoggerFactory.getLogger(EndpointInventoryCacheEsDAO.class); - - protected final EndpointInventory.Builder builder = new EndpointInventory.Builder(); - - public EndpointInventoryCacheEsDAO(ElasticSearchClient client) { - super(client); - } - - @Override - public int getEndpointId(int serviceId, String endpointName, int detectPoint) { - try { - String id = EndpointInventory.buildId(serviceId, endpointName, detectPoint); - GetResponse response = getClient().get(EndpointInventory.INDEX_NAME, id); - if (response.isExists()) { - return (int) response.getSource().getOrDefault(RegisterSource.SEQUENCE, 0); - } else { - return Const.NONE; - } - } catch (Throwable e) { - logger.error(e.getMessage(), e); - return Const.NONE; - } - } - - @Override - public EndpointInventory get(int endpointId) { - try { - SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); - searchSourceBuilder.query(QueryBuilders.termQuery(EndpointInventory.SEQUENCE, endpointId)); - searchSourceBuilder.size(1); - - SearchResponse response = getClient().search(EndpointInventory.INDEX_NAME, searchSourceBuilder); - if (response.getHits().totalHits == 1) { - SearchHit searchHit = response.getHits().getAt(0); - return builder.map2Data(searchHit.getSourceAsMap()); - } else { - return null; - } - } catch (Throwable e) { - logger.error(e.getMessage(), e); - return null; - } - } -} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java index e03c9bd555..d2bed082c8 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java @@ -25,7 +25,7 @@ import org.apache.skywalking.oap.server.core.analysis.Downsampling; import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.query.entity.Order; import org.apache.skywalking.oap.server.core.query.entity.TopNEntity; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; import org.apache.skywalking.oap.server.core.storage.model.ModelName; import org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO; @@ -104,7 +104,7 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO sourceBuilder.query(boolQueryBuilder); boolQueryBuilder.must().add(QueryBuilders.rangeQuery(Metrics.TIME_BUCKET).lte(endTB).gte(startTB)); - boolQueryBuilder.must().add(QueryBuilders.termQuery(EndpointInventory.SERVICE_ID, serviceId)); + boolQueryBuilder.must().add(QueryBuilders.termQuery(EndpointTraffic.SERVICE_ID, serviceId)); return aggregation(indexName, valueCName, sourceBuilder, topN, order); } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java index a76ed67d82..ee99ae5db8 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java @@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query; import com.google.common.base.Strings; import java.io.IOException; import java.util.List; +import org.apache.skywalking.apm.util.StringUtil; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord; import org.apache.skywalking.oap.server.core.analysis.record.Record; @@ -48,9 +49,9 @@ public class LogQueryEsDAO extends EsDAO implements ILogQueryDAO { } @Override - public Logs queryLogs(String metricName, int serviceId, int serviceInstanceId, int endpointId, String traceId, - LogState state, String stateCode, Pagination paging, int from, int limit, long startSecondTB, - long endSecondTB) throws IOException { + public Logs queryLogs(String metricName, int serviceId, int serviceInstanceId, String endpointId, String traceId, + LogState state, String stateCode, Pagination paging, int from, int limit, long startSecondTB, + long endSecondTB) throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); @@ -68,7 +69,7 @@ public class LogQueryEsDAO extends EsDAO implements ILogQueryDAO { boolQueryBuilder.must() .add(QueryBuilders.termQuery(AbstractLogRecord.SERVICE_INSTANCE_ID, serviceInstanceId)); } - if (endpointId != Const.NONE) { + if (StringUtil.isNotEmpty(endpointId)) { boolQueryBuilder.must().add(QueryBuilders.termQuery(AbstractLogRecord.ENDPOINT_ID, endpointId)); } if (!Strings.isNullOrEmpty(stateCode)) { @@ -79,10 +80,13 @@ public class LogQueryEsDAO extends EsDAO implements ILogQueryDAO { } if (LogState.ERROR.equals(state)) { boolQueryBuilder.must() - .add(QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, BooleanUtils.booleanToValue(true))); + .add( + QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, BooleanUtils.booleanToValue(true))); } else if (LogState.SUCCESS.equals(state)) { boolQueryBuilder.must() - .add(QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, BooleanUtils.booleanToValue(false))); + .add(QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, + BooleanUtils.booleanToValue(false) + )); } sourceBuilder.size(limit); @@ -98,12 +102,14 @@ public class LogQueryEsDAO extends EsDAO implements ILogQueryDAO { log.setServiceId(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.SERVICE_ID)).intValue()); log.setServiceInstanceId(((Number) searchHit.getSourceAsMap() .get(AbstractLogRecord.SERVICE_INSTANCE_ID)).intValue()); - log.setEndpointId(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_ID)).intValue()); + log.setEndpointId((String) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_ID)); + log.setEndpointName((String) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_NAME)); log.setError(BooleanUtils.valueToBoolean(((Number) searchHit.getSourceAsMap() .get(AbstractLogRecord.IS_ERROR)).intValue())); log.setStatusCode((String) searchHit.getSourceAsMap().get(AbstractLogRecord.STATUS_CODE)); log.setContentType(ContentType.instanceOf(((Number) searchHit.getSourceAsMap() - .get(AbstractLogRecord.CONTENT_TYPE)).intValue())); + .get( + AbstractLogRecord.CONTENT_TYPE)).intValue())); log.setContent((String) searchHit.getSourceAsMap().get(AbstractLogRecord.CONTENT)); logs.getLogs().add(log); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java index 8e2369423a..ff42b4abc7 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java @@ -26,13 +26,14 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.query.entity.Attribute; import org.apache.skywalking.oap.server.core.query.entity.Database; import org.apache.skywalking.oap.server.core.query.entity.Endpoint; import org.apache.skywalking.oap.server.core.query.entity.LanguageTrans; import org.apache.skywalking.oap.server.core.query.entity.Service; import org.apache.skywalking.oap.server.core.query.entity.ServiceInstance; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; import org.apache.skywalking.oap.server.core.register.NodeType; import org.apache.skywalking.oap.server.core.register.RegisterSource; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; @@ -83,6 +84,9 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO { return (int) response.getHits().getTotalHits(); } + /** + * @since 7.0.0, as EndpointInventory has been replaced by EndpointTraffic. This is not an accurate number anymore. + */ @Override public int numOfEndpoint() throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); @@ -90,12 +94,12 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO { BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); boolQueryBuilder.must() - .add(QueryBuilders.termQuery(EndpointInventory.DETECT_POINT, DetectPoint.SERVER.ordinal())); + .add(QueryBuilders.termQuery(EndpointTraffic.DETECT_POINT, DetectPoint.SERVER.value())); sourceBuilder.query(boolQueryBuilder); sourceBuilder.size(0); - SearchResponse response = getClient().search(EndpointInventory.INDEX_NAME, sourceBuilder); + SearchResponse response = getClient().search(EndpointTraffic.INDEX_NAME, sourceBuilder); return (int) response.getHits().getTotalHits(); } @@ -214,41 +218,50 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO { } @Override - public List searchEndpoint(String keyword, String serviceId, int limit) throws IOException { + public List searchEndpoint(String keyword, int serviceId, int limit) throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); - boolQueryBuilder.must().add(QueryBuilders.termQuery(EndpointInventory.SERVICE_ID, serviceId)); + boolQueryBuilder.must().add(QueryBuilders.termQuery(EndpointTraffic.SERVICE_ID, serviceId)); if (!Strings.isNullOrEmpty(keyword)) { - String matchCName = MatchCNameBuilder.INSTANCE.build(EndpointInventory.NAME); + String matchCName = MatchCNameBuilder.INSTANCE.build(EndpointTraffic.NAME); boolQueryBuilder.must().add(QueryBuilders.matchQuery(matchCName, keyword)); } boolQueryBuilder.must() - .add(QueryBuilders.termQuery(EndpointInventory.DETECT_POINT, DetectPoint.SERVER.ordinal())); + .add(QueryBuilders.termQuery(EndpointTraffic.DETECT_POINT, DetectPoint.SERVER.value())); sourceBuilder.query(boolQueryBuilder); - sourceBuilder.size(limit); + /** + * Query the dataset by a larger limit condition and distinct in the memory, + * in order to avoid the storage level distinct. + * This is a match query only, don't need 100% accurate. + */ + sourceBuilder.size(limit * 7); - SearchResponse response = getClient().search(EndpointInventory.INDEX_NAME, sourceBuilder); + SearchResponse response = getClient().search(EndpointTraffic.INDEX_NAME, sourceBuilder); List endpoints = new ArrayList<>(); for (SearchHit searchHit : response.getHits()) { Map sourceAsMap = searchHit.getSourceAsMap(); + final EndpointTraffic endpointTraffic = new EndpointTraffic.Builder().map2Data(sourceAsMap); + Endpoint endpoint = new Endpoint(); - endpoint.setId(((Number) sourceAsMap.get(EndpointInventory.SEQUENCE)).intValue()); - endpoint.setName((String) sourceAsMap.get(EndpointInventory.NAME)); + endpoint.setId(EndpointTraffic.buildId(endpointTraffic)); + endpoint.setName((String) sourceAsMap.get(EndpointTraffic.NAME)); endpoints.add(endpoint); } - return endpoints; + final List endpointList = endpoints.stream().distinct().collect(Collectors.toList()); + + return endpointList.size() > limit ? endpointList.subList(0, limit) : endpointList; } @Override public List getServiceInstances(long startTimestamp, long endTimestamp, - String serviceId) throws IOException { + String serviceId) throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); @@ -285,8 +298,9 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO { } else if (key.equals(PROCESS_NO)) { serviceInstance.getAttributes().add(new Attribute(PROCESS_NO, value)); } else if (key.equals(IPV4S)) { - List ipv4s = ServiceInstanceInventory.PropertyUtil.ipv4sDeserialize(properties.get(IPV4S) - .getAsString()); + List ipv4s = ServiceInstanceInventory.PropertyUtil.ipv4sDeserialize( + properties.get(IPV4S) + .getAsString()); for (String ipv4 : ipv4s) { serviceInstance.getAttributes() .add(new Attribute(ServiceInstanceInventory.PropertyUtil.IPV4S, ipv4)); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java index 27b66bbe99..9a6695b34d 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java @@ -18,9 +18,13 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.apache.skywalking.oap.server.core.UnexpectedException; import org.apache.skywalking.oap.server.core.analysis.Downsampling; import org.apache.skywalking.oap.server.core.analysis.manual.RelationDefineUtil; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation.EndpointRelationServerSideMetrics; import org.apache.skywalking.oap.server.core.analysis.manual.relation.instance.ServiceInstanceRelationClientSideMetrics; import org.apache.skywalking.oap.server.core.analysis.manual.relation.instance.ServiceInstanceRelationServerSideMetrics; @@ -41,10 +45,6 @@ import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.builder.SearchSourceBuilder; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { public TopologyQueryEsDAO(ElasticSearchClient client) { @@ -52,8 +52,10 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { } @Override - public List loadSpecifiedServerSideServiceRelations(Downsampling downsampling, long startTB, - long endTB, List serviceIds) throws IOException { + public List loadSpecifiedServerSideServiceRelations(Downsampling downsampling, + long startTB, + long endTB, + List serviceIds) throws IOException { if (CollectionUtils.isEmpty(serviceIds)) { throw new UnexpectedException("Service id is empty"); } @@ -67,8 +69,10 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { } @Override - public List loadSpecifiedClientSideServiceRelations(Downsampling downsampling, long startTB, - long endTB, List serviceIds) throws IOException { + public List loadSpecifiedClientSideServiceRelations(Downsampling downsampling, + long startTB, + long endTB, + List serviceIds) throws IOException { if (CollectionUtils.isEmpty(serviceIds)) { throw new UnexpectedException("Service id is empty"); } @@ -82,7 +86,7 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { } private void setQueryCondition(SearchSourceBuilder sourceBuilder, long startTB, long endTB, - List serviceIds) { + List serviceIds) { BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); boolQuery.must() .add(QueryBuilders.rangeQuery(ServiceRelationServerSideMetrics.TIME_BUCKET).gte(startTB).lte(endTB)); @@ -92,22 +96,32 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { if (serviceIds.size() == 1) { serviceIdBoolQuery.should() - .add(QueryBuilders.termQuery(ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, serviceIds - .get(0))); + .add( + QueryBuilders.termQuery(ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, serviceIds + .get(0))); serviceIdBoolQuery.should() - .add(QueryBuilders.termQuery(ServiceRelationServerSideMetrics.DEST_SERVICE_ID, serviceIds.get(0))); + .add(QueryBuilders.termQuery( + ServiceRelationServerSideMetrics.DEST_SERVICE_ID, + serviceIds.get(0) + )); } else { serviceIdBoolQuery.should() - .add(QueryBuilders.termsQuery(ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, serviceIds)); + .add(QueryBuilders.termsQuery( + ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, + serviceIds + )); serviceIdBoolQuery.should() - .add(QueryBuilders.termsQuery(ServiceRelationServerSideMetrics.DEST_SERVICE_ID, serviceIds)); + .add(QueryBuilders.termsQuery( + ServiceRelationServerSideMetrics.DEST_SERVICE_ID, + serviceIds + )); } sourceBuilder.query(boolQuery); } @Override public List loadServerSideServiceRelations(Downsampling downsampling, long startTB, - long endTB) throws IOException { + long endTB) throws IOException { String indexName = ModelName.build(downsampling, ServiceRelationServerSideMetrics.INDEX_NAME); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); sourceBuilder.query(QueryBuilders.rangeQuery(ServiceRelationServerSideMetrics.TIME_BUCKET) @@ -120,7 +134,7 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { @Override public List loadClientSideServiceRelations(Downsampling downsampling, long startTB, - long endTB) throws IOException { + long endTB) throws IOException { String indexName = ModelName.build(downsampling, ServiceRelationClientSideMetrics.INDEX_NAME); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); sourceBuilder.query(QueryBuilders.rangeQuery(ServiceRelationServerSideMetrics.TIME_BUCKET) @@ -132,8 +146,11 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { } @Override - public List loadServerSideServiceInstanceRelations(int clientServiceId, int serverServiceId, - Downsampling downsampling, long startTB, long endTB) throws IOException { + public List loadServerSideServiceInstanceRelations(int clientServiceId, + int serverServiceId, + Downsampling downsampling, + long startTB, + long endTB) throws IOException { String indexName = ModelName.build(downsampling, ServiceInstanceRelationServerSideMetrics.INDEX_NAME); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); sourceBuilder.size(0); @@ -143,8 +160,11 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { } @Override - public List loadClientSideServiceInstanceRelations(int clientServiceId, int serverServiceId, - Downsampling downsampling, long startTB, long endTB) throws IOException { + public List loadClientSideServiceInstanceRelations(int clientServiceId, + int serverServiceId, + Downsampling downsampling, + long startTB, + long endTB) throws IOException { String indexName = ModelName.build(downsampling, ServiceInstanceRelationClientSideMetrics.INDEX_NAME); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); sourceBuilder.size(0); @@ -154,7 +174,7 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { } private void setInstanceQueryCondition(SearchSourceBuilder sourceBuilder, long startTB, long endTB, - int clientServiceId, int serverServiceId) { + int clientServiceId, int serverServiceId) { BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); boolQuery.must() .add(QueryBuilders.rangeQuery(EndpointRelationServerSideMetrics.TIME_BUCKET).gte(startTB).lte(endTB)); @@ -165,21 +185,27 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { BoolQueryBuilder serverRelationBoolQuery = new BoolQueryBuilder(); serviceIdBoolQuery.should(serverRelationBoolQuery); - serverRelationBoolQuery.must(QueryBuilders.termQuery(ServiceInstanceRelationServerSideMetrics.SOURCE_SERVICE_ID, clientServiceId)); - serverRelationBoolQuery.must(QueryBuilders.termQuery(ServiceInstanceRelationServerSideMetrics.DEST_SERVICE_ID, serverServiceId)); + serverRelationBoolQuery.must( + QueryBuilders.termQuery(ServiceInstanceRelationServerSideMetrics.SOURCE_SERVICE_ID, clientServiceId)); + serverRelationBoolQuery.must( + QueryBuilders.termQuery(ServiceInstanceRelationServerSideMetrics.DEST_SERVICE_ID, serverServiceId)); BoolQueryBuilder clientRelationBoolQuery = new BoolQueryBuilder(); serviceIdBoolQuery.should(clientRelationBoolQuery); - clientRelationBoolQuery.must(QueryBuilders.termQuery(ServiceInstanceRelationServerSideMetrics.DEST_SERVICE_ID, clientServiceId)); - clientRelationBoolQuery.must(QueryBuilders.termQuery(ServiceInstanceRelationServerSideMetrics.SOURCE_SERVICE_ID, serverServiceId)); + clientRelationBoolQuery.must( + QueryBuilders.termQuery(ServiceInstanceRelationServerSideMetrics.DEST_SERVICE_ID, clientServiceId)); + clientRelationBoolQuery.must( + QueryBuilders.termQuery(ServiceInstanceRelationServerSideMetrics.SOURCE_SERVICE_ID, serverServiceId)); sourceBuilder.query(boolQuery); } @Override - public List loadSpecifiedDestOfServerSideEndpointRelations(Downsampling downsampling, long startTB, - long endTB, int destEndpointId) throws IOException { + public List loadSpecifiedDestOfServerSideEndpointRelations(Downsampling downsampling, + long startTB, + long endTB, + String destEndpointId) throws IOException { String indexName = ModelName.build(downsampling, EndpointRelationServerSideMetrics.INDEX_NAME); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); @@ -192,17 +218,21 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { BoolQueryBuilder serviceIdBoolQuery = QueryBuilders.boolQuery(); boolQuery.must().add(serviceIdBoolQuery); serviceIdBoolQuery.should() - .add(QueryBuilders.termQuery(EndpointRelationServerSideMetrics.SOURCE_ENDPOINT_ID, destEndpointId)); + .add(QueryBuilders.termQuery( + EndpointRelationServerSideMetrics.SOURCE_ENDPOINT, + destEndpointId + )); serviceIdBoolQuery.should() - .add(QueryBuilders.termQuery(EndpointRelationServerSideMetrics.DEST_ENDPOINT_ID, destEndpointId)); + .add( + QueryBuilders.termQuery(EndpointRelationServerSideMetrics.DEST_ENDPOINT, destEndpointId)); sourceBuilder.query(boolQuery); - return load(sourceBuilder, indexName, DetectPoint.SERVER); + return loadEndpoint(sourceBuilder, indexName, DetectPoint.SERVER); } private List load(SearchSourceBuilder sourceBuilder, String indexName, - DetectPoint detectPoint) throws IOException { + DetectPoint detectPoint) throws IOException { sourceBuilder.aggregation(AggregationBuilders.terms(Metrics.ENTITY_ID).field(Metrics.ENTITY_ID).size(1000)); SearchResponse response = getClient().search(indexName, sourceBuilder); @@ -214,8 +244,36 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO { RelationDefineUtil.RelationDefine relationDefine = RelationDefineUtil.splitEntityId(entityId); Call.CallDetail call = new Call.CallDetail(); - call.setSource(relationDefine.getSource()); - call.setTarget(relationDefine.getDest()); + call.setSource(String.valueOf(relationDefine.getSource())); + call.setTarget(String.valueOf(relationDefine.getDest())); + call.setComponentId(relationDefine.getComponentId()); + call.setDetectPoint(detectPoint); + call.generateID(); + calls.add(call); + } + return calls; + } + + private List loadEndpoint(SearchSourceBuilder sourceBuilder, String indexName, + DetectPoint detectPoint) throws IOException { + sourceBuilder.aggregation(AggregationBuilders.terms(Metrics.ENTITY_ID).field(Metrics.ENTITY_ID).size(1000)); + + SearchResponse response = getClient().search(indexName, sourceBuilder); + + List calls = new ArrayList<>(); + Terms entityTerms = response.getAggregations().get(Metrics.ENTITY_ID); + for (Terms.Bucket entityBucket : entityTerms.getBuckets()) { + String entityId = entityBucket.getKeyAsString(); + + RelationDefineUtil.EndpointRelationDefine relationDefine = RelationDefineUtil.splitEndpointRelationEntityId( + entityId); + Call.CallDetail call = new Call.CallDetail(); + call.setSource(EndpointTraffic.buildId(relationDefine.getSourceServiceId(), relationDefine.getSource(), + detectPoint + )); + call.setTarget(EndpointTraffic.buildId(relationDefine.getDestServiceId(), relationDefine.getDest(), + detectPoint + )); call.setComponentId(relationDefine.getComponentId()); call.setDetectPoint(detectPoint); call.generateID(); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java index 65ca71333d..e1330453af 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java @@ -54,9 +54,19 @@ public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO { } @Override - public TraceBrief queryBasicTraces(long startSecondTB, long endSecondTB, long minDuration, long maxDuration, - String endpointName, int serviceId, int serviceInstanceId, int endpointId, String traceId, int limit, int from, - TraceState traceState, QueryOrder queryOrder) throws IOException { + public TraceBrief queryBasicTraces(long startSecondTB, + long endSecondTB, + long minDuration, + long maxDuration, + String endpointName, + int serviceId, + int serviceInstanceId, + String endpointId, + String traceId, + int limit, + int from, + TraceState traceState, + QueryOrder queryOrder) throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); @@ -87,7 +97,7 @@ public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO { if (serviceInstanceId != 0) { boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.SERVICE_INSTANCE_ID, serviceInstanceId)); } - if (endpointId != 0) { + if (!Strings.isNullOrEmpty(endpointId)) { boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.ENDPOINT_ID, endpointId)); } if (!Strings.isNullOrEmpty(traceId)) { @@ -125,7 +135,8 @@ public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO { basicTrace.getEndpointNames().add((String) searchHit.getSourceAsMap().get(SegmentRecord.ENDPOINT_NAME)); basicTrace.setDuration(((Number) searchHit.getSourceAsMap().get(SegmentRecord.LATENCY)).intValue()); basicTrace.setError(BooleanUtils.valueToBoolean(((Number) searchHit.getSourceAsMap() - .get(SegmentRecord.IS_ERROR)).intValue())); + .get( + SegmentRecord.IS_ERROR)).intValue())); basicTrace.getTraceIds().add((String) searchHit.getSourceAsMap().get(SegmentRecord.TRACE_ID)); traceBrief.getTraces().add(basicTrace); } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java index 0951c40eb5..21a8685e9d 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/StorageModuleElasticsearch7Provider.java @@ -34,7 +34,6 @@ import org.apache.skywalking.oap.server.core.storage.IRegisterLockDAO; import org.apache.skywalking.oap.server.core.storage.StorageDAO; import org.apache.skywalking.oap.server.core.storage.StorageException; import org.apache.skywalking.oap.server.core.storage.StorageModule; -import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO; @@ -63,7 +62,6 @@ import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopNR import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query.TopologyQueryEsDAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.ttl.ElasticsearchStorageTTL; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.base.StorageEs7Installer; -import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache.EndpointInventoryCacheEs7DAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache.NetworkAddressInventoryCacheEs7DAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache.ServiceInstanceInventoryCacheEs7DAO; import org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.cache.ServiceInventoryCacheEs7DAO; @@ -171,8 +169,6 @@ public class StorageModuleElasticsearch7Provider extends ModuleProvider { elasticSearch7Client, config.getResultWindowMaxSize() )); - this.registerServiceImplementation( - IEndpointInventoryCacheDAO.class, new EndpointInventoryCacheEs7DAO(elasticSearch7Client)); this.registerServiceImplementation( INetworkAddressInventoryCacheDAO.class, new NetworkAddressInventoryCacheEs7DAO( elasticSearch7Client, diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/EndpointInventoryCacheEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/EndpointInventoryCacheEs7DAO.java deleted file mode 100644 index ea6b651962..0000000000 --- a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/cache/EndpointInventoryCacheEs7DAO.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.storage.plugin.elasticsearch7.cache; - -import org.apache.skywalking.oap.server.core.register.EndpointInventory; -import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.cache.EndpointInventoryCacheEsDAO; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class EndpointInventoryCacheEs7DAO extends EndpointInventoryCacheEsDAO { - - private static final Logger logger = LoggerFactory.getLogger(EndpointInventoryCacheEs7DAO.class); - - public EndpointInventoryCacheEs7DAO(ElasticSearchClient client) { - super(client); - } - - @Override - public EndpointInventory get(int endpointId) { - try { - SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); - searchSourceBuilder.query(QueryBuilders.termQuery(EndpointInventory.SEQUENCE, endpointId)); - searchSourceBuilder.size(1); - - SearchResponse response = getClient().search(EndpointInventory.INDEX_NAME, searchSourceBuilder); - if (response.getHits().getTotalHits().value == 1) { - SearchHit searchHit = response.getHits().getAt(0); - return builder.map2Data(searchHit.getSourceAsMap()); - } else { - return null; - } - } catch (Throwable e) { - logger.error(e.getMessage(), e); - return null; - } - } -} diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/LogQueryEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/LogQueryEs7DAO.java index ff17d726e9..5683eea2be 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/LogQueryEs7DAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/LogQueryEs7DAO.java @@ -19,6 +19,9 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query; import com.google.common.base.Strings; +import java.io.IOException; +import java.util.List; +import org.apache.skywalking.apm.util.StringUtil; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord; import org.apache.skywalking.oap.server.core.analysis.record.Record; @@ -38,9 +41,6 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; -import java.io.IOException; -import java.util.List; - import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.TRACE_ID; public class LogQueryEs7DAO extends EsDAO implements ILogQueryDAO { @@ -49,9 +49,9 @@ public class LogQueryEs7DAO extends EsDAO implements ILogQueryDAO { } @Override - public Logs queryLogs(String metricName, int serviceId, int serviceInstanceId, int endpointId, String traceId, - LogState state, String stateCode, Pagination paging, int from, int limit, long startSecondTB, - long endSecondTB) throws IOException { + public Logs queryLogs(String metricName, int serviceId, int serviceInstanceId, String endpointId, String traceId, + LogState state, String stateCode, Pagination paging, int from, int limit, long startSecondTB, + long endSecondTB) throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); @@ -69,7 +69,7 @@ public class LogQueryEs7DAO extends EsDAO implements ILogQueryDAO { boolQueryBuilder.must() .add(QueryBuilders.termQuery(AbstractLogRecord.SERVICE_INSTANCE_ID, serviceInstanceId)); } - if (endpointId != Const.NONE) { + if (StringUtil.isNotEmpty(endpointId)) { boolQueryBuilder.must().add(QueryBuilders.termQuery(AbstractLogRecord.ENDPOINT_ID, endpointId)); } if (!Strings.isNullOrEmpty(stateCode)) { @@ -80,10 +80,13 @@ public class LogQueryEs7DAO extends EsDAO implements ILogQueryDAO { } if (LogState.ERROR.equals(state)) { boolQueryBuilder.must() - .add(QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, BooleanUtils.booleanToValue(true))); + .add( + QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, BooleanUtils.booleanToValue(true))); } else if (LogState.SUCCESS.equals(state)) { boolQueryBuilder.must() - .add(QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, BooleanUtils.booleanToValue(false))); + .add(QueryBuilders.termQuery(AbstractLogRecord.IS_ERROR, + BooleanUtils.booleanToValue(false) + )); } sourceBuilder.size(limit); @@ -99,12 +102,14 @@ public class LogQueryEs7DAO extends EsDAO implements ILogQueryDAO { log.setServiceId(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.SERVICE_ID)).intValue()); log.setServiceInstanceId(((Number) searchHit.getSourceAsMap() .get(AbstractLogRecord.SERVICE_INSTANCE_ID)).intValue()); - log.setEndpointId(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_ID)).intValue()); + log.setEndpointId((String) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_ID)); + log.setEndpointName((String) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_NAME)); log.setError(BooleanUtils.valueToBoolean(((Number) searchHit.getSourceAsMap() .get(AbstractLogRecord.IS_ERROR)).intValue())); log.setStatusCode((String) searchHit.getSourceAsMap().get(AbstractLogRecord.STATUS_CODE)); log.setContentType(ContentType.instanceOf(((Number) searchHit.getSourceAsMap() - .get(AbstractLogRecord.CONTENT_TYPE)).intValue())); + .get( + AbstractLogRecord.CONTENT_TYPE)).intValue())); log.setContent((String) searchHit.getSourceAsMap().get(AbstractLogRecord.CONTENT)); logs.getLogs().add(log); diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetadataQueryEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetadataQueryEs7DAO.java index d421b69b20..29ab5e2b96 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetadataQueryEs7DAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/MetadataQueryEs7DAO.java @@ -19,7 +19,7 @@ package org.apache.skywalking.oap.server.storage.plugin.elasticsearch7.query; import java.io.IOException; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.register.NodeType; import org.apache.skywalking.oap.server.core.register.ServiceInventory; import org.apache.skywalking.oap.server.core.source.DetectPoint; @@ -54,6 +54,9 @@ public class MetadataQueryEs7DAO extends MetadataQueryEsDAO { return (int) response.getHits().getTotalHits().value; } + /** + * @since 7.0.0, as EndpointInventory has been replaced by EndpointTraffic. This is not an accurate number anymore. + */ @Override public int numOfEndpoint() throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); @@ -61,12 +64,12 @@ public class MetadataQueryEs7DAO extends MetadataQueryEsDAO { BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); boolQueryBuilder.must() - .add(QueryBuilders.termQuery(EndpointInventory.DETECT_POINT, DetectPoint.SERVER.ordinal())); + .add(QueryBuilders.termQuery(EndpointTraffic.DETECT_POINT, DetectPoint.SERVER.value())); sourceBuilder.query(boolQueryBuilder); sourceBuilder.size(0); - SearchResponse response = getClient().search(EndpointInventory.INDEX_NAME, sourceBuilder); + SearchResponse response = getClient().search(EndpointTraffic.INDEX_NAME, sourceBuilder); return (int) response.getHits().getTotalHits().value; } diff --git a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/TraceQueryEs7DAO.java b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/TraceQueryEs7DAO.java index ea89e6e3ff..862bf54f12 100644 --- a/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/TraceQueryEs7DAO.java +++ b/oap-server/server-storage-plugin/storage-elasticsearch7-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch7/query/TraceQueryEs7DAO.java @@ -48,7 +48,7 @@ public class TraceQueryEs7DAO extends TraceQueryEsDAO { @Override public TraceBrief queryBasicTraces(long startSecondTB, long endSecondTB, long minDuration, long maxDuration, - String endpointName, int serviceId, int serviceInstanceId, int endpointId, String traceId, int limit, int from, + String endpointName, int serviceId, int serviceInstanceId, String endpointId, String traceId, int limit, int from, TraceState traceState, QueryOrder queryOrder) throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); @@ -80,7 +80,7 @@ public class TraceQueryEs7DAO extends TraceQueryEsDAO { if (serviceInstanceId != 0) { boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.SERVICE_INSTANCE_ID, serviceInstanceId)); } - if (endpointId != 0) { + if (!Strings.isNullOrEmpty(endpointId)) { boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentRecord.ENDPOINT_ID, endpointId)); } if (!Strings.isNullOrEmpty(traceId)) { diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxModelConstants.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxModelConstants.java index ec54fec83b..18dd47dc28 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxModelConstants.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxModelConstants.java @@ -20,7 +20,7 @@ package org.apache.skywalking.oap.server.storage.plugin.influxdb; public interface InfluxModelConstants { /** - * Override column because the 'duration' is a identifier of InfluxDB. + * Override column because the 'duration' is the identifier of InfluxDB. */ String DURATION = "dur"; } diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxStorageProvider.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxStorageProvider.java index e294ccb104..38dfd00d9a 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxStorageProvider.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/InfluxStorageProvider.java @@ -27,7 +27,6 @@ import org.apache.skywalking.oap.server.core.storage.IRegisterLockDAO; import org.apache.skywalking.oap.server.core.storage.StorageDAO; import org.apache.skywalking.oap.server.core.storage.StorageException; import org.apache.skywalking.oap.server.core.storage.StorageModule; -import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO; @@ -53,10 +52,11 @@ import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedExcepti import org.apache.skywalking.oap.server.storage.plugin.influxdb.base.BatchDAO; import org.apache.skywalking.oap.server.storage.plugin.influxdb.base.HistoryDeleteDAO; import org.apache.skywalking.oap.server.storage.plugin.influxdb.base.InfluxStorageDAO; -import org.apache.skywalking.oap.server.storage.plugin.influxdb.installer.H2Installer; -import org.apache.skywalking.oap.server.storage.plugin.influxdb.installer.MySQLInstaller; +import org.apache.skywalking.oap.server.storage.plugin.influxdb.installer.InfluxDBH2MetaDBInstaller; +import org.apache.skywalking.oap.server.storage.plugin.influxdb.installer.InfluxDBMySQLMetaDBInstaller; import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.AggregationQuery; import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.AlarmQuery; +import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.InfluxMetadataQueryDAO; import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.LogQuery; import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.MetricsQuery; import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.ProfileTaskLogQuery; @@ -65,8 +65,6 @@ import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.ProfileThr import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.TopNRecordsQuery; import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.TopologyQuery; import org.apache.skywalking.oap.server.storage.plugin.influxdb.query.TraceQuery; -import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2EndpointInventoryCacheDAO; -import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetadataQueryDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2NetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2RegisterLockDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2RegisterLockInstaller; @@ -119,11 +117,10 @@ public class InfluxStorageProvider extends ModuleProvider { this.registerServiceImplementation(IServiceInventoryCacheDAO.class, new H2ServiceInventoryCacheDAO(client)); this.registerServiceImplementation( IServiceInstanceInventoryCacheDAO.class, new H2ServiceInstanceInventoryCacheDAO(client)); - this.registerServiceImplementation(IEndpointInventoryCacheDAO.class, new H2EndpointInventoryCacheDAO(client)); this.registerServiceImplementation( INetworkAddressInventoryCacheDAO.class, new H2NetworkAddressInventoryCacheDAO(client)); this.registerServiceImplementation( - IMetadataQueryDAO.class, new H2MetadataQueryDAO(client, config.getMetadataQueryMaxSize())); + IMetadataQueryDAO.class, new InfluxMetadataQueryDAO(influxClient, client, config.getMetadataQueryMaxSize())); this.registerServiceImplementation(ITopologyQueryDAO.class, new TopologyQuery(influxClient)); this.registerServiceImplementation(IMetricsQueryDAO.class, new MetricsQuery(influxClient)); @@ -151,9 +148,9 @@ public class InfluxStorageProvider extends ModuleProvider { ModelInstaller installer; if (config.getMetabaseType().equalsIgnoreCase("h2")) { - installer = new H2Installer(getManager()); + installer = new InfluxDBH2MetaDBInstaller(getManager()); } else { - installer = new MySQLInstaller(getManager()); + installer = new InfluxDBMySQLMetaDBInstaller(getManager()); } installer.install(client); new H2RegisterLockInstaller().install(client, lockDAO); diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/base/MetricsDAO.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/base/MetricsDAO.java index b44638cb11..98df2b303a 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/base/MetricsDAO.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/base/MetricsDAO.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import org.apache.skywalking.oap.server.core.analysis.TimeBucket; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.storage.IMetricsDAO; import org.apache.skywalking.oap.server.core.storage.StorageBuilder; @@ -45,6 +46,8 @@ import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select; public class MetricsDAO implements IMetricsDAO { public static final String TAG_ENTITY_ID = "_entity_id"; + public static final String TAG_ENDPOINT_OWNER_SERVICE = "_service_id"; + public static final String TAG_ENDPOINT_NAME = "_endpoint_name"; private final StorageBuilder storageBuilder; private final InfluxClient client; @@ -94,9 +97,19 @@ public class MetricsDAO implements IMetricsDAO { @Override public InsertRequest prepareBatchInsert(Model model, Metrics metrics) throws IOException { final long timestamp = TimeBucket.getTimestamp(metrics.getTimeBucket(), model.getDownsampling()); - return new InfluxInsertRequest(model, metrics, storageBuilder) - .time(timestamp, TimeUnit.MILLISECONDS) - .addFieldAsTag(Metrics.ENTITY_ID, TAG_ENTITY_ID); + if (metrics instanceof EndpointTraffic) { + /** + * @since 7.1.0 EndpointTraffic is a special manual metrics, to replace the old Endpoint Inventory. + */ + return new InfluxInsertRequest(model, metrics, storageBuilder) + .time(timestamp, TimeUnit.MILLISECONDS) + .addFieldAsTag(EndpointTraffic.SERVICE_ID, TAG_ENDPOINT_OWNER_SERVICE) + .addFieldAsTag(EndpointTraffic.NAME, TAG_ENDPOINT_NAME); + } else { + return new InfluxInsertRequest(model, metrics, storageBuilder) + .time(timestamp, TimeUnit.MILLISECONDS) + .addFieldAsTag(Metrics.ENTITY_ID, TAG_ENTITY_ID); + } } @Override diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/H2Installer.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/InfluxDBH2MetaDBInstaller.java similarity index 92% rename from oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/H2Installer.java rename to oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/InfluxDBH2MetaDBInstaller.java index 347f16bd71..a536f17700 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/H2Installer.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/InfluxDBH2MetaDBInstaller.java @@ -26,9 +26,9 @@ import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxModelConstants; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TableInstaller; -public class H2Installer extends H2TableInstaller { +public class InfluxDBH2MetaDBInstaller extends H2TableInstaller { - public H2Installer(ModuleManager moduleManager) { + public InfluxDBH2MetaDBInstaller(ModuleManager moduleManager) { super(moduleManager); overrideColumnName(ProfileTaskRecord.DURATION, InfluxModelConstants.DURATION); } diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/MySQLInstaller.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/InfluxDBMySQLMetaDBInstaller.java similarity index 92% rename from oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/MySQLInstaller.java rename to oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/InfluxDBMySQLMetaDBInstaller.java index 019d769499..3ac7accfe4 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/MySQLInstaller.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/installer/InfluxDBMySQLMetaDBInstaller.java @@ -26,9 +26,9 @@ import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxModelConstants; import org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql.MySQLTableInstaller; -public class MySQLInstaller extends MySQLTableInstaller { +public class InfluxDBMySQLMetaDBInstaller extends MySQLTableInstaller { - public MySQLInstaller(ModuleManager moduleManager) { + public InfluxDBMySQLMetaDBInstaller(ModuleManager moduleManager) { super(moduleManager); overrideColumnName(ProfileTaskRecord.DURATION, InfluxModelConstants.DURATION); } diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/AggregationQuery.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/AggregationQuery.java index 36436bbf26..de8765c400 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/AggregationQuery.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/AggregationQuery.java @@ -27,7 +27,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.oap.server.core.analysis.Downsampling; import org.apache.skywalking.oap.server.core.query.entity.Order; import org.apache.skywalking.oap.server.core.query.entity.TopNEntity; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; import org.apache.skywalking.oap.server.core.storage.model.ModelName; import org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO; @@ -85,7 +85,7 @@ public class AggregationQuery implements IAggregationQueryDAO { long startTB, long endTB, Order order) throws IOException { return getTopNEntity( downsampling, indName, - subQuery(EndpointInventory.SERVICE_ID, serviceId, indName, valueCName, startTB, endTB), order, topN + subQuery(EndpointTraffic.SERVICE_ID, serviceId, indName, valueCName, startTB, endTB), order, topN ); } diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/InfluxMetadataQueryDAO.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/InfluxMetadataQueryDAO.java new file mode 100644 index 0000000000..94611a6801 --- /dev/null +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/InfluxMetadataQueryDAO.java @@ -0,0 +1,112 @@ +/* + * 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.storage.plugin.influxdb.query; + +import com.google.common.base.Strings; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; +import org.apache.skywalking.oap.server.core.query.entity.Endpoint; +import org.apache.skywalking.oap.server.core.source.DetectPoint; +import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient; +import org.apache.skywalking.oap.server.storage.plugin.influxdb.InfluxClient; +import org.apache.skywalking.oap.server.storage.plugin.influxdb.base.MetricsDAO; +import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetadataQueryDAO; +import org.influxdb.dto.Query; +import org.influxdb.dto.QueryResult; +import org.influxdb.querybuilder.SelectQueryImpl; +import org.influxdb.querybuilder.WhereQueryImpl; + +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.contains; +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq; +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select; + +/** + * InfluxMetadataQueryDAO is a hybrid dao implementation. + * + * @since 7.1.0 Endpoint data is save in the Endpoint Traffic, rather than endpoint inventory(deleted). The Endpoint + * Traffic is a time-series metrics data, so need the influxdb implementation. + */ +public class InfluxMetadataQueryDAO extends H2MetadataQueryDAO { + private InfluxClient client; + + public InfluxMetadataQueryDAO(final InfluxClient client, final JDBCHikariCPClient h2Client, + final int metadataQueryMaxSize) { + super(h2Client, metadataQueryMaxSize); + this.client = client; + } + + @Override + public int numOfEndpoint() throws IOException { + WhereQueryImpl countQuery = select() + .count(EndpointTraffic.ENTITY_ID) + .from(client.getDatabase(), EndpointTraffic.INDEX_NAME) + .where(); + countQuery.where(eq(EndpointTraffic.DETECT_POINT, DetectPoint.SERVER.value())); + + Query query = new Query(countQuery.getCommand()); + + final QueryResult.Series series = client.queryForSingleSeries(query); + if (series == null) { + return 0; + } + + return ((Number) series.getValues().get(0).get(1)).intValue(); + } + + @Override + public List searchEndpoint(final String keyword, + final int serviceId, + final int limit) throws IOException { + final String endpointName = '\"' + EndpointTraffic.NAME + '\"'; + + WhereQueryImpl endpointQuery = select() + .column(EndpointTraffic.SERVICE_ID) + .column(endpointName) + .column(EndpointTraffic.DETECT_POINT) + .from(client.getDatabase(), EndpointTraffic.INDEX_NAME) + .where(); + endpointQuery.where(eq(MetricsDAO.TAG_ENDPOINT_OWNER_SERVICE, String.valueOf(serviceId))); + if (!Strings.isNullOrEmpty(keyword)) { + endpointQuery.where(contains(MetricsDAO.TAG_ENDPOINT_NAME, keyword.replaceAll("/", "////"))); + } + endpointQuery.limit(limit); + + Query query = new Query(endpointQuery.getCommand()); + + final QueryResult.Series series = client.queryForSingleSeries(query); + + List list = new ArrayList<>(limit); + if (series != null) { + series.getValues().forEach(values -> { + EndpointTraffic endpointTraffic = new EndpointTraffic(); + endpointTraffic.setServiceId((int) values.get(1)); + endpointTraffic.setName((String) values.get(2)); + endpointTraffic.setDetectPoint((int) values.get(3)); + + Endpoint endpoint = new Endpoint(); + endpoint.setId(EndpointTraffic.buildId(endpointTraffic)); + endpoint.setName(endpointTraffic.getName()); + list.add(endpoint); + }); + } + return list; + } +} diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/LogQuery.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/LogQuery.java index 6b155929fe..fdfaa90937 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/LogQuery.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/LogQuery.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.List; import java.util.Map; import lombok.extern.slf4j.Slf4j; +import org.apache.skywalking.apm.util.StringUtil; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord; import org.apache.skywalking.oap.server.core.query.entity.ContentType; @@ -43,6 +44,7 @@ import org.influxdb.querybuilder.clauses.ConjunctionClause; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.CONTENT; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.CONTENT_TYPE; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.ENDPOINT_ID; +import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.ENDPOINT_NAME; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.IS_ERROR; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.SERVICE_ID; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.SERVICE_INSTANCE_ID; @@ -63,19 +65,19 @@ public class LogQuery implements ILogQueryDAO { } @Override - public Logs queryLogs(String metricName, int serviceId, int serviceInstanceId, int endpointId, String traceId, + public Logs queryLogs(String metricName, int serviceId, int serviceInstanceId, String endpointId, String traceId, LogState state, String stateCode, Pagination paging, int from, int limit, long startTB, long endTB) throws IOException { WhereQueryImpl recallQuery = select().regex("*::field") - .from(client.getDatabase(), metricName) - .where(); + .from(client.getDatabase(), metricName) + .where(); if (serviceId != Const.NONE) { recallQuery.and(eq(RecordDAO.TAG_SERVICE_ID, String.valueOf(serviceId))); } if (serviceInstanceId != Const.NONE) { recallQuery.and(eq(SERVICE_INSTANCE_ID, serviceInstanceId)); } - if (endpointId != Const.NONE) { + if (StringUtil.isNotEmpty(endpointId)) { recallQuery.and(eq(ENDPOINT_ID, endpointId)); } if (!Strings.isNullOrEmpty(traceId)) { @@ -135,7 +137,8 @@ public class LogQuery implements ILogQueryDAO { log.setContent((String) data.get(CONTENT)); log.setContentType(ContentType.instanceOf((int) data.get(CONTENT_TYPE))); - log.setEndpointId((int) data.get(ENDPOINT_ID)); + log.setEndpointId((String) data.get(ENDPOINT_ID)); + log.setEndpointName((String) data.get(ENDPOINT_NAME)); log.setTraceId((String) data.get(TRACE_ID)); log.setTimestamp((String) data.get(TIMESTAMP)); diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TopologyQuery.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TopologyQuery.java index 34b81c8fb7..c50de3b133 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TopologyQuery.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TopologyQuery.java @@ -25,6 +25,7 @@ import java.util.List; import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.oap.server.core.analysis.Downsampling; import org.apache.skywalking.oap.server.core.analysis.manual.RelationDefineUtil; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation.EndpointRelationServerSideMetrics; import org.apache.skywalking.oap.server.core.analysis.manual.relation.instance.ServiceInstanceRelationClientSideMetrics; import org.apache.skywalking.oap.server.core.analysis.manual.relation.instance.ServiceInstanceRelationServerSideMetrics; @@ -153,31 +154,31 @@ public class TopologyQuery implements ITopologyQueryDAO { public List loadSpecifiedDestOfServerSideEndpointRelations(Downsampling downsampling, long startTB, long endTB, - int destEndpointId) throws IOException { + String destEndpointId) throws IOException { String measurement = ModelName.build(downsampling, EndpointRelationServerSideMetrics.INDEX_NAME); WhereQueryImpl query = buildServiceCallsQuery( measurement, startTB, endTB, - EndpointRelationServerSideMetrics.SOURCE_ENDPOINT_ID, - EndpointRelationServerSideMetrics.DEST_ENDPOINT_ID, + EndpointRelationServerSideMetrics.SOURCE_ENDPOINT, + EndpointRelationServerSideMetrics.DEST_ENDPOINT, Collections.emptyList() ); - query.and(eq(EndpointRelationServerSideMetrics.DEST_ENDPOINT_ID, destEndpointId)); + query.and(eq(EndpointRelationServerSideMetrics.DEST_ENDPOINT, destEndpointId)); WhereQueryImpl query2 = buildServiceCallsQuery( measurement, startTB, endTB, - EndpointRelationServerSideMetrics.SOURCE_ENDPOINT_ID, - EndpointRelationServerSideMetrics.DEST_ENDPOINT_ID, + EndpointRelationServerSideMetrics.SOURCE_ENDPOINT, + EndpointRelationServerSideMetrics.DEST_ENDPOINT, Collections.emptyList() ); - query2.and(eq(EndpointRelationServerSideMetrics.SOURCE_ENDPOINT_ID, destEndpointId)); + query2.and(eq(EndpointRelationServerSideMetrics.SOURCE_ENDPOINT, destEndpointId)); List calls = buildCalls(query, DetectPoint.SERVER); - calls.addAll(buildCalls(query2, DetectPoint.CLIENT)); + calls.addAll(buildEndpointCalls(query2, DetectPoint.CLIENT)); return calls; } @@ -229,7 +230,7 @@ public class TopologyQuery implements ITopologyQueryDAO { } private List buildCalls(WhereQueryImpl query, - DetectPoint detectPoint) throws IOException { + DetectPoint detectPoint) throws IOException { QueryResult.Series series = client.queryForSingleSeries(query); if (log.isDebugEnabled()) { @@ -245,8 +246,38 @@ public class TopologyQuery implements ITopologyQueryDAO { String entityId = (String) values.get(1); RelationDefineUtil.RelationDefine relationDefine = RelationDefineUtil.splitEntityId(entityId); - call.setSource(relationDefine.getSource()); - call.setTarget(relationDefine.getDest()); + call.setSource(String.valueOf(relationDefine.getSource())); + call.setTarget(String.valueOf(relationDefine.getDest())); + call.setComponentId(relationDefine.getComponentId()); + call.setDetectPoint(detectPoint); + call.generateID(); + calls.add(call); + }); + return calls; + } + + private List buildEndpointCalls(WhereQueryImpl query, + DetectPoint detectPoint) throws IOException { + QueryResult.Series series = client.queryForSingleSeries(query); + + if (log.isDebugEnabled()) { + log.debug("SQL: {} result set: {}", query.getCommand(), series); + } + if (series == null) { + return Collections.emptyList(); + } + + List calls = new ArrayList<>(); + series.getValues().forEach(values -> { + Call.CallDetail call = new Call.CallDetail(); + String entityId = (String) values.get(1); + RelationDefineUtil.EndpointRelationDefine relationDefine = RelationDefineUtil.splitEndpointRelationEntityId( + entityId); + + call.setSource( + EndpointTraffic.buildId(relationDefine.getSourceServiceId(), relationDefine.getSource(), detectPoint)); + call.setTarget( + EndpointTraffic.buildId(relationDefine.getDestServiceId(), relationDefine.getDest(), detectPoint)); call.setComponentId(relationDefine.getComponentId()); call.setDetectPoint(detectPoint); call.generateID(); diff --git a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TraceQuery.java b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TraceQuery.java index 6ad679edb0..1e27fb9fe6 100644 --- a/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TraceQuery.java +++ b/oap-server/server-storage-plugin/storage-influxdb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/influxdb/query/TraceQuery.java @@ -41,10 +41,10 @@ import org.influxdb.querybuilder.SelectQueryImpl; import org.influxdb.querybuilder.WhereQueryImpl; import org.influxdb.querybuilder.clauses.Clause; +import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.contains; import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.eq; import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.gte; import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.lte; -import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.regex; import static org.influxdb.querybuilder.BuiltQuery.QueryBuilder.select; @Slf4j @@ -63,7 +63,7 @@ public class TraceQuery implements ITraceQueryDAO { String endpointName, int serviceId, int serviceInstanceId, - int endpointId, + String endpointId, String traceId, int limit, int from, @@ -98,7 +98,7 @@ public class TraceQuery implements ITraceQueryDAO { recallQuery.and(lte(SegmentRecord.LATENCY, maxDuration)); } if (!Strings.isNullOrEmpty(endpointName)) { - recallQuery.and(regex(SegmentRecord.ENDPOINT_NAME, "/" + endpointName.replaceAll("/", "\\\\/") + "/")); + recallQuery.and(contains(SegmentRecord.ENDPOINT_NAME, endpointName)); } if (serviceId != 0) { recallQuery.and(eq(RecordDAO.TAG_SERVICE_ID, String.valueOf(serviceId))); @@ -106,7 +106,7 @@ public class TraceQuery implements ITraceQueryDAO { if (serviceInstanceId != 0) { recallQuery.and(eq(SegmentRecord.SERVICE_INSTANCE_ID, serviceInstanceId)); } - if (endpointId != 0) { + if (!com.google.common.base.Strings.isNullOrEmpty(endpointId)) { recallQuery.and(eq(SegmentRecord.ENDPOINT_ID, endpointId)); } if (!Strings.isNullOrEmpty(traceId)) { diff --git a/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/JaegerSpan.java b/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/JaegerSpan.java index 9fbae2485e..ae1cf4a4b7 100644 --- a/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/JaegerSpan.java +++ b/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/JaegerSpan.java @@ -56,7 +56,7 @@ public class JaegerSpan extends Source { private String endpointName; @Setter @Getter - private int endpointId; + private String endpointId; @Setter @Getter private long startTime; diff --git a/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/JaegerSpanRecord.java b/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/JaegerSpanRecord.java index 28def8e82a..8b1a0dd7ae 100644 --- a/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/JaegerSpanRecord.java +++ b/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/JaegerSpanRecord.java @@ -79,7 +79,7 @@ public class JaegerSpanRecord extends Record { @Getter @Column(columnName = ENDPOINT_ID) @IDColumn - private int endpointId; + private String endpointId; @Setter @Getter @Column(columnName = START_TIME) @@ -149,7 +149,7 @@ public class JaegerSpanRecord extends Record { record.setServiceId(((Number) dbMap.get(SERVICE_ID)).intValue()); record.setServiceInstanceId(((Number) dbMap.get(SERVICE_INSTANCE_ID)).intValue()); record.setEndpointName((String) dbMap.get(ENDPOINT_NAME)); - record.setEndpointId(((Number) dbMap.get(ENDPOINT_ID)).intValue()); + record.setEndpointId((String) dbMap.get(ENDPOINT_ID)); record.setStartTime(((Number) dbMap.get(START_TIME)).longValue()); record.setEndTime(((Number) dbMap.get(END_TIME)).longValue()); record.setLatency(((Number) dbMap.get(LATENCY)).intValue()); diff --git a/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/elasticsearch/JaegerTraceQueryEsDAO.java b/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/elasticsearch/JaegerTraceQueryEsDAO.java index d292843346..473a20a188 100644 --- a/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/elasticsearch/JaegerTraceQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-jaeger-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jaeger/elasticsearch/JaegerTraceQueryEsDAO.java @@ -80,9 +80,19 @@ public class JaegerTraceQueryEsDAO extends EsDAO implements ITraceQueryDAO { } @Override - public TraceBrief queryBasicTraces(long startSecondTB, long endSecondTB, long minDuration, long maxDuration, - String endpointName, int serviceId, int serviceInstanceId, int endpointId, String traceId, int limit, int from, - TraceState traceState, QueryOrder queryOrder) throws IOException { + public TraceBrief queryBasicTraces(long startSecondTB, + long endSecondTB, + long minDuration, + long maxDuration, + String endpointName, + int serviceId, + int serviceInstanceId, + String endpointId, + String traceId, + int limit, + int from, + TraceState traceState, + QueryOrder queryOrder) throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); @@ -113,7 +123,7 @@ public class JaegerTraceQueryEsDAO extends EsDAO implements ITraceQueryDAO { if (serviceInstanceId != 0) { boolQueryBuilder.must().add(QueryBuilders.termQuery(SERVICE_INSTANCE_ID, serviceInstanceId)); } - if (endpointId != 0) { + if (!Strings.isNullOrEmpty(endpointId)) { boolQueryBuilder.must().add(QueryBuilders.termQuery(ENDPOINT_ID, endpointId)); } if (!Strings.isNullOrEmpty(traceId)) { diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/pom.xml b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/pom.xml index 66c8e88432..2f798694ff 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/pom.xml +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/pom.xml @@ -43,11 +43,11 @@ com.h2database h2 - - - - - + + + + + diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java index 5b468ced6c..597748f431 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/H2StorageProvider.java @@ -26,7 +26,6 @@ import org.apache.skywalking.oap.server.core.storage.IRegisterLockDAO; import org.apache.skywalking.oap.server.core.storage.StorageDAO; import org.apache.skywalking.oap.server.core.storage.StorageException; import org.apache.skywalking.oap.server.core.storage.StorageModule; -import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO; @@ -51,7 +50,6 @@ import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedExcepti import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2AggregationQueryDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2AlarmQueryDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2BatchDAO; -import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2EndpointInventoryCacheDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2HistoryDeleteDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2LogQueryDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetadataQueryDAO; @@ -121,23 +119,27 @@ public class H2StorageProvider extends ModuleProvider { this.registerServiceImplementation(IRegisterLockDAO.class, lockDAO); this.registerServiceImplementation(IServiceInventoryCacheDAO.class, new H2ServiceInventoryCacheDAO(h2Client)); - this.registerServiceImplementation(IServiceInstanceInventoryCacheDAO.class, new H2ServiceInstanceInventoryCacheDAO(h2Client)); - this.registerServiceImplementation(IEndpointInventoryCacheDAO.class, new H2EndpointInventoryCacheDAO(h2Client)); - this.registerServiceImplementation(INetworkAddressInventoryCacheDAO.class, new H2NetworkAddressInventoryCacheDAO(h2Client)); + this.registerServiceImplementation( + IServiceInstanceInventoryCacheDAO.class, new H2ServiceInstanceInventoryCacheDAO(h2Client)); + this.registerServiceImplementation( + INetworkAddressInventoryCacheDAO.class, new H2NetworkAddressInventoryCacheDAO(h2Client)); this.registerServiceImplementation(ITopologyQueryDAO.class, new H2TopologyQueryDAO(h2Client)); this.registerServiceImplementation(IMetricsQueryDAO.class, new H2MetricsQueryDAO(h2Client)); this.registerServiceImplementation(ITraceQueryDAO.class, new H2TraceQueryDAO(h2Client)); - this.registerServiceImplementation(IMetadataQueryDAO.class, new H2MetadataQueryDAO(h2Client, config.getMetadataQueryMaxSize())); + this.registerServiceImplementation( + IMetadataQueryDAO.class, new H2MetadataQueryDAO(h2Client, config.getMetadataQueryMaxSize())); this.registerServiceImplementation(IAggregationQueryDAO.class, new H2AggregationQueryDAO(h2Client)); this.registerServiceImplementation(IAlarmQueryDAO.class, new H2AlarmQueryDAO(h2Client)); - this.registerServiceImplementation(IHistoryDeleteDAO.class, new H2HistoryDeleteDAO(getManager(), h2Client, new GeneralStorageTTL())); + this.registerServiceImplementation( + IHistoryDeleteDAO.class, new H2HistoryDeleteDAO(getManager(), h2Client, new GeneralStorageTTL())); this.registerServiceImplementation(ITopNRecordsQueryDAO.class, new H2TopNRecordsQueryDAO(h2Client)); this.registerServiceImplementation(ILogQueryDAO.class, new H2LogQueryDAO(h2Client)); this.registerServiceImplementation(IProfileTaskQueryDAO.class, new H2ProfileTaskQueryDAO(h2Client)); this.registerServiceImplementation(IProfileTaskLogQueryDAO.class, new H2ProfileTaskLogQueryDAO(h2Client)); - this.registerServiceImplementation(IProfileThreadSnapshotQueryDAO.class, new H2ProfileThreadSnapshotQueryDAO(h2Client)); + this.registerServiceImplementation( + IProfileThreadSnapshotQueryDAO.class, new H2ProfileThreadSnapshotQueryDAO(h2Client)); } @Override diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java index dea2b0b38d..4bab452c1a 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AggregationQueryDAO.java @@ -24,7 +24,7 @@ import org.apache.skywalking.oap.server.core.analysis.Downsampling; import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.query.entity.Order; import org.apache.skywalking.oap.server.core.query.entity.TopNEntity; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; import org.apache.skywalking.oap.server.core.storage.model.ModelName; import org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO; @@ -77,7 +77,7 @@ public class H2AggregationQueryDAO implements IAggregationQueryDAO { public List getEndpointTopN(int serviceId, String indName, String valueCName, int topN, Downsampling downsampling, long startTB, long endTB, Order order) throws IOException { return topNQuery(indName, valueCName, topN, downsampling, startTB, endTB, order, (sql, conditions) -> { - sql.append(" and ").append(EndpointInventory.SERVICE_ID).append("=?"); + sql.append(" and ").append(EndpointTraffic.SERVICE_ID).append("=?"); conditions.add(serviceId); }); } diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2EndpointInventoryCacheDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2EndpointInventoryCacheDAO.java deleted file mode 100644 index 9d86508020..0000000000 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2EndpointInventoryCacheDAO.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.storage.plugin.jdbc.h2.dao; - -import java.io.IOException; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; -import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; -import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class H2EndpointInventoryCacheDAO extends H2SQLExecutor implements IEndpointInventoryCacheDAO { - private static final Logger logger = LoggerFactory.getLogger(H2EndpointInventoryCacheDAO.class); - private JDBCHikariCPClient h2Client; - - public H2EndpointInventoryCacheDAO(JDBCHikariCPClient h2Client) { - this.h2Client = h2Client; - } - - @Override - public int getEndpointId(int serviceId, String endpointName, int detectPoint) { - String id = EndpointInventory.buildId(serviceId, endpointName, detectPoint); - return getEntityIDByID(h2Client, EndpointInventory.SEQUENCE, EndpointInventory.INDEX_NAME, id); - } - - @Override - public EndpointInventory get(int endpointId) { - try { - return (EndpointInventory) getByColumn(h2Client, EndpointInventory.INDEX_NAME, EndpointInventory.SEQUENCE, endpointId, new EndpointInventory.Builder()); - } catch (IOException e) { - logger.error(e.getMessage(), e); - return null; - } - } -} diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2LogQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2LogQueryDAO.java index 80b90335f0..45cda2150b 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2LogQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2LogQueryDAO.java @@ -19,6 +19,13 @@ package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao; import com.google.common.base.Strings; +import java.io.IOException; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import org.apache.skywalking.apm.util.StringUtil; import org.apache.skywalking.oap.server.core.Const; import org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord; import org.apache.skywalking.oap.server.core.query.entity.ContentType; @@ -30,16 +37,10 @@ import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO; import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient; import org.apache.skywalking.oap.server.library.util.BooleanUtils; -import java.io.IOException; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.CONTENT; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.CONTENT_TYPE; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.ENDPOINT_ID; +import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.ENDPOINT_NAME; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.SERVICE_ID; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.SERVICE_INSTANCE_ID; import static org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogRecord.STATUS_CODE; @@ -54,9 +55,9 @@ public class H2LogQueryDAO implements ILogQueryDAO { } @Override - public Logs queryLogs(String metricName, int serviceId, int serviceInstanceId, int endpointId, String traceId, - LogState state, String stateCode, Pagination paging, int from, int limit, long startSecondTB, - long endSecondTB) throws IOException { + public Logs queryLogs(String metricName, int serviceId, int serviceInstanceId, String endpointId, String traceId, + LogState state, String stateCode, Pagination paging, int from, int limit, long startSecondTB, + long endSecondTB) throws IOException { StringBuilder sql = new StringBuilder(); List parameters = new ArrayList<>(10); @@ -77,7 +78,7 @@ public class H2LogQueryDAO implements ILogQueryDAO { sql.append(" and ").append(AbstractLogRecord.SERVICE_INSTANCE_ID).append(" = ?"); parameters.add(serviceInstanceId); } - if (endpointId != Const.NONE) { + if (StringUtil.isNotEmpty(endpointId)) { sql.append(" and ").append(AbstractLogRecord.ENDPOINT_ID).append(" = ?"); parameters.add(endpointId); } @@ -109,12 +110,14 @@ public class H2LogQueryDAO implements ILogQueryDAO { buildLimit(sql, from, limit); - try (ResultSet resultSet = h2Client.executeQuery(connection, "select * " + sql.toString(), parameters.toArray(new Object[0]))) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, "select * " + sql.toString(), parameters.toArray(new Object[0]))) { while (resultSet.next()) { Log log = new Log(); log.setServiceId(resultSet.getInt(SERVICE_ID)); log.setServiceInstanceId(resultSet.getInt(SERVICE_INSTANCE_ID)); - log.setEndpointId(resultSet.getInt(ENDPOINT_ID)); + log.setEndpointId(resultSet.getString(ENDPOINT_ID)); + log.setEndpointName(resultSet.getString(ENDPOINT_NAME)); log.setTraceId(resultSet.getString(TRACE_ID)); log.setTimestamp(resultSet.getString(TIMESTAMP)); log.setStatusCode(resultSet.getString(STATUS_CODE)); diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java index 1f3caf351a..a7609536b7 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java @@ -29,13 +29,13 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.query.entity.Attribute; import org.apache.skywalking.oap.server.core.query.entity.Database; import org.apache.skywalking.oap.server.core.query.entity.Endpoint; import org.apache.skywalking.oap.server.core.query.entity.LanguageTrans; import org.apache.skywalking.oap.server.core.query.entity.Service; import org.apache.skywalking.oap.server.core.query.entity.ServiceInstance; -import org.apache.skywalking.oap.server.core.register.EndpointInventory; import org.apache.skywalking.oap.server.core.register.NodeType; import org.apache.skywalking.oap.server.core.register.RegisterSource; import org.apache.skywalking.oap.server.core.register.ServiceInstanceInventory; @@ -76,7 +76,8 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { private Integer getNum(StringBuilder sql, List condition) throws IOException { try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]))) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, sql.toString(), condition.toArray(new Object[0]))) { if (resultSet.next()) { return resultSet.getInt("num"); } @@ -91,8 +92,8 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { public int numOfEndpoint() throws IOException { StringBuilder sql = new StringBuilder(); List condition = new ArrayList<>(5); - sql.append("select count(*) num from ").append(EndpointInventory.INDEX_NAME).append(" where "); - sql.append(EndpointInventory.DETECT_POINT).append("=").append(DetectPoint.SERVER.ordinal()); + sql.append("select count(*) num from ").append(EndpointTraffic.INDEX_NAME).append(" where "); + sql.append(EndpointTraffic.DETECT_POINT).append("=").append(DetectPoint.SERVER.value()); return getNum(sql, condition); } @@ -121,7 +122,8 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { sql.append(" limit ").append(metadataQueryMaxSize); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]))) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, sql.toString(), condition.toArray(new Object[0]))) { return buildServices(resultSet); } } catch (SQLException e) { @@ -142,7 +144,8 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { sql.append(" limit ").append(metadataQueryMaxSize); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]))) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, sql.toString(), condition.toArray(new Object[0]))) { return buildServices(resultSet); } } catch (SQLException e) { @@ -159,7 +162,8 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { condition.add(NodeType.Database.value()); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]))) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, sql.toString(), condition.toArray(new Object[0]))) { List databases = new ArrayList<>(); while (resultSet.next()) { Database database = new Database(); @@ -199,7 +203,8 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { sql.append(" limit ").append(metadataQueryMaxSize); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]))) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, sql.toString(), condition.toArray(new Object[0]))) { return buildServices(resultSet); } } catch (SQLException e) { @@ -218,7 +223,8 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { condition.add(serviceCode); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]))) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, sql.toString(), condition.toArray(new Object[0]))) { while (resultSet.next()) { Service service = new Service(); @@ -235,27 +241,39 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { } @Override - public List searchEndpoint(String keyword, String serviceId, int limit) throws IOException { + public List searchEndpoint(String keyword, int serviceId, int limit) throws IOException { StringBuilder sql = new StringBuilder(); List condition = new ArrayList<>(5); - sql.append("select * from ").append(EndpointInventory.INDEX_NAME).append(" where "); - sql.append(EndpointInventory.SERVICE_ID).append("=?"); + sql.append("select * from ").append(EndpointTraffic.INDEX_NAME).append(" where "); + sql.append(EndpointTraffic.SERVICE_ID).append("=?"); condition.add(serviceId); if (!Strings.isNullOrEmpty(keyword)) { - sql.append(" and ").append(EndpointInventory.NAME).append(" like '%").append(keyword).append("%' "); + sql.append(" and ").append(EndpointTraffic.NAME).append(" like '%").append(keyword).append("%' "); } - sql.append(" and ").append(EndpointInventory.DETECT_POINT).append(" = ?"); - condition.add(DetectPoint.SERVER.ordinal()); - sql.append(" limit ").append(limit); + sql.append(" and ").append(EndpointTraffic.DETECT_POINT).append(" = ?"); + condition.add(DetectPoint.SERVER.value()); + /** + * Query the dataset by a larger limit condition and distinct in the memory, + * in order to avoid the storage level distinct. + * This is a match query only, don't need 100% accurate. + */ + sql.append(" limit ").append(limit * 7); List endpoints = new ArrayList<>(); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]))) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, sql.toString(), condition.toArray(new Object[0]))) { while (resultSet.next()) { + EndpointTraffic endpointTraffic = new EndpointTraffic(); + endpointTraffic.setServiceId(resultSet.getInt(EndpointTraffic.SERVICE_ID)); + endpointTraffic.setName(resultSet.getString(EndpointTraffic.NAME)); + endpointTraffic.setDetectPoint(resultSet.getInt(EndpointTraffic.DETECT_POINT)); + endpointTraffic.setTimeBucket(resultSet.getLong(EndpointTraffic.TIME_BUCKET)); + Endpoint endpoint = new Endpoint(); - endpoint.setId(resultSet.getInt(EndpointInventory.SEQUENCE)); - endpoint.setName(resultSet.getString(EndpointInventory.NAME)); + endpoint.setId(EndpointTraffic.buildId(endpointTraffic)); + endpoint.setName(endpointTraffic.getName()); endpoints.add(endpoint); } } @@ -267,7 +285,7 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { @Override public List getServiceInstances(long startTimestamp, long endTimestamp, - String serviceId) throws IOException { + String serviceId) throws IOException { StringBuilder sql = new StringBuilder(); List condition = new ArrayList<>(5); sql.append("select * from ").append(ServiceInstanceInventory.INDEX_NAME).append(" where "); @@ -277,7 +295,8 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { List serviceInstances = new ArrayList<>(); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]))) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, sql.toString(), condition.toArray(new Object[0]))) { while (resultSet.next()) { ServiceInstance serviceInstance = new ServiceInstance(); @@ -300,11 +319,14 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { } else if (key.equals(PROCESS_NO)) { serviceInstance.getAttributes().add(new Attribute(PROCESS_NO, value)); } else if (key.equals(IPV4S)) { - List ipv4s = ServiceInstanceInventory.PropertyUtil.ipv4sDeserialize(properties.get(IPV4S) - .getAsString()); + List ipv4s = ServiceInstanceInventory.PropertyUtil.ipv4sDeserialize( + properties.get(IPV4S) + .getAsString()); for (String ipv4 : ipv4s) { serviceInstance.getAttributes() - .add(new Attribute(ServiceInstanceInventory.PropertyUtil.IPV4S, ipv4)); + .add(new Attribute(ServiceInstanceInventory.PropertyUtil.IPV4S, + ipv4 + )); } } else { serviceInstance.getAttributes().add(new Attribute(key, value)); @@ -322,7 +344,7 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO { } private void setTimeRangeCondition(StringBuilder sql, List conditions, long startTimestamp, - long endTimestamp) { + long endTimestamp) { sql.append(" ( (") .append(RegisterSource.HEARTBEAT_TIME) .append(" >= ? and ") diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java index ebf68e8240..332ec54281 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.skywalking.oap.server.core.analysis.Downsampling; import org.apache.skywalking.oap.server.core.analysis.manual.RelationDefineUtil; +import org.apache.skywalking.oap.server.core.analysis.manual.endpoint.EndpointTraffic; import org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation.EndpointRelationServerSideMetrics; import org.apache.skywalking.oap.server.core.analysis.manual.relation.instance.ServiceInstanceRelationClientSideMetrics; import org.apache.skywalking.oap.server.core.analysis.manual.relation.instance.ServiceInstanceRelationServerSideMetrics; @@ -46,59 +47,99 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO { } @Override - public List loadSpecifiedServerSideServiceRelations(Downsampling downsampling, long startTB, - long endTB, List serviceIds) throws IOException { + public List loadSpecifiedServerSideServiceRelations(Downsampling downsampling, + long startTB, + long endTB, + List serviceIds) throws IOException { String tableName = ModelName.build(downsampling, ServiceRelationServerSideMetrics.INDEX_NAME); - return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, ServiceRelationServerSideMetrics.DEST_SERVICE_ID, serviceIds, false); + return loadServiceCalls( + tableName, startTB, endTB, ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, + ServiceRelationServerSideMetrics.DEST_SERVICE_ID, serviceIds, false + ); } @Override - public List loadSpecifiedClientSideServiceRelations(Downsampling downsampling, long startTB, - long endTB, List serviceIds) throws IOException { + public List loadSpecifiedClientSideServiceRelations(Downsampling downsampling, + long startTB, + long endTB, + List serviceIds) throws IOException { String tableName = ModelName.build(downsampling, ServiceRelationClientSideMetrics.INDEX_NAME); - return loadServiceCalls(tableName, startTB, endTB, ServiceRelationClientSideMetrics.SOURCE_SERVICE_ID, ServiceRelationClientSideMetrics.DEST_SERVICE_ID, serviceIds, true); + return loadServiceCalls( + tableName, startTB, endTB, ServiceRelationClientSideMetrics.SOURCE_SERVICE_ID, + ServiceRelationClientSideMetrics.DEST_SERVICE_ID, serviceIds, true + ); } @Override public List loadServerSideServiceRelations(Downsampling downsampling, long startTB, - long endTB) throws IOException { + long endTB) throws IOException { String tableName = ModelName.build(downsampling, ServiceRelationServerSideMetrics.INDEX_NAME); - return loadServiceCalls(tableName, startTB, endTB, ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, ServiceRelationServerSideMetrics.DEST_SERVICE_ID, new ArrayList<>(0), false); + return loadServiceCalls( + tableName, startTB, endTB, ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID, + ServiceRelationServerSideMetrics.DEST_SERVICE_ID, new ArrayList<>(0), false + ); } @Override public List loadClientSideServiceRelations(Downsampling downsampling, long startTB, - long endTB) throws IOException { + long endTB) throws IOException { String tableName = ModelName.build(downsampling, ServiceRelationClientSideMetrics.INDEX_NAME); - return loadServiceCalls(tableName, startTB, endTB, ServiceRelationClientSideMetrics.SOURCE_SERVICE_ID, ServiceRelationClientSideMetrics.DEST_SERVICE_ID, new ArrayList<>(0), true); + return loadServiceCalls( + tableName, startTB, endTB, ServiceRelationClientSideMetrics.SOURCE_SERVICE_ID, + ServiceRelationClientSideMetrics.DEST_SERVICE_ID, new ArrayList<>(0), true + ); } @Override - public List loadServerSideServiceInstanceRelations(int clientServiceId, int serverServiceId, - Downsampling downsampling, long startTB, long endTB) throws IOException { + public List loadServerSideServiceInstanceRelations(int clientServiceId, + int serverServiceId, + Downsampling downsampling, + long startTB, + long endTB) throws IOException { String tableName = ModelName.build(downsampling, ServiceInstanceRelationServerSideMetrics.INDEX_NAME); - return loadServiceInstanceCalls(tableName, startTB, endTB, ServiceInstanceRelationServerSideMetrics.SOURCE_SERVICE_ID, ServiceInstanceRelationServerSideMetrics.DEST_SERVICE_ID, clientServiceId, serverServiceId, false); + return loadServiceInstanceCalls( + tableName, startTB, endTB, ServiceInstanceRelationServerSideMetrics.SOURCE_SERVICE_ID, + ServiceInstanceRelationServerSideMetrics.DEST_SERVICE_ID, clientServiceId, serverServiceId, false + ); } @Override - public List loadClientSideServiceInstanceRelations(int clientServiceId, int serverServiceId, - Downsampling downsampling, long startTB, long endTB) throws IOException { + public List loadClientSideServiceInstanceRelations(int clientServiceId, + int serverServiceId, + Downsampling downsampling, + long startTB, + long endTB) throws IOException { String tableName = ModelName.build(downsampling, ServiceInstanceRelationClientSideMetrics.INDEX_NAME); - return loadServiceInstanceCalls(tableName, startTB, endTB, ServiceInstanceRelationClientSideMetrics.SOURCE_SERVICE_ID, ServiceInstanceRelationClientSideMetrics.DEST_SERVICE_ID, clientServiceId, serverServiceId, true); + return loadServiceInstanceCalls( + tableName, startTB, endTB, ServiceInstanceRelationClientSideMetrics.SOURCE_SERVICE_ID, + ServiceInstanceRelationClientSideMetrics.DEST_SERVICE_ID, clientServiceId, serverServiceId, true + ); } @Override - public List loadSpecifiedDestOfServerSideEndpointRelations(Downsampling downsampling, long startTB, - long endTB, int destEndpointId) throws IOException { + public List loadSpecifiedDestOfServerSideEndpointRelations(Downsampling downsampling, + long startTB, + long endTB, + String destEndpointId) throws IOException { String tableName = ModelName.build(downsampling, EndpointRelationServerSideMetrics.INDEX_NAME); - List calls = loadEndpointFromSide(tableName, startTB, endTB, EndpointRelationServerSideMetrics.SOURCE_ENDPOINT_ID, EndpointRelationServerSideMetrics.DEST_ENDPOINT_ID, destEndpointId, false); - calls.addAll(loadEndpointFromSide(tableName, startTB, endTB, EndpointRelationServerSideMetrics.SOURCE_ENDPOINT_ID, EndpointRelationServerSideMetrics.DEST_ENDPOINT_ID, destEndpointId, true)); + List calls = loadEndpointFromSide( + tableName, startTB, endTB, EndpointRelationServerSideMetrics.SOURCE_ENDPOINT, + EndpointRelationServerSideMetrics.DEST_ENDPOINT, destEndpointId, false + ); + calls.addAll(loadEndpointFromSide(tableName, startTB, endTB, EndpointRelationServerSideMetrics.SOURCE_ENDPOINT, + EndpointRelationServerSideMetrics.DEST_ENDPOINT, destEndpointId, true + )); return calls; } - private List loadServiceCalls(String tableName, long startTB, long endTB, String sourceCName, - String destCName, List serviceIds, boolean isClientSide) throws IOException { + private List loadServiceCalls(String tableName, + long startTB, + long endTB, + String sourceCName, + String destCName, + List serviceIds, + boolean isClientSide) throws IOException { Object[] conditions = new Object[serviceIds.size() * 2 + 2]; conditions[0] = startTB; conditions[1] = endTB; @@ -117,8 +158,11 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO { } List calls = new ArrayList<>(); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, "select " + Metrics.ENTITY_ID + " from " + tableName + " where " + Metrics.TIME_BUCKET + ">= ? and " + Metrics.TIME_BUCKET + "<=? " + serviceIdMatchSql - .toString() + " group by " + Metrics.ENTITY_ID, conditions)) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, + "select " + Metrics.ENTITY_ID + " from " + tableName + " where " + Metrics.TIME_BUCKET + ">= ? and " + Metrics.TIME_BUCKET + "<=? " + serviceIdMatchSql + .toString() + " group by " + Metrics.ENTITY_ID, conditions + )) { buildCalls(resultSet, calls, isClientSide); } } catch (SQLException e) { @@ -127,9 +171,14 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO { return calls; } - private List loadServiceInstanceCalls(String tableName, long startTB, long endTB, - String sourceCName, String descCName, int sourceServiceId, int destServiceId, - boolean isClientSide) throws IOException { + private List loadServiceInstanceCalls(String tableName, + long startTB, + long endTB, + String sourceCName, + String descCName, + int sourceServiceId, + int destServiceId, + boolean isClientSide) throws IOException { Object[] conditions = new Object[] { startTB, endTB, @@ -150,8 +199,11 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO { .append("))"); List calls = new ArrayList<>(); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, "select " + Metrics.ENTITY_ID + " from " + tableName + " where " + Metrics.TIME_BUCKET + ">= ? and " + Metrics.TIME_BUCKET + "<=? " + serviceIdMatchSql - .toString() + " group by " + Metrics.ENTITY_ID, conditions)) { + try (ResultSet resultSet = h2Client.executeQuery( + connection, + "select " + Metrics.ENTITY_ID + " from " + tableName + " where " + Metrics.TIME_BUCKET + ">= ? and " + Metrics.TIME_BUCKET + "<=? " + serviceIdMatchSql + .toString() + " group by " + Metrics.ENTITY_ID, conditions + )) { buildCalls(resultSet, calls, isClientSide); } } catch (SQLException e) { @@ -160,16 +212,25 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO { return calls; } - private List loadEndpointFromSide(String tableName, long startTB, long endTB, String sourceCName, - String destCName, int id, boolean isSourceId) throws IOException { + private List loadEndpointFromSide(String tableName, + long startTB, + long endTB, + String sourceCName, + String destCName, + String id, + boolean isSourceId) throws IOException { Object[] conditions = new Object[3]; conditions[0] = startTB; conditions[1] = endTB; conditions[2] = id; List calls = new ArrayList<>(); try (Connection connection = h2Client.getConnection()) { - try (ResultSet resultSet = h2Client.executeQuery(connection, "select " + Metrics.ENTITY_ID + " from " + tableName + " where " + Metrics.TIME_BUCKET + ">= ? and " + Metrics.TIME_BUCKET + "<=? and " + (isSourceId ? sourceCName : destCName) + "=?" + " group by " + Metrics.ENTITY_ID, conditions)) { - buildCalls(resultSet, calls, isSourceId); + try (ResultSet resultSet = h2Client.executeQuery( + connection, + "select " + Metrics.ENTITY_ID + " from " + tableName + " where " + Metrics.TIME_BUCKET + ">= ? and " + Metrics.TIME_BUCKET + "<=? and " + (isSourceId ? sourceCName : destCName) + "=?" + " group by " + Metrics.ENTITY_ID, + conditions + )) { + buildEndpointCalls(resultSet, calls, isSourceId); } } catch (SQLException e) { throw new IOException(e); @@ -178,14 +239,14 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO { } private void buildCalls(ResultSet resultSet, List calls, - boolean isClientSide) throws SQLException { + boolean isClientSide) throws SQLException { while (resultSet.next()) { Call.CallDetail call = new Call.CallDetail(); String entityId = resultSet.getString(Metrics.ENTITY_ID); RelationDefineUtil.RelationDefine relationDefine = RelationDefineUtil.splitEntityId(entityId); - call.setSource(relationDefine.getSource()); - call.setTarget(relationDefine.getDest()); + call.setSource(String.valueOf(relationDefine.getSource())); + call.setTarget(String.valueOf(relationDefine.getDest())); call.setComponentId(relationDefine.getComponentId()); if (isClientSide) { call.setDetectPoint(DetectPoint.CLIENT); @@ -196,4 +257,30 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO { calls.add(call); } } + + private void buildEndpointCalls(ResultSet resultSet, List calls, + boolean isClientSide) throws SQLException { + while (resultSet.next()) { + Call.CallDetail call = new Call.CallDetail(); + String entityId = resultSet.getString(Metrics.ENTITY_ID); + RelationDefineUtil.EndpointRelationDefine relationDefine = RelationDefineUtil.splitEndpointRelationEntityId( + entityId); + + if (isClientSide) { + call.setDetectPoint(DetectPoint.CLIENT); + } else { + call.setDetectPoint(DetectPoint.SERVER); + } + call.setSource(EndpointTraffic.buildId(relationDefine.getSourceServiceId(), relationDefine.getSource(), + call.getDetectPoint() + )); + call.setTarget(EndpointTraffic.buildId(relationDefine.getDestServiceId(), relationDefine.getDest(), + call.getDetectPoint() + )); + call.setComponentId(relationDefine.getComponentId()); + + call.generateID(); + calls.add(call); + } + } } diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TraceQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TraceQueryDAO.java index 40f19325bc..ff222ef466 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TraceQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TraceQueryDAO.java @@ -48,7 +48,7 @@ public class H2TraceQueryDAO implements ITraceQueryDAO { @Override public TraceBrief queryBasicTraces(long startSecondTB, long endSecondTB, long minDuration, long maxDuration, - String endpointName, int serviceId, int serviceInstanceId, int endpointId, String traceId, int limit, int from, + String endpointName, int serviceId, int serviceInstanceId, String endpointId, String traceId, int limit, int from, TraceState traceState, QueryOrder queryOrder) throws IOException { StringBuilder sql = new StringBuilder(); List parameters = new ArrayList<>(10); @@ -82,7 +82,7 @@ public class H2TraceQueryDAO implements ITraceQueryDAO { sql.append(" and ").append(SegmentRecord.SERVICE_INSTANCE_ID).append(" = ?"); parameters.add(serviceInstanceId); } - if (endpointId != 0) { + if (!Strings.isNullOrEmpty(endpointId)) { sql.append(" and ").append(SegmentRecord.ENDPOINT_ID).append(" = ?"); parameters.add(endpointId); } diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java index 09d302ef5b..5fc2072a0b 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLStorageProvider.java @@ -25,7 +25,6 @@ import org.apache.skywalking.oap.server.core.storage.IRegisterLockDAO; import org.apache.skywalking.oap.server.core.storage.StorageDAO; import org.apache.skywalking.oap.server.core.storage.StorageException; import org.apache.skywalking.oap.server.core.storage.StorageModule; -import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInstanceInventoryCacheDAO; import org.apache.skywalking.oap.server.core.storage.cache.IServiceInventoryCacheDAO; @@ -48,7 +47,6 @@ import org.apache.skywalking.oap.server.library.module.ModuleProvider; import org.apache.skywalking.oap.server.library.module.ModuleStartException; import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2BatchDAO; -import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2EndpointInventoryCacheDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2HistoryDeleteDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetadataQueryDAO; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetricsQueryDAO; @@ -110,24 +108,29 @@ public class MySQLStorageProvider extends ModuleProvider { lockDAO = new H2RegisterLockDAO(mysqlClient); this.registerServiceImplementation(IRegisterLockDAO.class, lockDAO); - this.registerServiceImplementation(IServiceInventoryCacheDAO.class, new H2ServiceInventoryCacheDAO(mysqlClient)); - this.registerServiceImplementation(IServiceInstanceInventoryCacheDAO.class, new H2ServiceInstanceInventoryCacheDAO(mysqlClient)); - this.registerServiceImplementation(IEndpointInventoryCacheDAO.class, new H2EndpointInventoryCacheDAO(mysqlClient)); - this.registerServiceImplementation(INetworkAddressInventoryCacheDAO.class, new H2NetworkAddressInventoryCacheDAO(mysqlClient)); + this.registerServiceImplementation( + IServiceInventoryCacheDAO.class, new H2ServiceInventoryCacheDAO(mysqlClient)); + this.registerServiceImplementation( + IServiceInstanceInventoryCacheDAO.class, new H2ServiceInstanceInventoryCacheDAO(mysqlClient)); + this.registerServiceImplementation( + INetworkAddressInventoryCacheDAO.class, new H2NetworkAddressInventoryCacheDAO(mysqlClient)); this.registerServiceImplementation(ITopologyQueryDAO.class, new H2TopologyQueryDAO(mysqlClient)); this.registerServiceImplementation(IMetricsQueryDAO.class, new H2MetricsQueryDAO(mysqlClient)); this.registerServiceImplementation(ITraceQueryDAO.class, new MySQLTraceQueryDAO(mysqlClient)); - this.registerServiceImplementation(IMetadataQueryDAO.class, new H2MetadataQueryDAO(mysqlClient, config.getMetadataQueryMaxSize())); + this.registerServiceImplementation( + IMetadataQueryDAO.class, new H2MetadataQueryDAO(mysqlClient, config.getMetadataQueryMaxSize())); this.registerServiceImplementation(IAggregationQueryDAO.class, new MySQLAggregationQueryDAO(mysqlClient)); this.registerServiceImplementation(IAlarmQueryDAO.class, new MySQLAlarmQueryDAO(mysqlClient)); - this.registerServiceImplementation(IHistoryDeleteDAO.class, new H2HistoryDeleteDAO(getManager(), mysqlClient, new GeneralStorageTTL())); + this.registerServiceImplementation( + IHistoryDeleteDAO.class, new H2HistoryDeleteDAO(getManager(), mysqlClient, new GeneralStorageTTL())); this.registerServiceImplementation(ITopNRecordsQueryDAO.class, new H2TopNRecordsQueryDAO(mysqlClient)); this.registerServiceImplementation(ILogQueryDAO.class, new MySQLLogQueryDAO(mysqlClient)); this.registerServiceImplementation(IProfileTaskQueryDAO.class, new H2ProfileTaskQueryDAO(mysqlClient)); this.registerServiceImplementation(IProfileTaskLogQueryDAO.class, new H2ProfileTaskLogQueryDAO(mysqlClient)); - this.registerServiceImplementation(IProfileThreadSnapshotQueryDAO.class, new H2ProfileThreadSnapshotQueryDAO(mysqlClient)); + this.registerServiceImplementation( + IProfileThreadSnapshotQueryDAO.class, new H2ProfileThreadSnapshotQueryDAO(mysqlClient)); } @Override diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java index 21c2f8e307..f0320c2129 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/mysql/MySQLTableInstaller.java @@ -21,8 +21,10 @@ package org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql; import java.sql.Connection; import java.sql.SQLException; import lombok.extern.slf4j.Slf4j; +import org.apache.skywalking.oap.server.core.alarm.AlarmRecord; import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord; import org.apache.skywalking.oap.server.core.analysis.metrics.IntKeyLongValueHashMap; +import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics; import org.apache.skywalking.oap.server.core.profile.ProfileTaskLogRecord; import org.apache.skywalking.oap.server.core.profile.ProfileThreadSnapshotRecord; import org.apache.skywalking.oap.server.core.register.RegisterSource; @@ -37,13 +39,12 @@ import org.apache.skywalking.oap.server.storage.plugin.jdbc.SQLBuilder; import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TableInstaller; import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.ALARM; -import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.ENDPOINT_INVENTORY; import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.NETWORK_ADDRESS; +import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROFILE_TASK_LOG; +import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROFILE_TASK_SEGMENT_SNAPSHOT; import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SEGMENT; import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_INSTANCE_INVENTORY; import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.SERVICE_INVENTORY; -import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROFILE_TASK_LOG; -import static org.apache.skywalking.oap.server.core.source.DefaultScopeDefine.PROFILE_TASK_SEGMENT_SNAPSHOT; /** * Extend H2TableInstaller but match MySQL SQL syntax. @@ -78,12 +79,15 @@ public class MySQLTableInstaller extends H2TableInstaller { } else if (Double.class.equals(type) || double.class.equals(type)) { return "DOUBLE"; } else if (String.class.equals(type)) { - if (SEGMENT == model.getScopeId() || PROFILE_TASK_SEGMENT_SNAPSHOT == model.getScopeId()) { - if (name.getName().equals(SegmentRecord.TRACE_ID) || name.getName().equals(SegmentRecord.SEGMENT_ID)) - return "VARCHAR(300)"; - if (name.getName().equals(SegmentRecord.DATA_BINARY)) { - return "MEDIUMTEXT"; - } + if (name.getName().equals(SegmentRecord.TRACE_ID) || name.getName().equals(SegmentRecord.SEGMENT_ID)) { + return "VARCHAR(150)"; + } + if (Metrics.ENTITY_ID.equals(name.getName())) { + return "VARCHAR(512)"; + } + if (SegmentRecord.ENDPOINT_NAME.equals(name.getName()) || SegmentRecord.ENDPOINT_ID.equals( + name.getName())) { + return "VARCHAR(200)"; } if (PROFILE_TASK_LOG == model.getScopeId() || PROFILE_TASK_SEGMENT_SNAPSHOT == model.getScopeId()) { if (name.getName().equals(ProfileTaskLogRecord.TASK_ID)) { @@ -111,7 +115,6 @@ public class MySQLTableInstaller extends H2TableInstaller { case SERVICE_INVENTORY: case SERVICE_INSTANCE_INVENTORY: case NETWORK_ADDRESS: - case ENDPOINT_INVENTORY: createInventoryIndexes(client, model); return; case SEGMENT: @@ -135,38 +138,38 @@ public class MySQLTableInstaller extends H2TableInstaller { try (Connection connection = client.getConnection()) { // query by task id, sequence SQLBuilder tableIndexSQL = new SQLBuilder("CREATE INDEX "); - tableIndexSQL.append(model.getName().toUpperCase()).append("_TASK_ID_SEQUENCE "); + tableIndexSQL.append(model.getName().toUpperCase()).append("_A "); tableIndexSQL.append("ON ") - .append(model.getName()) - .append("(") - .append(ProfileThreadSnapshotRecord.TASK_ID) - .append(", ") - .append(ProfileThreadSnapshotRecord.SEQUENCE) - .append(")"); + .append(model.getName()) + .append("(") + .append(ProfileThreadSnapshotRecord.TASK_ID) + .append(", ") + .append(ProfileThreadSnapshotRecord.SEQUENCE) + .append(")"); createIndex(client, connection, model, tableIndexSQL); // query by segment id, sequence tableIndexSQL = new SQLBuilder("CREATE INDEX "); tableIndexSQL.append(model.getName().toUpperCase()).append("_SEGMENT_ID_SEQUENCE "); tableIndexSQL.append("ON ") - .append(model.getName()) - .append("(") - .append(ProfileThreadSnapshotRecord.SEGMENT_ID) - .append(", ") - .append(ProfileThreadSnapshotRecord.SEQUENCE) - .append(")"); + .append(model.getName()) + .append("(") + .append(ProfileThreadSnapshotRecord.SEGMENT_ID) + .append(", ") + .append(ProfileThreadSnapshotRecord.SEQUENCE) + .append(")"); createIndex(client, connection, model, tableIndexSQL); // query by segment id, dump time tableIndexSQL = new SQLBuilder("CREATE INDEX "); tableIndexSQL.append(model.getName().toUpperCase()).append("_SEGMENT_ID_DUMP_TIME "); tableIndexSQL.append("ON ") - .append(model.getName()) - .append("(") - .append(ProfileThreadSnapshotRecord.SEGMENT_ID) - .append(", ") - .append(ProfileThreadSnapshotRecord.DUMP_TIME) - .append(")"); + .append(model.getName()) + .append("(") + .append(ProfileThreadSnapshotRecord.SEGMENT_ID) + .append(", ") + .append(ProfileThreadSnapshotRecord.DUMP_TIME) + .append(")"); createIndex(client, connection, model, tableIndexSQL); } catch (JDBCClientException | SQLException e) { throw new StorageException(e.getMessage(), e); @@ -179,10 +182,10 @@ public class MySQLTableInstaller extends H2TableInstaller { SQLBuilder tableIndexSQL = new SQLBuilder("CREATE INDEX "); tableIndexSQL.append(model.getName().toUpperCase()).append("_TASK_ID "); tableIndexSQL.append("ON ") - .append(model.getName()) - .append("(") - .append(ProfileTaskLogRecord.TASK_ID) - .append(")"); + .append(model.getName()) + .append("(") + .append(ProfileTaskLogRecord.TASK_ID) + .append(")"); createIndex(client, connection, model, tableIndexSQL); } catch (JDBCClientException | SQLException e) { throw new StorageException(e.getMessage(), e); @@ -196,7 +199,7 @@ public class MySQLTableInstaller extends H2TableInstaller { tableIndexSQL.append("ON ") .append(model.getName()) .append("(") - .append(SegmentRecord.TIME_BUCKET) + .append(Metrics.TIME_BUCKET) .append(")"); createIndex(client, connection, model, tableIndexSQL); } catch (JDBCClientException | SQLException e) { @@ -211,7 +214,7 @@ public class MySQLTableInstaller extends H2TableInstaller { tableIndexSQL.append("ON ") .append(model.getName()) .append("(") - .append(SegmentRecord.TIME_BUCKET) + .append(AlarmRecord.TIME_BUCKET) .append(")"); createIndex(client, connection, model, tableIndexSQL); } catch (JDBCClientException | SQLException e) { diff --git a/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/ZipkinSpan.java b/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/ZipkinSpan.java index ca65787385..539c7a2ba0 100644 --- a/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/ZipkinSpan.java +++ b/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/ZipkinSpan.java @@ -56,7 +56,7 @@ public class ZipkinSpan extends Source { private String endpointName; @Setter @Getter - private int endpointId; + private String endpointId; @Setter @Getter private long startTime; diff --git a/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/ZipkinSpanRecord.java b/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/ZipkinSpanRecord.java index 8b067221e8..37b8921f93 100644 --- a/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/ZipkinSpanRecord.java +++ b/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/ZipkinSpanRecord.java @@ -79,7 +79,7 @@ public class ZipkinSpanRecord extends Record { @Getter @Column(columnName = ENDPOINT_ID) @IDColumn - private int endpointId; + private String endpointId; @Setter @Getter @Column(columnName = START_TIME) @@ -149,7 +149,7 @@ public class ZipkinSpanRecord extends Record { record.setServiceId(((Number) dbMap.get(SERVICE_ID)).intValue()); record.setServiceInstanceId(((Number) dbMap.get(SERVICE_INSTANCE_ID)).intValue()); record.setEndpointName((String) dbMap.get(ENDPOINT_NAME)); - record.setEndpointId(((Number) dbMap.get(ENDPOINT_ID)).intValue()); + record.setEndpointId((String) dbMap.get(ENDPOINT_ID)); record.setStartTime(((Number) dbMap.get(START_TIME)).longValue()); record.setEndTime(((Number) dbMap.get(END_TIME)).longValue()); record.setLatency(((Number) dbMap.get(LATENCY)).intValue()); diff --git a/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/elasticsearch/ZipkinTraceQueryEsDAO.java b/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/elasticsearch/ZipkinTraceQueryEsDAO.java index 94611429ba..579993dfa3 100644 --- a/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/elasticsearch/ZipkinTraceQueryEsDAO.java +++ b/oap-server/server-storage-plugin/storage-zipkin-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/zipkin/elasticsearch/ZipkinTraceQueryEsDAO.java @@ -78,9 +78,19 @@ public class ZipkinTraceQueryEsDAO extends EsDAO implements ITraceQueryDAO { } @Override - public TraceBrief queryBasicTraces(long startSecondTB, long endSecondTB, long minDuration, long maxDuration, - String endpointName, int serviceId, int serviceInstanceId, int endpointId, String traceId, int limit, int from, - TraceState traceState, QueryOrder queryOrder) throws IOException { + public TraceBrief queryBasicTraces(long startSecondTB, + long endSecondTB, + long minDuration, + long maxDuration, + String endpointName, + int serviceId, + int serviceInstanceId, + String endpointId, + String traceId, + int limit, + int from, + TraceState traceState, + QueryOrder queryOrder) throws IOException { SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); @@ -111,7 +121,7 @@ public class ZipkinTraceQueryEsDAO extends EsDAO implements ITraceQueryDAO { if (serviceInstanceId != 0) { boolQueryBuilder.must().add(QueryBuilders.termQuery(SERVICE_INSTANCE_ID, serviceInstanceId)); } - if (endpointId != 0) { + if (!Strings.isNullOrEmpty(endpointId)) { boolQueryBuilder.must().add(QueryBuilders.termQuery(ENDPOINT_ID, endpointId)); } if (!Strings.isNullOrEmpty(traceId)) { diff --git a/oap-server/server-tools/profile-exporter/tool-profile-snapshot-bootstrap/src/test/java/org/apache/skywalking/oap/server/tool/profile/exporter/test/ProfileTraceDAO.java b/oap-server/server-tools/profile-exporter/tool-profile-snapshot-bootstrap/src/test/java/org/apache/skywalking/oap/server/tool/profile/exporter/test/ProfileTraceDAO.java index 4d26691a6a..37112822a7 100644 --- a/oap-server/server-tools/profile-exporter/tool-profile-snapshot-bootstrap/src/test/java/org/apache/skywalking/oap/server/tool/profile/exporter/test/ProfileTraceDAO.java +++ b/oap-server/server-tools/profile-exporter/tool-profile-snapshot-bootstrap/src/test/java/org/apache/skywalking/oap/server/tool/profile/exporter/test/ProfileTraceDAO.java @@ -39,7 +39,7 @@ public class ProfileTraceDAO implements ITraceQueryDAO { } @Override - public TraceBrief queryBasicTraces(long startSecondTB, long endSecondTB, long minDuration, long maxDuration, String endpointName, int serviceId, int serviceInstanceId, int endpointId, String traceId, int limit, int from, TraceState traceState, QueryOrder queryOrder) throws IOException { + public TraceBrief queryBasicTraces(long startSecondTB, long endSecondTB, long minDuration, long maxDuration, String endpointName, int serviceId, int serviceInstanceId, String endpointId, String traceId, int limit, int from, TraceState traceState, QueryOrder queryOrder) throws IOException { return null; } diff --git a/oap-server/server-tools/profile-exporter/tool-profile-snapshot-server-mock/src/main/java/org/apache/skywalking/oap/server/tool/profile/core/MockCoreModuleProvider.java b/oap-server/server-tools/profile-exporter/tool-profile-snapshot-server-mock/src/main/java/org/apache/skywalking/oap/server/tool/profile/core/MockCoreModuleProvider.java index 6143f9d899..54dda096e9 100755 --- a/oap-server/server-tools/profile-exporter/tool-profile-snapshot-server-mock/src/main/java/org/apache/skywalking/oap/server/tool/profile/core/MockCoreModuleProvider.java +++ b/oap-server/server-tools/profile-exporter/tool-profile-snapshot-server-mock/src/main/java/org/apache/skywalking/oap/server/tool/profile/core/MockCoreModuleProvider.java @@ -18,11 +18,12 @@ package org.apache.skywalking.oap.server.tool.profile.core; +import java.io.IOException; +import java.util.Collections; import org.apache.skywalking.oap.server.core.CoreModule; import org.apache.skywalking.oap.server.core.CoreModuleConfig; import org.apache.skywalking.oap.server.core.CoreModuleProvider; import org.apache.skywalking.oap.server.core.annotation.AnnotationScan; -import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache; import org.apache.skywalking.oap.server.core.cache.NetworkAddressInventoryCache; import org.apache.skywalking.oap.server.core.cache.ProfileTaskCache; import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache; @@ -41,8 +42,6 @@ import org.apache.skywalking.oap.server.core.query.ProfileTaskQueryService; import org.apache.skywalking.oap.server.core.query.TopNRecordsQueryService; import org.apache.skywalking.oap.server.core.query.TopologyQueryService; import org.apache.skywalking.oap.server.core.query.TraceQueryService; -import org.apache.skywalking.oap.server.core.register.service.EndpointInventoryRegister; -import org.apache.skywalking.oap.server.core.register.service.IEndpointInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.INetworkAddressInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInstanceInventoryRegister; import org.apache.skywalking.oap.server.core.register.service.IServiceInventoryRegister; @@ -74,9 +73,6 @@ import org.apache.skywalking.oap.server.tool.profile.core.mock.MockSourceReceive import org.apache.skywalking.oap.server.tool.profile.core.mock.MockStreamAnnotationListener; import org.apache.skywalking.oap.server.tool.profile.core.mock.MockWorkerInstancesService; -import java.io.IOException; -import java.util.Collections; - public class MockCoreModuleProvider extends CoreModuleProvider { private final StorageModels storageModels; @@ -117,12 +113,14 @@ public class MockCoreModuleProvider extends CoreModuleProvider { CoreModuleConfig moduleConfig = new CoreModuleConfig(); this.registerServiceImplementation(ConfigService.class, new ConfigService(moduleConfig)); - this.registerServiceImplementation(DownsamplingConfigService.class, new DownsamplingConfigService(Collections.emptyList())); + this.registerServiceImplementation( + DownsamplingConfigService.class, new DownsamplingConfigService(Collections.emptyList())); this.registerServiceImplementation(GRPCHandlerRegister.class, new MockGRPCHandlerRegister()); this.registerServiceImplementation(JettyHandlerRegister.class, new MockJettyHandlerRegister()); - this.registerServiceImplementation(IComponentLibraryCatalogService.class, new MockComponentLibraryCatalogService()); + this.registerServiceImplementation( + IComponentLibraryCatalogService.class, new MockComponentLibraryCatalogService()); this.registerServiceImplementation(SourceReceiver.class, new MockSourceReceiver()); @@ -135,17 +133,19 @@ public class MockCoreModuleProvider extends CoreModuleProvider { this.registerServiceImplementation(IModelGetter.class, storageModels); this.registerServiceImplementation(IModelOverride.class, storageModels); - this.registerServiceImplementation(ServiceInventoryCache.class, new ServiceInventoryCache(getManager(), moduleConfig)); + this.registerServiceImplementation( + ServiceInventoryCache.class, new ServiceInventoryCache(getManager(), moduleConfig)); this.registerServiceImplementation(IServiceInventoryRegister.class, new ServiceInventoryRegister(getManager())); - this.registerServiceImplementation(ServiceInstanceInventoryCache.class, new ServiceInstanceInventoryCache(getManager(), moduleConfig)); - this.registerServiceImplementation(IServiceInstanceInventoryRegister.class, new ServiceInstanceInventoryRegister(getManager())); - - this.registerServiceImplementation(EndpointInventoryCache.class, new EndpointInventoryCache(getManager(), moduleConfig)); - this.registerServiceImplementation(IEndpointInventoryRegister.class, new EndpointInventoryRegister(getManager())); + this.registerServiceImplementation( + ServiceInstanceInventoryCache.class, new ServiceInstanceInventoryCache(getManager(), moduleConfig)); + this.registerServiceImplementation( + IServiceInstanceInventoryRegister.class, new ServiceInstanceInventoryRegister(getManager())); - this.registerServiceImplementation(NetworkAddressInventoryCache.class, new NetworkAddressInventoryCache(getManager(), moduleConfig)); - this.registerServiceImplementation(INetworkAddressInventoryRegister.class, new NetworkAddressInventoryRegister(getManager())); + this.registerServiceImplementation( + NetworkAddressInventoryCache.class, new NetworkAddressInventoryCache(getManager(), moduleConfig)); + this.registerServiceImplementation( + INetworkAddressInventoryRegister.class, new NetworkAddressInventoryRegister(getManager())); this.registerServiceImplementation(TopologyQueryService.class, new TopologyQueryService(getManager())); this.registerServiceImplementation(MetricQueryService.class, new MetricQueryService(getManager())); @@ -184,7 +184,7 @@ public class MockCoreModuleProvider extends CoreModuleProvider { @Override public String[] requiredModules() { return new String[] { - TelemetryModule.NAME + TelemetryModule.NAME }; } } diff --git a/test/e2e/e2e-common/src/main/java/org/apache/skywalking/e2e/SkyWalkingAnnotations.java b/test/e2e/e2e-common/src/main/java/org/apache/skywalking/e2e/SkyWalkingAnnotations.java index 4121ecdba2..ec35971a81 100644 --- a/test/e2e/e2e-common/src/main/java/org/apache/skywalking/e2e/SkyWalkingAnnotations.java +++ b/test/e2e/e2e-common/src/main/java/org/apache/skywalking/e2e/SkyWalkingAnnotations.java @@ -208,7 +208,7 @@ public final class SkyWalkingAnnotations { compose.withPull(true) .withLocalCompose(true) - .withTailChildContainers(!IS_CI) + .withTailChildContainers(true) .withRemoveImages(DockerComposeContainer.RemoveImages.LOCAL); if (IS_CI) { diff --git a/test/plugin/scenarios/activemq-scenario/config/expectedData.yaml b/test/plugin/scenarios/activemq-scenario/config/expectedData.yaml index 13614f547c..c61f2e9a02 100644 --- a/test/plugin/scenarios/activemq-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/activemq-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {activemq-scenario: nq 0} instances: - {activemq-scenario: nq 0} - operationNames: - - activemq-scenario: [ActiveMQ/Queue/test/Consumer, /activemq-scenario/case/activemq] heartbeat: [] segmentItems: - serviceName: activemq-scenario diff --git a/test/plugin/scenarios/apm-toolkit-trace-scenario/config/expectedData.yaml b/test/plugin/scenarios/apm-toolkit-trace-scenario/config/expectedData.yaml index 80800c7a38..14fefb6813 100644 --- a/test/plugin/scenarios/apm-toolkit-trace-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/apm-toolkit-trace-scenario/config/expectedData.yaml @@ -19,9 +19,6 @@ registryItems: - {apm-toolkit-trace-scenario: 2} instances: - {apm-toolkit-trace-scenario: 1} - operationNames: - - apm-toolkit-trace-scenario: [/case/asyncVisit/runnable, /case/asyncVisit/callable, - /case/tool-kit, /case/asyncVisit/supplier] heartbeat: [] segmentItems: - serviceName: apm-toolkit-trace-scenario @@ -196,7 +193,7 @@ segmentItems: - {key: http.method, value: GET} - {key: correlation, value: correlationValueTest} refs: - - {parentEndpointId: -1, parentEndpoint: '', + - {parentEndpointId: 0, parentEndpoint: Thread/org.apache.skywalking.apm.toolkit.trace.CallableWrapper/call, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /case/tool-kit, entryServiceInstanceId: 1} @@ -292,7 +289,7 @@ segmentItems: - {key: http.method, value: GET} - {key: correlation, value: correlationValueTest} refs: - - {parentEndpointId: -1, parentEndpoint: '', + - {parentEndpointId: 0, parentEndpoint: Thread/org.apache.skywalking.apm.toolkit.trace.RunnableWrapper/run, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /case/tool-kit, entryServiceInstanceId: 1} @@ -352,7 +349,7 @@ segmentItems: - {key: http.method, value: GET} - {key: correlation, value: correlationValueTest} refs: - - {parentEndpointId: -1, parentEndpoint: '', + - {parentEndpointId: 0, parentEndpoint: Thread/org.apache.skywalking.apm.toolkit.trace.SupplierWrapper/get, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /case/tool-kit, entryServiceInstanceId: 1} \ No newline at end of file diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/config/expectedData.yaml b/test/plugin/scenarios/armeria-0.96minus-scenario/config/expectedData.yaml index 7038128a81..c4bfaf6f51 100644 --- a/test/plugin/scenarios/armeria-0.96minus-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/armeria-0.96minus-scenario/config/expectedData.yaml @@ -20,8 +20,6 @@ registryItems: - {'armeria-0.96minus-scenario': 2} instances: - {'armeria-0.96minus-scenario': 1} - operationNames: - - 'armeria-0.96minus-scenario': [/greet/skywalking] heartbeat: [] segmentItems: - serviceName: armeria-0.96minus-scenario diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/config/expectedData.yaml b/test/plugin/scenarios/armeria-0.96plus-scenario/config/expectedData.yaml index 44e8a10f13..19125260d4 100644 --- a/test/plugin/scenarios/armeria-0.96plus-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/armeria-0.96plus-scenario/config/expectedData.yaml @@ -20,8 +20,6 @@ registryItems: - {'armeria-0.96plus-scenario': 2} instances: - {'armeria-0.96plus-scenario': 1} - operationNames: - - 'armeria-0.96plus-scenario': [/greet/skywalking] heartbeat: [] segmentItems: - serviceName: armeria-0.96plus-scenario diff --git a/test/plugin/scenarios/avro-scenario/config/expectedData.yaml b/test/plugin/scenarios/avro-scenario/config/expectedData.yaml index 4890674171..b259bd5446 100644 --- a/test/plugin/scenarios/avro-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/avro-scenario/config/expectedData.yaml @@ -20,9 +20,6 @@ registryItems: instances: - {avro-server: 1} - {avro-client: 1} - operationNames: - - avro-server: [example.proto.Greeter.hello] - - avro-client: [/avro-scenario/case/healthCheck, /avro-scenario/case/avro-scenario] heartbeat: [] segmentItems: - serviceName: avro-server diff --git a/test/plugin/scenarios/canal-scenario/config/expectedData.yaml b/test/plugin/scenarios/canal-scenario/config/expectedData.yaml index 020f6a544a..d3d4b20e4e 100644 --- a/test/plugin/scenarios/canal-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/canal-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {canal-scenario: 2} instances: - {canal-scenario: 1} - operationNames: - - canal-scenario: [/canal-scenario/case/canal-case] heartbeat: [] segmentItems: - serviceName: canal-scenario diff --git a/test/plugin/scenarios/cassandra-java-driver-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/cassandra-java-driver-3.x-scenario/config/expectedData.yaml index 45dcc1bb67..c603ca787e 100644 --- a/test/plugin/scenarios/cassandra-java-driver-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/cassandra-java-driver-3.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {cassandra-java-driver-3.x-scenario: 2} instances: - {cassandra-java-driver-3.x-scenario: 1} - operationNames: - - cassandra-java-driver-3.x-scenario: [/cassandra-java-driver-3.x-scenario/case/cassandra] heartbeat: [] segmentItems: - serviceName: cassandra-java-driver-3.x-scenario diff --git a/test/plugin/scenarios/customize-scenario/config/expectedData.yaml b/test/plugin/scenarios/customize-scenario/config/expectedData.yaml index 34f1eddc42..98884cbbdd 100644 --- a/test/plugin/scenarios/customize-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/customize-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {customize-scenario: nq 0} instances: - {customize-scenario: 1} - operationNames: - - customize-scenario: [/case/customize] segmentItems: - serviceName: customize-scenario segmentSize: gt 1 diff --git a/test/plugin/scenarios/dubbo-2.5.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/dubbo-2.5.x-scenario/config/expectedData.yaml index 6c4d00912c..0f23f9fd1a 100644 --- a/test/plugin/scenarios/dubbo-2.5.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/dubbo-2.5.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {dubbo-2.5.x-scenario: 2} instances: - {dubbo-2.5.x-scenario: 1} - operationNames: - - dubbo-2.5.x-scenario: [/dubbo-2.5.x-scenario/case/dubbo, org.apache.skywalking.apm.testcase.dubbo.services.GreetService.doBusiness()] heartbeat: [] segmentItems: - serviceName: dubbo-2.5.x-scenario diff --git a/test/plugin/scenarios/dubbo-2.7.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/dubbo-2.7.x-scenario/config/expectedData.yaml index 62548c5c5f..e497b7591f 100644 --- a/test/plugin/scenarios/dubbo-2.7.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/dubbo-2.7.x-scenario/config/expectedData.yaml @@ -18,9 +18,6 @@ registryItems: - {dubbo-2.7.x-scenario: 2} instances: - {dubbo-2.7.x-scenario: 1} - operationNames: - - dubbo-2.7.x-scenario: [/dubbo-2.7.x-scenario/case/dubbo, - org.apache.skywalking.apm.testcase.dubbo.services.GreetService.doBusiness()] heartbeat: [] segmentItems: - serviceName: dubbo-2.7.x-scenario diff --git a/test/plugin/scenarios/ehcache-2.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/ehcache-2.x-scenario/config/expectedData.yaml index 02e22562e5..54591d177f 100644 --- a/test/plugin/scenarios/ehcache-2.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/ehcache-2.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {ehcache-2.x-scenario: 2} instances: - {ehcache-2.x-scenario: 1} - operationNames: - - ehcache-2.x-scenario: [/ehcache-2.x-scenario/case/ehcache] heartbeat: [] segmentItems: - serviceName: ehcache-2.x-scenario diff --git a/test/plugin/scenarios/elasticsearch-5.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/elasticsearch-5.x-scenario/config/expectedData.yaml index dbe2c45d15..14310ad8c6 100644 --- a/test/plugin/scenarios/elasticsearch-5.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/elasticsearch-5.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {elasticsearch-5.x-scenario: nq 0} instances: - {elasticsearch-5.x-scenario: 1} - operationNames: - - elasticsearch-5.x-scenario: [/case/elasticsearch] heartbeat: [] segmentItems: - serviceName: elasticsearch-5.x-scenario diff --git a/test/plugin/scenarios/elasticsearch-6.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/elasticsearch-6.x-scenario/config/expectedData.yaml index 745377f5a1..ea0c5a7921 100644 --- a/test/plugin/scenarios/elasticsearch-6.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/elasticsearch-6.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {elasticsearch-6.x-scenario: nq 0} instances: - {elasticsearch-6.x-scenario: 1} - operationNames: - - elasticsearch-6.x-scenario: [/elasticsearch-case/case/elasticsearch] heartbeat: [] segmentItems: - serviceName: elasticsearch-6.x-scenario diff --git a/test/plugin/scenarios/elasticsearch-7.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/elasticsearch-7.x-scenario/config/expectedData.yaml index c45972fb1e..0afa00d5a9 100644 --- a/test/plugin/scenarios/elasticsearch-7.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/elasticsearch-7.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {elasticsearch-7.x-scenario: nq 0} instances: - {elasticsearch-7.x-scenario: 1} - operationNames: - - elasticsearch-7.x-scenario: [/elasticsearch-case/case/elasticsearch] heartbeat: [] segmentItems: - serviceName: elasticsearch-7.x-scenario diff --git a/test/plugin/scenarios/feign-scenario/config/expectedData.yaml b/test/plugin/scenarios/feign-scenario/config/expectedData.yaml index f2a411802c..3ef2b62cc9 100644 --- a/test/plugin/scenarios/feign-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/feign-scenario/config/expectedData.yaml @@ -18,9 +18,6 @@ registryItems: - {feign-scenario: nq 0} instances: - {feign-scenario: 1} - operationNames: - - feign-scenario: [/feign-scenario/update/1, /feign-scenario/get/1, /feign-scenario/create/, - /feign-scenario/case/feign-scenario, /feign-scenario/delete/1] heartbeat: [] segmentItems: - serviceName: feign-scenario diff --git a/test/plugin/scenarios/finagle-17.10.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/finagle-17.10.x-scenario/config/expectedData.yaml index 13e28ea818..b386a29db4 100644 --- a/test/plugin/scenarios/finagle-17.10.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/finagle-17.10.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {finagle-17.10.x-scenario: 2} instances: - {finagle-17.10.x-scenario: 1} - operationNames: - - finagle-17.10.x-scenario: [hello, /finagle-17.10.x-scenario/case/finagle] heartbeat: [] segmentItems: - serviceName: finagle-17.10.x-scenario diff --git a/test/plugin/scenarios/finagle-6.25.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/finagle-6.25.x-scenario/config/expectedData.yaml index 6f49af51ee..6141f30c5f 100644 --- a/test/plugin/scenarios/finagle-6.25.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/finagle-6.25.x-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {finagle-6.25.x-scenario: 2} instances: - {finagle-6.25.x-scenario: 1} - operationNames: - - finagle-6.25.x-scenario: [hello, /finagle-6.25.x-scenario/case/finagle] heartbeat: [] segmentItems: - serviceName: finagle-6.25.x-scenario diff --git a/test/plugin/scenarios/finagle-6.44.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/finagle-6.44.x-scenario/config/expectedData.yaml index 05ba675b19..b4bf231b51 100644 --- a/test/plugin/scenarios/finagle-6.44.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/finagle-6.44.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {finagle-6.44.x-scenario: 2} instances: - {finagle-6.44.x-scenario: 1} - operationNames: - - finagle-6.44.x-scenario: [hello, /finagle-6.44.x-scenario/case/finagle] heartbeat: [] segmentItems: - serviceName: finagle-6.44.x-scenario diff --git a/test/plugin/scenarios/gateway-scenario/config/expectedData.yaml b/test/plugin/scenarios/gateway-scenario/config/expectedData.yaml index b48b2f1300..124385d3f0 100644 --- a/test/plugin/scenarios/gateway-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/gateway-scenario/config/expectedData.yaml @@ -21,9 +21,6 @@ registryItems: instances: - {gateway-projectB-scenario: 1} - {gateway-projectA-scenario: 1} - operationNames: - - gateway-projectB-scenario: [/provider/b/testcase] - - gateway-projectA-scenario: [WEBFLUX.handle] heartbeat: [] segmentItems: - serviceName: gateway-projectB-scenario @@ -48,7 +45,7 @@ segmentItems: - {key: url, value: not null} - {key: http.method, value: GET} refs: - - {parentEndpointId: -1, parentEndpoint: '', networkAddressId: 0, + - {parentEndpointId: 0, parentEndpoint: GATEWAY/provider_route, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstanceId: not null, networkAddress: 'localhost:18070', entryEndpoint: WEBFLUX.handle, entryServiceInstanceId: not null} diff --git a/test/plugin/scenarios/grpc-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-scenario/config/expectedData.yaml index dbbec60411..e4e13fe543 100644 --- a/test/plugin/scenarios/grpc-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/grpc-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - { grpc-scenario: 2 } instances: - { grpc-scenario: 1 } - operationNames: - - grpc-scenario: [Greeter.sayHello, GreeterBlocking.sayHello, GreeterBlockingError.sayHello, /grpc-scenario/case/grpc-scenario] heartbeat: [] segmentItems: - serviceName: grpc-scenario diff --git a/test/plugin/scenarios/gson-scenario/config/expectedData.yaml b/test/plugin/scenarios/gson-scenario/config/expectedData.yaml index 95ea037db2..618da09c51 100644 --- a/test/plugin/scenarios/gson-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/gson-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {gson-scenario: nq 0} instances: - {gson-scenario: nq 0} - operationNames: - - gson-scenario: [/gson-scenario/case/gson-scenario] segmentItems: - serviceName: gson-scenario segmentSize: ge 2 diff --git a/test/plugin/scenarios/h2-scenario/config/expectedData.yaml b/test/plugin/scenarios/h2-scenario/config/expectedData.yaml index bd9da8aa16..733f817b0d 100644 --- a/test/plugin/scenarios/h2-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/h2-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {h2-scenario: 2} instances: - {h2-scenario: 1} - operationNames: - - h2-scenario: [/h2-scenario/case/h2-scenario] heartbeat: [] segmentItems: - serviceName: h2-scenario diff --git a/test/plugin/scenarios/httpasyncclient-scenario/config/expectedData.yaml b/test/plugin/scenarios/httpasyncclient-scenario/config/expectedData.yaml index a5ecd33956..41f62b8526 100644 --- a/test/plugin/scenarios/httpasyncclient-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/httpasyncclient-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {httpasyncclient-scenario: nq 0} instances: - {httpasyncclient-scenario: 1} - operationNames: - - httpasyncclient-scenario: [/httpasyncclient/case/httpasyncclient, /httpasyncclient/back] segmentItems: - serviceName: httpasyncclient-scenario segmentSize: ge 4 diff --git a/test/plugin/scenarios/httpclient-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/httpclient-3.x-scenario/config/expectedData.yaml index c0e154f310..300eff841a 100644 --- a/test/plugin/scenarios/httpclient-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/httpclient-3.x-scenario/config/expectedData.yaml @@ -18,9 +18,6 @@ registryItems: - {httpclient-3.x-scenario: 2} instances: - {httpclient-3.x-scenario: 1} - operationNames: - - httpclient-3.x-scenario: [/httpclient-3.x-scenario/case/httpclient, - /httpclient-3.x-scenario/case/context-propagate] heartbeat: [] segmentItems: - serviceName: httpclient-3.x-scenario diff --git a/test/plugin/scenarios/httpclient-4.3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/httpclient-4.3.x-scenario/config/expectedData.yaml index af156bcb57..02087bff36 100644 --- a/test/plugin/scenarios/httpclient-4.3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/httpclient-4.3.x-scenario/config/expectedData.yaml @@ -18,10 +18,6 @@ registryItems: - {httpclient-4.3.x-scenario: 2} instances: - {httpclient-4.3.x-scenario: 1} - operationNames: - - httpclient-4.3.x-scenario: [/httpclient-4.3.x-scenario/case/httpclient, - /httpclient-4.3.x-scenario/healthCheck, - /httpclient-4.3.x-scenario/case/context-propagate] heartbeat: [] segmentItems: - serviceName: httpclient-4.3.x-scenario diff --git a/test/plugin/scenarios/hystrix-scenario/config/expectedData.yaml b/test/plugin/scenarios/hystrix-scenario/config/expectedData.yaml index f02c033b8d..e2f8188493 100644 --- a/test/plugin/scenarios/hystrix-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/hystrix-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {hystrix-scenario: 2} instances: - {hystrix-scenario: 1} - operationNames: - - hystrix-scenario: [/case/hystrix-scenario] heartbeat: [] segmentItems: - serviceName: hystrix-scenario @@ -65,7 +63,7 @@ segmentItems: peer: '' peerId: 0 refs: - - {parentEndpointId: -1, parentEndpoint: '', networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, + - {parentEndpointId: 0, parentEndpoint: Hystrix/TestACommand/Execution, networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: '${hystrix-scenario[0]}', parentServiceInstanceId: nq 0, networkAddress: '', entryEndpoint: /case/hystrix-scenario, entryServiceInstanceId: nq 0} - segmentId: not null spans: diff --git a/test/plugin/scenarios/jdk-http-scenario/config/expectedData.yaml b/test/plugin/scenarios/jdk-http-scenario/config/expectedData.yaml index a220229240..23ab4f90ef 100644 --- a/test/plugin/scenarios/jdk-http-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/jdk-http-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {jdk-http-scenario: 2} instances: - {jdk-http-scenario: 1} - operationNames: - - jdk-http-scenario: [/jdk-http-scenario/case/receiveContext-0, /jdk-http-scenario/case/jdk-http-scenario] heartbeat: [] segmentItems: - serviceName: jdk-http-scenario diff --git a/test/plugin/scenarios/jdk-threading-scenario/config/expectedData.yaml b/test/plugin/scenarios/jdk-threading-scenario/config/expectedData.yaml index e5be08ef75..18245a9aea 100644 --- a/test/plugin/scenarios/jdk-threading-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/jdk-threading-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {jdk-threading-scenario: 2} instances: - {jdk-threading-scenario: 1} - operationNames: - - jdk-threading-scenario: ['/greet/{username}'] heartbeat: [] segmentItems: diff --git a/test/plugin/scenarios/jedis-scenario/config/expectedData.yaml b/test/plugin/scenarios/jedis-scenario/config/expectedData.yaml index aacdf80f65..72118d295a 100644 --- a/test/plugin/scenarios/jedis-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/jedis-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {jedis-scenario: 2} instances: - {jedis-scenario: 1} - operationNames: - - jedis-scenario: [/jedis-scenario/case/jedis-scenario] heartbeat: [] segmentItems: - serviceName: jedis-scenario diff --git a/test/plugin/scenarios/jetty-scenario/config/expectedData.yaml b/test/plugin/scenarios/jetty-scenario/config/expectedData.yaml index b4bcafed6c..d56289f5e7 100644 --- a/test/plugin/scenarios/jetty-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/jetty-scenario/config/expectedData.yaml @@ -20,10 +20,6 @@ registryItems: instances: - {jettyserver-scenario: 1} - {jettyclient-scenario: 1} - operationNames: - - jettyserver-scenario: [/jettyserver-case/case/receiveContext-0] - - jettyclient-scenario: [/jettyclient-case/case/jettyclient-case, - /jettyclient-case/case/healthCheck] segmentItems: - serviceName: jettyserver-scenario segmentSize: 1 diff --git a/test/plugin/scenarios/kafka-scenario/config/expectedData.yaml b/test/plugin/scenarios/kafka-scenario/config/expectedData.yaml index eb2b7dafa8..2f2e5fa4e4 100644 --- a/test/plugin/scenarios/kafka-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/kafka-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {kafka-scenario: 2} instances: - {kafka-scenario: 1} - operationNames: - - kafka-scenario: [Kafka/test/Consumer/testGroup, /case/kafka-case] heartbeat: [] segmentItems: - serviceName: kafka-scenario diff --git a/test/plugin/scenarios/kotlin-coroutine-scenario/config/expectedData.yaml b/test/plugin/scenarios/kotlin-coroutine-scenario/config/expectedData.yaml index 6a882e97f8..c1e891cebb 100644 --- a/test/plugin/scenarios/kotlin-coroutine-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/kotlin-coroutine-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {kotlin-coroutine-scenario: 2} instances: - {kotlin-coroutine-scenario: 1} - operationNames: - - kotlin-coroutine-scenario: [/kotlin-coroutine-scenario/case/h2] heartbeat: [] segmentItems: - serviceName: kotlin-coroutine-scenario diff --git a/test/plugin/scenarios/lettuce-scenario/config/expectedData.yaml b/test/plugin/scenarios/lettuce-scenario/config/expectedData.yaml index df6fe7ee1f..d78728c20f 100644 --- a/test/plugin/scenarios/lettuce-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/lettuce-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {lettuce-scenario: 2} instances: - {lettuce-scenario: 1} - operationNames: - - lettuce-scenario: [/lettuce-scenario/case/lettuce-case, /lettuce-scenario/case/healthCheck] heartbeat: [] segmentItems: - serviceName: lettuce-scenario diff --git a/test/plugin/scenarios/mongodb-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/mongodb-3.x-scenario/config/expectedData.yaml index 1ddcd60c09..01f851b1b2 100644 --- a/test/plugin/scenarios/mongodb-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/mongodb-3.x-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {mongodb-3.x-scenario: nq 0} instances: - {mongodb-3.x-scenario: 1} - operationNames: - - mongodb-3.x-scenario: [/mongodb-case/case/mongodb] heartbeat: [] segmentItems: diff --git a/test/plugin/scenarios/mysql-scenario/config/expectedData.yaml b/test/plugin/scenarios/mysql-scenario/config/expectedData.yaml index 929b7ef07c..9c678687e5 100644 --- a/test/plugin/scenarios/mysql-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/mysql-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {mysql-scenario: nq 0} instances: - {mysql-scenario: 1} - operationNames: - - mysql-scenario: [/mysql-scenario/case/healthCheck, /mysql-scenario/case/mysql-scenario] segmentItems: - serviceName: mysql-scenario segmentSize: ge 2 diff --git a/test/plugin/scenarios/netty-socketio-scenario/config/expectedData.yaml b/test/plugin/scenarios/netty-socketio-scenario/config/expectedData.yaml index 233fb3d50b..079e990e11 100644 --- a/test/plugin/scenarios/netty-socketio-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/netty-socketio-scenario/config/expectedData.yaml @@ -19,9 +19,6 @@ registryItems: - {netty-socketio-scenario: 2} instances: - {netty-socketio-scenario: 1} - operationNames: - - netty-socketio-scenario: [/netty-socketio-scenario/case/netty-socketio, - /netty-socketio-scenario/healthCheck, SocketIO/onConnect, SocketIO/send_data/receive] heartbeat: [] segmentItems: - serviceName: netty-socketio-scenario diff --git a/test/plugin/scenarios/okhttp-scenario/config/expectedData.yaml b/test/plugin/scenarios/okhttp-scenario/config/expectedData.yaml index 8b5f782f1d..00c1a1ddb7 100644 --- a/test/plugin/scenarios/okhttp-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/okhttp-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {okhttp-scenario: nq 0} instances: - {okhttp-scenario: 1} - operationNames: - - okhttp-scenario: [/case/receiveContext-0, /case/healthCheck, /case/okhttp-case, /case/receiveContext-1] heartbeat: [] segmentItems: - serviceName: okhttp-scenario @@ -76,7 +74,7 @@ segmentItems: - {key: url, value: 'http://127.0.0.1:8080/okhttp-case/case/receiveContext-0'} - {key: http.method, value: GET} refs: - - {parentEndpointId: -1, parentEndpoint: '', networkAddressId: 0, entryEndpointId: 0, + - {parentEndpointId: 0, parentEndpoint: /okhttp-case/case/receiveContext-0, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: nq 0, parentServiceInstanceId: nq 0, networkAddress: '127.0.0.1:8080', entryEndpoint: /case/okhttp-case, entryServiceInstanceId: nq 0} - segmentId: not null @@ -98,7 +96,7 @@ segmentItems: - {key: url, value: 'http://127.0.0.1:8080/okhttp-case/case/receiveContext-1'} - {key: http.method, value: GET} refs: - - {parentEndpointId: -1, parentEndpoint: '', networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 0, + - {parentEndpointId: 0, parentEndpoint: /okhttp-case/case/receiveContext-0, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: nq 0, parentServiceInstanceId: nq 0, networkAddress: '127.0.0.1:8080', entryEndpoint: /case/okhttp-case, entryServiceInstanceId: nq 0} - segmentId: not null spans: diff --git a/test/plugin/scenarios/oracle-scenario/config/expectedData.yaml b/test/plugin/scenarios/oracle-scenario/config/expectedData.yaml index 1a209b4575..df1168063b 100644 --- a/test/plugin/scenarios/oracle-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/oracle-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {oracle-scenario: nq 0} instances: - {oracle-scenario: 1} - operationNames: - - oracle-scenario: [/oracle-scenario/case/oracle] segmentItems: - serviceName: oracle-scenario segmentSize: ge 1 diff --git a/test/plugin/scenarios/play-scenario/config/expectedData.yaml b/test/plugin/scenarios/play-scenario/config/expectedData.yaml index e9c7668c9a..b2f5337dbe 100644 --- a/test/plugin/scenarios/play-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/play-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {play-scenario: 2} instances: - {play-scenario: 1} - operationNames: - - play-scenario: ["/play-scenario/case/play-scenario/projects/{projectId}"] segmentItems: - serviceName: play-scenario segmentSize: gt 1 diff --git a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml index a374546a6b..b6b0269eb4 100644 --- a/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/postgresql-above9.4.1207-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {postgresql-above9.4.1207-scenario: nq 0} instances: - {postgresql-above9.4.1207-scenario: 1} - operationNames: - - postgresql-above9.4.1207-scenario: [/postgresql-scenario/case/postgres] segmentItems: - serviceName: postgresql-above9.4.1207-scenario segmentSize: ge 1 diff --git a/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml b/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml index 44493b7317..b9b666d54f 100644 --- a/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/postgresql-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {postgresql-scenario: nq 0} instances: - {postgresql-scenario: 1} - operationNames: - - postgresql-scenario: [/postgresql-scenario/case/postgres] heartbeat: [] segmentItems: - serviceName: postgresql-scenario diff --git a/test/plugin/scenarios/pulsar-scenario/config/expectedData.yaml b/test/plugin/scenarios/pulsar-scenario/config/expectedData.yaml index a7316759d4..0d9f84a9c3 100644 --- a/test/plugin/scenarios/pulsar-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/pulsar-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {pulsar-scenario: nq 0} instances: - {pulsar-scenario: nq 0} - operationNames: - - pulsar-scenario: [/case/pulsar-case, Pulsar/test/Consumer/test] segmentItems: - serviceName: pulsar-scenario segmentSize: ge 3 diff --git a/test/plugin/scenarios/rabbitmq-scenario/config/expectedData.yaml b/test/plugin/scenarios/rabbitmq-scenario/config/expectedData.yaml index a1d9a89595..a12cfc806b 100644 --- a/test/plugin/scenarios/rabbitmq-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/rabbitmq-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {rabbitmq-scenario: nq 0} instances: - {rabbitmq-scenario: 1} - operationNames: - - rabbitmq-scenario: [/rabbitmq-scenario/case/rabbitmq, RabbitMQ/Topic/Queue/test/Consumer] segmentItems: - serviceName: rabbitmq-scenario segmentSize: gt 2 diff --git a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml index d1c33a9bed..eb2bf267fd 100644 --- a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {redisson-scenario: 2} instances: - {redisson-scenario: 1} - operationNames: - - redisson-scenario: [/case/healthCheck, /case/redisson-case] heartbeat: [] segmentItems: - serviceName: redisson-scenario diff --git a/test/plugin/scenarios/resttemplate-4.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/resttemplate-4.x-scenario/config/expectedData.yaml index 43d57d39c9..03966f2f9e 100644 --- a/test/plugin/scenarios/resttemplate-4.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/resttemplate-4.x-scenario/config/expectedData.yaml @@ -18,9 +18,6 @@ registryItems: - {resttemplate-4.x-scenario: nq 0} instances: - {resttemplate-4.x-scenario: 1} - operationNames: - - resttemplate-4.x-scenario: [/resttemplate-4.x-scenario/resttemplate/asyncback, /resttemplate-4.x-scenario/resttemplate/case/resttemplate, - /resttemplate-4.x-scenario/resttemplate/syncback] heartbeat: [] segmentItems: - serviceName: resttemplate-4.x-scenario diff --git a/test/plugin/scenarios/servicecomb-0.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/servicecomb-0.x-scenario/config/expectedData.yaml index 6b6dae5820..62cea6aa8c 100644 --- a/test/plugin/scenarios/servicecomb-0.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/servicecomb-0.x-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {servicecomb-0.x-scenario: 2} instances: - {servicecomb-0.x-scenario: 1} - operationNames: - - servicecomb-0.x-scenario: [codefirst.codeFirstSpringmvcHelloClient.say, codefirst.codeFirstHello.sayHi] heartbeat: [] segmentItems: - serviceName: servicecomb-0.x-scenario diff --git a/test/plugin/scenarios/servicecomb-1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/servicecomb-1.x-scenario/config/expectedData.yaml index 21816a9c7e..fa579a4178 100644 --- a/test/plugin/scenarios/servicecomb-1.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/servicecomb-1.x-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {servicecomb-1.x-scenario: 2} instances: - {servicecomb-1.x-scenario: 1} - operationNames: - - servicecomb-1.x-scenario: [codefirst.codeFirstSpringmvcHelloClient.say, codefirst.codeFirstHello.sayHi] heartbeat: [] segmentItems: - serviceName: servicecomb-1.x-scenario diff --git a/test/plugin/scenarios/shardingsphere-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/shardingsphere-3.x-scenario/config/expectedData.yaml index f02c68bd71..c1fda50f99 100644 --- a/test/plugin/scenarios/shardingsphere-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/shardingsphere-3.x-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {shardingsphere-3.x-scenario: nq 0} instances: - {shardingsphere-3.x-scenario: 1} - operationNames: - - shardingsphere-3.x-scenario: [/shardingsphere-3.x-scenario/case/execute] heartbeat: [] segmentItems: - serviceName: shardingsphere-3.x-scenario diff --git a/test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/config/expectedData.yaml b/test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/config/expectedData.yaml index b45895a0d1..bd4913f6f6 100644 --- a/test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/shardingsphere-4.x-RC1-RC2-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {shardingsphere-4.x-RC1-RC2-scenario: nq 0} instances: - {shardingsphere-4.x-RC1-RC2-scenario: 1} - operationNames: - - shardingsphere-4.x-RC1-RC2-scenario: [/shardingsphere-4.x-RC1-RC2-scenario/case/execute] heartbeat: [] segmentItems: - serviceName: shardingsphere-4.x-RC1-RC2-scenario diff --git a/test/plugin/scenarios/shardingsphere-4.x-RC3-scenario/config/expectedData.yaml b/test/plugin/scenarios/shardingsphere-4.x-RC3-scenario/config/expectedData.yaml index a4990cb6a7..f2d3e4fe7d 100644 --- a/test/plugin/scenarios/shardingsphere-4.x-RC3-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/shardingsphere-4.x-RC3-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {shardingsphere-4.x-RC3-scenario: nq 0} instances: - {shardingsphere-4.x-RC3-scenario: 1} - operationNames: - - shardingsphere-4.x-RC3-scenario: [/shardingsphere-4.x-RC3-scenario/case/execute] heartbeat: [] segmentItems: - serviceName: shardingsphere-4.x-RC3-scenario diff --git a/test/plugin/scenarios/sofarpc-scenario/config/expectedData.yaml b/test/plugin/scenarios/sofarpc-scenario/config/expectedData.yaml index d48c5b1fdb..1d9fd765f1 100644 --- a/test/plugin/scenarios/sofarpc-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/sofarpc-scenario/config/expectedData.yaml @@ -19,9 +19,6 @@ registryItems: - {sofarpc-scenario: 2} instances: - {sofarpc-scenario: 1} - operationNames: - - sofarpc-scenario: [org.apache.skywalking.apm.testcase.sofarpc.interfaces.SofaRpcDemoService.hello(java.lang.String), - /sofarpc-scenario/case/sofarpc] heartbeat: [] segmentItems: - serviceName: sofarpc-scenario diff --git a/test/plugin/scenarios/solrj-7.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/solrj-7.x-scenario/config/expectedData.yaml index b9781b473e..e2355659c5 100644 --- a/test/plugin/scenarios/solrj-7.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/solrj-7.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {solrj-7.x-scenario: nq 0} instances: - {solrj-7.x-scenario: nq 0} - operationNames: - - solrj-7.x-scenario: [/solrj-scenario/case/solrj] heartbeat: [] segmentItems: - serviceName: solrj-7.x-scenario diff --git a/test/plugin/scenarios/spring-3.0.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-3.0.x-scenario/config/expectedData.yaml index 322a191689..380c2a563d 100644 --- a/test/plugin/scenarios/spring-3.0.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-3.0.x-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {spring-3.0.x-scenario: 2} instances: - {spring-3.0.x-scenario: 1} - operationNames: - - spring-3.0.x-scenario: [/healthCheck, /case/spring3] heartbeat: [] segmentItems: - serviceName: spring-3.0.x-scenario diff --git a/test/plugin/scenarios/spring-3.1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-3.1.x-scenario/config/expectedData.yaml index 3e3bedbd32..d68689625d 100644 --- a/test/plugin/scenarios/spring-3.1.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-3.1.x-scenario/config/expectedData.yaml @@ -18,10 +18,6 @@ registryItems: - {spring-3.1.x-scenario: 2} instances: - {spring-3.1.x-scenario: 1} - operationNames: - - spring-3.1.x-scenario: ['{DELETE}/delete/{id}', /case/resttemplate, '{GET}/get/{id}', - '{POST}/create/', /healthCheck, /case/spring3, - '{PUT}/update/{id}'] heartbeat: [] segmentItems: - serviceName: spring-3.1.x-scenario diff --git a/test/plugin/scenarios/spring-4.1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-4.1.x-scenario/config/expectedData.yaml index 14cfa9ae35..79fb337fe4 100644 --- a/test/plugin/scenarios/spring-4.1.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-4.1.x-scenario/config/expectedData.yaml @@ -18,9 +18,6 @@ registryItems: - {spring-4.1.x-scenario: 2} instances: - {spring-4.1.x-scenario: 1} - operationNames: - - spring-4.1.x-scenario: ['{DELETE}/delete/{id}', /case/resttemplate, '{GET}/get/{id}', - '{POST}/create/', /healthCheck, /case/spring3, '{PUT}/update/{id}'] heartbeat: [] segmentItems: - serviceName: spring-4.1.x-scenario diff --git a/test/plugin/scenarios/spring-4.3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-4.3.x-scenario/config/expectedData.yaml index 2d7776deba..72cd02aa2e 100644 --- a/test/plugin/scenarios/spring-4.3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-4.3.x-scenario/config/expectedData.yaml @@ -18,10 +18,6 @@ registryItems: - {spring-4.3.x-scenario: 2} instances: - {spring-4.3.x-scenario: 1} - operationNames: - - spring-4.3.x-scenario: [/create/, '/delete/{id}', /inherit/child/test, /healthCheck, - '/get/{id}', '/update/{id}', /case/resttemplate, - /case/spring3, /impl/requestmapping, /impl/restmapping] heartbeat: [] segmentItems: - serviceName: spring-4.3.x-scenario diff --git a/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml index ea4056c0c6..026dc2751d 100644 --- a/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {spring-async-scenario: 2} instances: - {spring-async-scenario: 1} - operationNames: - - spring-async-scenario: [/spring-async-scenario/case/asyncVisit, /spring-async-scenario/case/spring-async] heartbeat: [] segmentItems: - serviceName: spring-async-scenario @@ -63,7 +61,7 @@ segmentItems: - {key: url, value: 'http://localhost:8080/spring-async-scenario/case/asyncVisit'} - {key: http.method, value: GET} refs: - - {parentEndpointId: -1, parentEndpoint: '', networkAddressId: 0, entryEndpointId: 0, + - {parentEndpointId: 0, parentEndpoint: SpringAsync, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /spring-async-scenario/case/spring-async, entryServiceInstanceId: 1} @@ -86,7 +84,7 @@ segmentItems: - {key: url, value: 'http://localhost:8080/spring-async-scenario/case/asyncVisit'} - {key: http.method, value: GET} refs: - - {parentEndpointId: -1, parentEndpoint: '', networkAddressId: 0, entryEndpointId: 0, + - {parentEndpointId: 0, parentEndpoint: SpringAsync, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /spring-async-scenario/case/spring-async, entryServiceInstanceId: 1} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml index 381a880a0b..512f03c344 100644 --- a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml @@ -18,9 +18,6 @@ registryItems: - {spring-cloud-feign-1.1.x-scenario: nq 0} instances: - {spring-cloud-feign-1.1.x-scenario: 1} - operationNames: - - spring-cloud-feign-1.1.x-scenario: [/spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario, - /spring-cloud-feign-1.1.x-scenario/get] heartbeat: [] segmentItems: - serviceName: spring-cloud-feign-1.1.x-scenario diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml index 9f8e496f8a..0cba2b146c 100644 --- a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml @@ -18,9 +18,6 @@ registryItems: - {spring-cloud-feign-1.2.x-scenario: nq 0} instances: - {spring-cloud-feign-1.2.x-scenario: 1} - operationNames: - - spring-cloud-feign-1.2.x-scenario: [/spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario, - /spring-cloud-feign-1.2.x-scenario/get] heartbeat: [] segmentItems: - serviceName: spring-cloud-feign-1.2.x-scenario diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/config/expectedData.yaml index edce0ed9f5..0982e69fbf 100644 --- a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/config/expectedData.yaml @@ -18,10 +18,6 @@ registryItems: - {spring-cloud-feign-2.x-scenario: nq 0} instances: - {spring-cloud-feign-2.x-scenario: 1} - operationNames: - - spring-cloud-feign-2.x-scenario: [/spring-cloud-feign-2.x-scenario/update/1, /spring-cloud-feign-2.x-scenario/create/, - /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, - /spring-cloud-feign-2.x-scenario/delete/1, /spring-cloud-feign-2.x-scenario/get/1] heartbeat: [] segmentItems: - serviceName: spring-cloud-feign-2.x-scenario diff --git a/test/plugin/scenarios/spring-tx-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-tx-scenario/config/expectedData.yaml index 3f7a4f2279..043a27fe9f 100644 --- a/test/plugin/scenarios/spring-tx-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-tx-scenario/config/expectedData.yaml @@ -19,8 +19,6 @@ registryItems: - {spring-tx-scenario: 2} instances: - {spring-tx-scenario: 1} - operationNames: - - spring-tx-scenario: [/case/spring-tx-case, /case/healthCheck] heartbeat: [] segmentItems: - serviceName: spring-tx-scenario diff --git a/test/plugin/scenarios/struts2.3-scenario/config/expectedData.yaml b/test/plugin/scenarios/struts2.3-scenario/config/expectedData.yaml index 5d400a0a1e..a6fc9d6ac3 100644 --- a/test/plugin/scenarios/struts2.3-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/struts2.3-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {struts2.3-scenario: 2} instances: - {struts2.3-scenario: 1} - operationNames: - - struts2.3-scenario: [/struts2.3-scenario/struts-scenario/case1.action, /struts2.3-scenario/struts-scenario/case.action] heartbeat: [] segmentItems: - serviceName: struts2.3-scenario diff --git a/test/plugin/scenarios/struts2.5-scenario/config/expectedData.yaml b/test/plugin/scenarios/struts2.5-scenario/config/expectedData.yaml index bf3c2c63bc..b14ab6e8e2 100644 --- a/test/plugin/scenarios/struts2.5-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/struts2.5-scenario/config/expectedData.yaml @@ -18,8 +18,6 @@ registryItems: - {struts2.5-scenario: 2} instances: - {struts2.5-scenario: 1} - operationNames: - - struts2.5-scenario: [/struts2.5-scenario/struts-scenario/case1.action, /struts2.5-scenario/struts-scenario/case.action] heartbeat: [] segmentItems: - serviceName: struts2.5-scenario diff --git a/test/plugin/scenarios/undertow-scenario/config/expectedData.yaml b/test/plugin/scenarios/undertow-scenario/config/expectedData.yaml index 4f811c245a..f53e423ff8 100644 --- a/test/plugin/scenarios/undertow-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/undertow-scenario/config/expectedData.yaml @@ -19,9 +19,6 @@ registryItems: - {undertow-scenario: 2} instances: - {undertow-scenario: 1} - operationNames: - - undertow-scenario: [/undertow-scenario/case/undertow1, /undertow-scenario/case/undertow, - '/undertow-routing-scenario/case/{context}'] heartbeat: [] segmentItems: - serviceName: undertow-scenario @@ -64,7 +61,7 @@ segmentItems: - {key: url, value: 'http://localhost:8081/undertow-routing-scenario/case/undertow'} - {key: http.method, value: GET} refs: - - {parentEndpointId: -1, parentEndpoint: '', networkAddressId: 0, + - {parentEndpointId: 0, parentEndpoint: UndertowDispatch, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: 'localhost:8081', entryEndpoint: /undertow-scenario/case/undertow, entryServiceInstanceId: 1} @@ -87,7 +84,7 @@ segmentItems: - {key: url, value: 'http://localhost:8080/undertow-scenario/case/undertow1'} - {key: http.method, value: GET} refs: - - {parentEndpointId: -1, parentEndpoint: '', networkAddressId: 0, + - {parentEndpointId: 0, parentEndpoint: UndertowDispatch, networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /undertow-scenario/case/undertow, entryServiceInstanceId: 1} diff --git a/test/plugin/scenarios/webflux-scenario/config/expectedData.yaml b/test/plugin/scenarios/webflux-scenario/config/expectedData.yaml index 91b194feea..f8ca4d1bd8 100644 --- a/test/plugin/scenarios/webflux-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/webflux-scenario/config/expectedData.yaml @@ -21,9 +21,6 @@ registryItems: instances: - {webflux-projectB-scenario: 1} - {webflux-projectA-scenario: 1} - operationNames: - - webflux-projectB-scenario: [WEBFLUX.handle] - - webflux-projectA-scenario: [/projectA/testcase] heartbeat: [] segmentItems: - serviceName: webflux-projectB-scenario diff --git a/test/plugin/scenarios/zookeeper-scenario/config/expectedData.yaml b/test/plugin/scenarios/zookeeper-scenario/config/expectedData.yaml index 6ed7304f20..c6137e9df5 100644 --- a/test/plugin/scenarios/zookeeper-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/zookeeper-scenario/config/expectedData.yaml @@ -19,9 +19,6 @@ registryItems: - {zookeeper-scenario: 2} instances: - {zookeeper-scenario: 1} - operationNames: - - zookeeper-scenario: [Zookeeper/WatchedEvent/NodeDeleted, /zookeeper-scenario/case/zookeeper-case, - /zookeeper-scenario/case/healthCheck] heartbeat: [] segmentItems: - serviceName: zookeeper-scenario -- GitLab