-
Notifications
You must be signed in to change notification settings - Fork 57
[monitoring] Impl metrics #631
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
Open
chernser
wants to merge
18
commits into
main
Choose a base branch
from
impl_metrics
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6fc7e1a
Fixed metrics registration name. Added tests. Replaced volatile varia…
chernser e3e6b72
implemented base statistics for topics. added dropwizard library to c…
chernser 8a8f2ed
fixed Processing tests with correct statistics initialization
chernser db3326b
Merge branch 'main' into impl_metrics
chernser ac017c0
fixed in test conflict of task id
chernser 1521e64
documented metrics. moved mean receive lag to task metrics
chernser 69d2b66
added countRows for cloud
chernser b9e11f1
fixed table name
chernser ead37d6
Fix clusterAllReplicas
chernser 9539a50
Fix clusterAllReplicas
chernser 8dbfabd
final fix for counter
chernser 3b8bd42
final fix for counter
chernser e8be6d2
Added inserted bytes
chernser 6faac11
Added logging
chernser 9d19bdf
removed dropwizard as too fat library. implemented simple moving avg
chernser cc30055
Merge branch 'main' into impl_metrics
chernser f3993bf
optimized calculating sum in SMA
chernser f99f1b5
optimized calculating sum in SMA
chernser 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
34 changes: 34 additions & 0 deletions
34
src/main/java/com/clickhouse/kafka/connect/util/jmx/SimpleMovingAverage.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,34 @@ | ||
| package com.clickhouse.kafka.connect.util.jmx; | ||
|
|
||
| import java.util.concurrent.atomic.AtomicInteger; | ||
| import java.util.concurrent.atomic.AtomicLong; | ||
|
|
||
| /** | ||
| * Not thread-safe Exponential Moving Average implementation | ||
| */ | ||
| public class SimpleMovingAverage { | ||
|
|
||
| public static final int DEFAULT_WINDOW_SIZE = 60; | ||
|
|
||
| private final long[] values; | ||
| private final AtomicInteger head; | ||
| private final AtomicLong sum; | ||
| private final int n; | ||
|
|
||
| public SimpleMovingAverage(int numOfValues) { | ||
| this.values = new long[numOfValues]; | ||
| this.n = this.values.length - 1; | ||
| this.head = new AtomicInteger(); | ||
| this.sum = new AtomicLong(); | ||
| } | ||
|
|
||
| public void add(long value) { | ||
| int insertIndex = head.getAndIncrement() % values.length; | ||
| sum.addAndGet(value - values[insertIndex]); | ||
| values[insertIndex] = value; | ||
| } | ||
|
|
||
| public double get() { | ||
| return (double) sum.get() / values.length; | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know where the timestamp comes from? Record metadata, or when created, just want to validate since we can have clock skew in some siuations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will find out.
As for time skew - this would be a problem. But it can be normalized I think if skew stays in the range.