-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add carbon metrics to get dashboard support #93
Merged
Merged
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
f2a266a
Add dependencies and Metrics class
sahandilshan e2b88a9
Add metrics to the Sink
sahandilshan 2e606c2
Add metrics to the source
sahandilshan b67b489
Add Metrics to stream functions
sahandilshan 677b13e
Add app_name label to the metrics
sahandilshan 560b472
Merge from upstream/master
sahandilshan 40ed6c1
Stable version
sahandilshan 6161630
Stable version
sahandilshan 1e52e60
Add carbon metrics and remove prometheus metrics
sahandilshan 36e4650
Update sink and file operations
sahandilshan 94f4a3e
Update Source to work with carbon metrics
sahandilshan 6b41288
Fix bugs and checkstyle issues
sahandilshan b61a213
Add carbon analytics metrics
sahandilshan ea9ff8a
Merge branch 'master' of https://github.com/siddhi-io/siddhi-io-file …
sahandilshan 705b872
Fix bugs in FileDeleteExtension
sahandilshan 1af6e17
Add deleted api docs
sahandilshan 192a9bb
Remove unwanted comments
sahandilshan d4680e3
Modify shortenFile path
sahandilshan 9fc6d0d
Prevent updating the file status continuously
sahandilshan afae1be
Bump Carbon-analytics version
sahandilshan f1b4bd3
Fix issue while calculating the read percentage
sahandilshan 5eb001a
Change the package of the metrics classes
sahandilshan b9047b8
Register metrics only when prometheus reporter is running
sahandilshan 85ee5fb
Add PROMETHEUS_REPORTER_NAME constant
sahandilshan 927d758
Merge with upstream/master
sahandilshan 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 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 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 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 |
---|---|---|
|
@@ -31,13 +31,15 @@ | |
import io.siddhi.core.query.processor.stream.function.StreamFunctionProcessor; | ||
import io.siddhi.core.util.config.ConfigReader; | ||
import io.siddhi.core.util.snapshot.state.StateFactory; | ||
import io.siddhi.extension.io.file.metrics.FileCopyMetrics; | ||
import io.siddhi.extension.util.Utils; | ||
import io.siddhi.query.api.definition.AbstractDefinition; | ||
import io.siddhi.query.api.definition.Attribute; | ||
import org.apache.commons.vfs2.FileObject; | ||
import org.apache.commons.vfs2.FileSystemException; | ||
import org.apache.commons.vfs2.Selectors; | ||
import org.apache.log4j.Logger; | ||
import org.wso2.carbon.si.metrics.core.internal.MetricsDataHolder; | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
|
@@ -126,6 +128,7 @@ public class FileCopyExtension extends StreamFunctionProcessor { | |
private static final Logger log = Logger.getLogger(FileCopyExtension.class); | ||
private Pattern pattern = null; | ||
private int inputExecutorLength; | ||
private FileCopyMetrics fileCopyMetrics; | ||
|
||
@Override | ||
protected StateFactory init(AbstractDefinition inputDefinition, ExpressionExecutor[] attributeExpressionExecutors, | ||
|
@@ -137,6 +140,19 @@ protected StateFactory init(AbstractDefinition inputDefinition, ExpressionExecut | |
pattern = Pattern.compile(((ConstantExpressionExecutor) | ||
attributeExpressionExecutors[2]).getValue().toString()); | ||
} | ||
if (MetricsDataHolder.getInstance().getMetricService() != null && | ||
MetricsDataHolder.getInstance().getMetricManagementService().isEnabled()) { | ||
try { | ||
if (MetricsDataHolder.getInstance().getMetricManagementService().isReporterRunning( | ||
"prometheus")) { | ||
String siddhiAppName = siddhiQueryContext.getSiddhiAppContext().getName(); | ||
fileCopyMetrics = new FileCopyMetrics(siddhiAppName); | ||
} | ||
} catch (IllegalArgumentException e) { | ||
log.debug("Prometheus reporter is not running. Hence file metrics will not be initialise in " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be rephrased as "will not be initialized" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was fixed in 85ee5fb |
||
+ inputDefinition.getId() + "."); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
|
@@ -222,6 +238,11 @@ public void stop() { | |
private void copyFileToDestination(FileObject sourceFileObject, String destinationDirUri, Pattern pattern, | ||
FileObject rootSourceFileObject) { | ||
FileObject destinationFileObject = null; | ||
if (fileCopyMetrics != null) { | ||
fileCopyMetrics.setSource(Utils.getShortFilePath(sourceFileObject.getName().getPath())); | ||
fileCopyMetrics.setDestination(Utils.getShortFilePath(destinationDirUri)); | ||
fileCopyMetrics.setTime(System.currentTimeMillis()); | ||
} | ||
try { | ||
String fileName = sourceFileObject.getName().getBaseName(); | ||
String destinationPath; | ||
|
@@ -239,7 +260,13 @@ private void copyFileToDestination(FileObject sourceFileObject, String destinati | |
destinationFileObject.copyFrom(sourceFileObject, Selectors.SELECT_ALL); | ||
destinationFileObject.close(); | ||
} | ||
if (fileCopyMetrics != null) { | ||
fileCopyMetrics.getCopyMetric(1); | ||
} | ||
} catch (FileSystemException e) { | ||
if (fileCopyMetrics != null) { | ||
fileCopyMetrics.getCopyMetric(0); | ||
} | ||
throw new SiddhiAppRuntimeException("Exception occurred when doing file operations when copying for " + | ||
"file: " + sourceFileObject.getName().getPath(), e); | ||
} finally { | ||
|
This file contains 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 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.
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.
Shall we make this a constant? Maybe it should be a constant in the carbon metrics package.
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.
This was fixed in 85ee5fb, There's no constant available in the carbon metrics, Hence introduce as a new constant.