Skip to content

Commit

Permalink
Offloader metrics (apache#13833)
Browse files Browse the repository at this point in the history
### Motivation
Currently, there is no offload metrics for tiered storage, so it is very hard for us to debug the performance issues. For example , we can not find why offload is slow or why read offload is slow. For above reasons. we need to add some offload metrics for monitoring.

### Modifications
Add metrics during offload procedure and read offload data procedure. Including offloadTime, offloadError, offloadRate, readLedgerLatency, writeStoreLatency, writeStoreError, readOffloadIndexLatency, readOffloadDataLatency, readOffloadRate, readOffloadError.
  • Loading branch information
tjiuming authored Apr 15, 2022
1 parent d8923b8 commit 732049f
Show file tree
Hide file tree
Showing 22 changed files with 996 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public interface LedgerOffloaderFactory<T extends LedgerOffloader> {
*/
T create(OffloadPoliciesImpl offloadPolicies,
Map<String, String> userMetadata,
OrderedScheduler scheduler)
OrderedScheduler scheduler,
LedgerOffloaderStats offloaderStats)
throws IOException;

/**
Expand All @@ -68,8 +69,9 @@ T create(OffloadPoliciesImpl offloadPolicies,
default T create(OffloadPoliciesImpl offloadPolicies,
Map<String, String> userMetadata,
SchemaStorage schemaStorage,
OrderedScheduler scheduler)
OrderedScheduler scheduler,
LedgerOffloaderStats offloaderStats)
throws IOException {
return create(offloadPolicies, userMetadata, scheduler);
return create(offloadPolicies, userMetadata, scheduler, offloaderStats);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* 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.bookkeeper.mledger;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.bookkeeper.common.annotation.InterfaceAudience;
import org.apache.bookkeeper.common.annotation.InterfaceStability;
import org.apache.bookkeeper.mledger.impl.LedgerOffloaderStatsImpl;


/**
* Management Bean for a {@link LedgerOffloader}.
*/
@InterfaceAudience.LimitedPrivate
@InterfaceStability.Stable
public interface LedgerOffloaderStats extends AutoCloseable {

void recordOffloadError(String topic);

void recordOffloadBytes(String topic, long size);

void recordReadLedgerLatency(String topic, long latency, TimeUnit unit);

void recordWriteToStorageError(String topic);

void recordReadOffloadError(String topic);

void recordReadOffloadBytes(String topic, long size);

void recordReadOffloadIndexLatency(String topic, long latency, TimeUnit unit);

void recordReadOffloadDataLatency(String topic, long latency, TimeUnit unit);

void recordDeleteOffloadOps(String topic, boolean succeed);


static LedgerOffloaderStats create(boolean exposeManagedLedgerStats, boolean exposeTopicLevelMetrics,
ScheduledExecutorService scheduler, int interval) {
if (!exposeManagedLedgerStats) {
return LedgerOffloaderStatsDisable.INSTANCE;
}

return LedgerOffloaderStatsImpl.getInstance(exposeTopicLevelMetrics, scheduler, interval);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* 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.bookkeeper.mledger;

import java.util.concurrent.TimeUnit;

class LedgerOffloaderStatsDisable implements LedgerOffloaderStats {

static final LedgerOffloaderStats INSTANCE = new LedgerOffloaderStatsDisable();

private LedgerOffloaderStatsDisable() {

}

@Override
public void recordOffloadError(String topic) {

}

@Override
public void recordOffloadBytes(String topic, long size) {

}

@Override
public void recordReadLedgerLatency(String topic, long latency, TimeUnit unit) {

}

@Override
public void recordWriteToStorageError(String topic) {

}

@Override
public void recordReadOffloadError(String topic) {

}

@Override
public void recordReadOffloadBytes(String topic, long size) {

}

@Override
public void recordReadOffloadIndexLatency(String topic, long latency, TimeUnit unit) {

}

@Override
public void recordReadOffloadDataLatency(String topic, long latency, TimeUnit unit) {

}

@Override
public void recordDeleteOffloadOps(String topic, boolean succeed) {

}

@Override
public void close() throws Exception {

}
}
Loading

0 comments on commit 732049f

Please sign in to comment.