-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[draft] Start publishing segment load metric from a separate monitor #18314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bfe9529
implement the segmentDiscoveryStatsProvider and counter and hook it up
uds5501 f2a174a
Address review comments
uds5501 a1123bf
Fix jacoco coverage
uds5501 02f6d39
Address review comments
uds5501 eb7d8bb
Attempt fixing embedded tests
uds5501 1fe9e52
Fix embedded tests for minio
uds5501 98a358a
Add serverview metrics and remove the available segments one
uds5501 1bbd7d4
Docs oopsie
uds5501 ab58000
Fix the count based metric
uds5501 e3a48f3
Fix metrics
uds5501 9d7d9e9
Use individual blocking queues to emit and provide events
uds5501 dfbfb10
Fix relatime query tests
uds5501 138c423
Address review comments
uds5501 de4f982
Run tests only when historical sends the segment
uds5501 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
server/src/main/java/org/apache/druid/server/metrics/BrokerSegmentStatsMonitor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * 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.druid.server.metrics; | ||
|
|
||
| import com.google.inject.Inject; | ||
| import org.apache.druid.discovery.NodeRole; | ||
| import org.apache.druid.guice.annotations.LoadScope; | ||
| import org.apache.druid.java.util.emitter.service.ServiceEmitter; | ||
| import org.apache.druid.java.util.emitter.service.ServiceMetricEvent; | ||
| import org.apache.druid.java.util.metrics.AbstractMonitor; | ||
| import org.apache.druid.server.coordinator.stats.RowKey; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Monitor that tracks the number of segments of a datasource currently queryable by this Broker. | ||
| */ | ||
| @LoadScope(roles = {NodeRole.BROKER_JSON_NAME}) | ||
| public class BrokerSegmentStatsMonitor extends AbstractMonitor | ||
| { | ||
| private final BrokerSegmentStatsProvider statsProvider; | ||
|
|
||
| @Inject | ||
| public BrokerSegmentStatsMonitor(BrokerSegmentStatsProvider statsProvider) | ||
| { | ||
| this.statsProvider = statsProvider; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean doMonitor(ServiceEmitter emitter) | ||
| { | ||
| emit(emitter, "serverview/segment/added", statsProvider.getSegmentAddedCount()); | ||
| emit(emitter, "serverview/segment/removed", statsProvider.getSegmentRemovedCount()); | ||
| return true; | ||
| } | ||
|
|
||
| private void emit(ServiceEmitter emitter, String key, Map<RowKey, Long> counts) | ||
| { | ||
| final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder(); | ||
| if (counts != null) { | ||
| counts.forEach((k, v) -> { | ||
| k.getValues().forEach((dim, value) -> builder.setDimension(dim.reportedName(), value)); | ||
| emitter.emit(builder.setMetric(key, v)); | ||
| }); | ||
| } | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
server/src/main/java/org/apache/druid/server/metrics/BrokerSegmentStatsProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * 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.druid.server.metrics; | ||
|
|
||
| import org.apache.druid.server.coordinator.stats.RowKey; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public interface BrokerSegmentStatsProvider | ||
| { | ||
| /** | ||
| * Return the number of segments recently added by a Broker for a datasource, service and description. | ||
| */ | ||
| Map<RowKey, Long> getSegmentAddedCount(); | ||
|
|
||
| /** | ||
| * Return the number of segments recently dropped by a Broker for a datasource, service and description. | ||
| */ | ||
| Map<RowKey, Long> getSegmentRemovedCount(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.