Remove timeout offset and correct `MetricsExtension` declarations (#10098)
* Remove timeout offset and correct `MetricsExtension` declarations * Fix ProcessRelation topology overlap for nodes communication with multiple component IDs.(HTTP and TCP) * Support component IDs' priority in process relationship metrics. * Remove abandon logic in MergableBufferedData, which caused unexpected no-update.
This commit is contained in:
parent
4be7a2ef88
commit
d6fa688ff8
|
|
@ -21,6 +21,10 @@
|
|||
// for the specific minute of booted successfully, the metrics are expected to load from database when
|
||||
// it doesn't exist in the cache.
|
||||
```
|
||||
* Remove the offset of metric session timeout according to worker creation sequence.
|
||||
* Correct `MetricsExtension` annotations declarations in manual entities.
|
||||
* Support component IDs' priority in process relation metrics.
|
||||
* Remove abandon logic in MergableBufferedData, which caused unexpected no-update.
|
||||
|
||||
#### UI
|
||||
|
||||
|
|
|
|||
|
|
@ -51,10 +51,7 @@ public class MergableBufferedData<METRICS extends Metrics> implements BufferedDa
|
|||
if (existed == null) {
|
||||
buffer.put(id, data);
|
||||
} else {
|
||||
final boolean isAbandoned = !existed.combine(data);
|
||||
if (isAbandoned) {
|
||||
buffer.remove(id);
|
||||
}
|
||||
existed.combine(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.analysis.MetricsExtension;
|
||||
import org.apache.skywalking.oap.server.core.analysis.Stream;
|
||||
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
|
||||
import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor;
|
||||
|
|
@ -40,6 +41,7 @@ import static org.apache.skywalking.oap.server.core.analysis.metrics.Metrics.TIM
|
|||
|
||||
@Stream(name = EndpointRelationServerSideMetrics.INDEX_NAME, scopeId = DefaultScopeDefine.ENDPOINT_RELATION,
|
||||
builder = EndpointRelationServerSideMetrics.Builder.class, processor = MetricsStreamProcessor.class)
|
||||
@MetricsExtension(supportDownSampling = true, supportUpdate = false, timeRelativeID = true)
|
||||
@EqualsAndHashCode(of = {
|
||||
"entityId"
|
||||
}, callSuper = true)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* 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.relation.process;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* ProcessNetworkRelationIDs indicates the IDs with the priority for process network relation.
|
||||
*
|
||||
* @since 9.4.0
|
||||
*/
|
||||
public enum ProcessNetworkRelationIDs {
|
||||
HTTPS(129, 4),
|
||||
HTTP(49, 3),
|
||||
TCP_TLS(130, 2),
|
||||
TCP(110, 1);
|
||||
|
||||
/**
|
||||
* ID from component-libraries.yml definition.
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* The higher the atomic number, the higher the priority
|
||||
*/
|
||||
private Integer priority;
|
||||
|
||||
ProcessNetworkRelationIDs(final int id, final int priority) {
|
||||
this.id = id;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if componentA has higher priority
|
||||
*/
|
||||
public static boolean compare(int componentA, int componentB) {
|
||||
final Integer priorityA = (Integer) ID_2_PRIORITY.getOrDefault(componentA, 0);
|
||||
final Integer priorityB = (Integer) ID_2_PRIORITY.getOrDefault(componentB, 0);
|
||||
return priorityA.compareTo(priorityB) > 0;
|
||||
}
|
||||
|
||||
private static HashMap ID_2_PRIORITY = new HashMap<Integer, Integer>(4);
|
||||
|
||||
static {
|
||||
initMapping(TCP);
|
||||
initMapping(TCP_TLS);
|
||||
initMapping(HTTP);
|
||||
initMapping(HTTPS);
|
||||
}
|
||||
|
||||
private static void initMapping(ProcessNetworkRelationIDs componentId) {
|
||||
ID_2_PRIORITY.put(componentId.id, componentId.priority);
|
||||
}
|
||||
}
|
||||
|
|
@ -36,10 +36,11 @@ import org.apache.skywalking.oap.server.core.storage.type.Convert2Storage;
|
|||
import org.apache.skywalking.oap.server.core.storage.type.StorageBuilder;
|
||||
|
||||
@Stream(name = ProcessRelationClientSideMetrics.INDEX_NAME, scopeId = DefaultScopeDefine.PROCESS_RELATION,
|
||||
builder = ProcessRelationClientSideMetrics.Builder.class, processor = MetricsStreamProcessor.class)
|
||||
builder = ProcessRelationClientSideMetrics.Builder.class, processor = MetricsStreamProcessor.class)
|
||||
@MetricsExtension(supportDownSampling = false, supportUpdate = true, timeRelativeID = true)
|
||||
@EqualsAndHashCode(of = {
|
||||
"entityId"
|
||||
"entityId",
|
||||
"component_id"
|
||||
}, callSuper = true)
|
||||
@SQLDatabase.Sharding(shardingAlgorithm = ShardingAlgorithm.NO_SHARDING)
|
||||
public class ProcessRelationClientSideMetrics extends Metrics {
|
||||
|
|
@ -78,10 +79,12 @@ public class ProcessRelationClientSideMetrics extends Metrics {
|
|||
|
||||
@Override
|
||||
public boolean combine(Metrics metrics) {
|
||||
if (this.getTimeBucket() > metrics.getTimeBucket()) {
|
||||
this.setTimeBucket(metrics.getTimeBucket());
|
||||
final ProcessRelationClientSideMetrics processRelationClientSideMetrics = (ProcessRelationClientSideMetrics) metrics;
|
||||
if (ProcessNetworkRelationIDs.compare(this.componentId, processRelationClientSideMetrics.getComponentId())) {
|
||||
this.setComponentId(processRelationClientSideMetrics.getComponentId());
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ import org.apache.skywalking.oap.server.core.storage.type.Convert2Storage;
|
|||
import org.apache.skywalking.oap.server.core.storage.type.StorageBuilder;
|
||||
|
||||
@Stream(name = ProcessRelationServerSideMetrics.INDEX_NAME, scopeId = DefaultScopeDefine.PROCESS_RELATION,
|
||||
builder = ProcessRelationServerSideMetrics.Builder.class, processor = MetricsStreamProcessor.class)
|
||||
builder = ProcessRelationServerSideMetrics.Builder.class, processor = MetricsStreamProcessor.class)
|
||||
@MetricsExtension(supportDownSampling = false, supportUpdate = true, timeRelativeID = true)
|
||||
@EqualsAndHashCode(of = {
|
||||
"entityId"
|
||||
"entityId"
|
||||
}, callSuper = true)
|
||||
@SQLDatabase.Sharding(shardingAlgorithm = ShardingAlgorithm.NO_SHARDING)
|
||||
public class ProcessRelationServerSideMetrics extends Metrics {
|
||||
|
|
@ -78,10 +78,12 @@ public class ProcessRelationServerSideMetrics extends Metrics {
|
|||
|
||||
@Override
|
||||
public boolean combine(Metrics metrics) {
|
||||
if (this.getTimeBucket() > metrics.getTimeBucket()) {
|
||||
this.setTimeBucket(metrics.getTimeBucket());
|
||||
final ProcessRelationServerSideMetrics processRelationServerSideMetrics = (ProcessRelationServerSideMetrics) metrics;
|
||||
if (ProcessNetworkRelationIDs.compare(this.componentId, processRelationServerSideMetrics.getComponentId())) {
|
||||
this.setComponentId(processRelationServerSideMetrics.getComponentId());
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -77,11 +77,9 @@ public class ServiceRelationClientSideMetrics extends Metrics {
|
|||
ServiceRelationClientSideMetrics serviceRelationClientSideMetrics = (ServiceRelationClientSideMetrics) metrics;
|
||||
if (this.getComponentId() == 0 && serviceRelationClientSideMetrics.getComponentId() != 0) {
|
||||
this.componentId = serviceRelationClientSideMetrics.getComponentId();
|
||||
return true;
|
||||
}
|
||||
if (this.getTimeBucket() > metrics.getTimeBucket()) {
|
||||
this.setTimeBucket(metrics.getTimeBucket());
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import lombok.EqualsAndHashCode;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.analysis.MetricsExtension;
|
||||
import org.apache.skywalking.oap.server.core.analysis.Stream;
|
||||
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
|
||||
import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor;
|
||||
|
|
@ -40,6 +41,7 @@ import static org.apache.skywalking.oap.server.core.analysis.metrics.Metrics.TIM
|
|||
|
||||
@Stream(name = ServiceRelationServerSideMetrics.INDEX_NAME, scopeId = DefaultScopeDefine.SERVICE_RELATION,
|
||||
builder = ServiceRelationServerSideMetrics.Builder.class, processor = MetricsStreamProcessor.class)
|
||||
@MetricsExtension(supportDownSampling = true, supportUpdate = true, timeRelativeID = true)
|
||||
@EqualsAndHashCode(of = {
|
||||
"entityId"
|
||||
}, callSuper = true)
|
||||
|
|
@ -76,7 +78,12 @@ public class ServiceRelationServerSideMetrics extends Metrics {
|
|||
|
||||
@Override
|
||||
public boolean combine(Metrics metrics) {
|
||||
return true;
|
||||
ServiceRelationServerSideMetrics serviceRelationServerSideMetrics = (ServiceRelationServerSideMetrics) metrics;
|
||||
if (this.getComponentId() == 0 && serviceRelationServerSideMetrics.getComponentId() != 0) {
|
||||
this.componentId = serviceRelationServerSideMetrics.getComponentId();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -150,7 +157,8 @@ public class ServiceRelationServerSideMetrics extends Metrics {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void entity2Storage(final ServiceRelationServerSideMetrics storageData, final Convert2Storage converter) {
|
||||
public void entity2Storage(final ServiceRelationServerSideMetrics storageData,
|
||||
final Convert2Storage converter) {
|
||||
converter.accept(ENTITY_ID, storageData.getEntityId());
|
||||
converter.accept(SOURCE_SERVICE_ID, storageData.getSourceServiceId());
|
||||
converter.accept(DEST_SERVICE_ID, storageData.getDestServiceId());
|
||||
|
|
|
|||
|
|
@ -53,11 +53,6 @@ import org.apache.skywalking.oap.server.telemetry.api.MetricsTag;
|
|||
*/
|
||||
@Slf4j
|
||||
public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
|
||||
/**
|
||||
* The counter of MetricsPersistentWorker instance, to calculate session timeout offset.
|
||||
*/
|
||||
private static long SESSION_TIMEOUT_OFFSITE_COUNTER = 0;
|
||||
|
||||
private final Model model;
|
||||
private final MetricsSessionCache sessionCache;
|
||||
private final IMetricsDAO metricsDAO;
|
||||
|
|
@ -157,7 +152,6 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
|
|||
"metrics_persistent_cache", "The counter of metrics status, new or cached.",
|
||||
new MetricsTag.Keys("status"), new MetricsTag.Values("cached")
|
||||
);
|
||||
SESSION_TIMEOUT_OFFSITE_COUNTER++;
|
||||
serverStatusService = moduleDefineHolder.find(CoreModule.NAME).provider().getService(ServerStatusService.class);
|
||||
}
|
||||
|
||||
|
|
@ -176,9 +170,7 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
|
|||
supportUpdate, storageSessionTimeout, metricsDataTTL, kind
|
||||
);
|
||||
// For a down-sampling metrics, we prolong the session timeout for 4 times, nearly 5 minutes.
|
||||
// And add offset according to worker creation sequence, to avoid context clear overlap,
|
||||
// eventually optimize load of IDs reading.
|
||||
sessionCache.setTimeoutThreshold(storageSessionTimeout * 4 + SESSION_TIMEOUT_OFFSITE_COUNTER * 200);
|
||||
sessionCache.setTimeoutThreshold(storageSessionTimeout * 4);
|
||||
// The down sampling level worker executes every 4 periods.
|
||||
this.persistentMod = 4;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue