Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import static org.apache.bifromq.metrics.TenantMetric.MqttQoS2DistBytes;
import static org.apache.bifromq.metrics.TenantMetric.MqttQoS2ExternalLatency;
import static org.apache.bifromq.metrics.TenantMetric.MqttQoS2IngressBytes;
import static org.apache.bifromq.metrics.TenantMetric.MqttTransientSubLatency;
import static org.apache.bifromq.mqtt.handler.IMQTTProtocolHelper.SubResult.EXCEED_LIMIT;
import static org.apache.bifromq.mqtt.handler.MQTTSessionIdUtil.packetId;
import static org.apache.bifromq.mqtt.handler.MQTTSessionIdUtil.userSessionId;
Expand Down Expand Up @@ -570,12 +569,10 @@ protected final CompletableFuture<IMQTTProtocolHelper.SubResult> checkAndSubscri
.setUserProperties(grantedUserProps);
subTask.subId().ifPresent(optionBuilder::setSubId);
TopicFilterOption tfOption = optionBuilder.build();
Timer.Sample start = Timer.start();
return addFgTask(subTopicFilter(reqId, topicFilter, tfOption))
.thenComposeAsync(subResult -> {
switch (subResult) {
case OK, EXISTS -> {
start.stop(tenantMeter.timer(MqttTransientSubLatency));
if (!isSharedSubscription(topicFilter) && settings.retainEnabled
&& (tfOption.getRetainHandling() == SEND_AT_SUBSCRIBE
|| (subResult == IMQTTProtocolHelper.SubResult.OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.apache.bifromq.metrics.TenantMetric.MqttQoS1InternalLatency;
import static org.apache.bifromq.metrics.TenantMetric.MqttQoS2InternalLatency;
import static org.apache.bifromq.metrics.TenantMetric.MqttTransientSubCount;
import static org.apache.bifromq.metrics.TenantMetric.MqttTransientSubLatency;
import static org.apache.bifromq.metrics.TenantMetric.MqttTransientUnsubCount;
import static org.apache.bifromq.metrics.TenantMetric.MqttTransientUnsubLatency;
import static org.apache.bifromq.mqtt.handler.IMQTTProtocolHelper.SubResult.EXCEED_LIMIT;
Expand Down Expand Up @@ -181,10 +182,12 @@ protected final CompletableFuture<IMQTTProtocolHelper.SubResult> subTopicFilter(
memUsage.addAndGet(topicFilter.length());
memUsage.addAndGet(option.getSerializedSize());
}
Timer.Sample start = Timer.start();
return addMatchRecord(reqId, topicFilter, option.getIncarnation())
.thenApplyAsync(matchResult -> {
switch (matchResult) {
case OK -> {
start.stop(tenantMeter.timer(MqttTransientSubLatency));
if (prevOption == null) {
return OK;
} else {
Expand Down
Loading