{"id":18965867,"url":"https://github.com/wso2/carbon-metrics","last_synced_at":"2025-05-15T17:06:11.853Z","repository":{"id":25446338,"uuid":"28876285","full_name":"wso2/carbon-metrics","owner":"wso2","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-12T02:28:39.000Z","size":2450,"stargazers_count":41,"open_issues_count":3,"forks_count":72,"subscribers_count":166,"default_branch":"master","last_synced_at":"2025-04-11T23:57:47.957Z","etag":null,"topics":["common"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wso2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-01-06T18:11:33.000Z","updated_at":"2025-03-12T02:28:38.000Z","dependencies_parsed_at":"2024-01-08T05:47:02.134Z","dependency_job_id":"d8df63e2-b6b3-4638-952d-c40a27944eb4","html_url":"https://github.com/wso2/carbon-metrics","commit_stats":null,"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wso2%2Fcarbon-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wso2%2Fcarbon-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wso2%2Fcarbon-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wso2%2Fcarbon-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wso2","download_url":"https://codeload.github.com/wso2/carbon-metrics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254384988,"owners_count":22062422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["common"],"created_at":"2024-11-08T14:33:37.400Z","updated_at":"2025-05-15T17:06:06.845Z","avatar_url":"https://github.com/wso2.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"WSO2 Carbon Metrics\n===================\n\n---\n|  Branch | Build Status |\n| :------ |:------------ | \n| master  | [![Build Status](https://wso2.org/jenkins/buildStatus/icon?job=platform-builds/carbon-metrics)](https://wso2.org/jenkins/job/platform-builds/job/carbon-metrics/) |\n---\n\n\"WSO2 Carbon Metrics\" provides an API for WSO2 Carbon Components to use the [Metrics library](http://metrics.dropwizard.io).\n\n## Configuring Metrics\n\nThe metrics is configured via a YAML file. The Metrics is enabled by default and it can be disabled from the configuration. The Metrics is also configured to register a standard Java MBean for management operations.\n\nAll reporters are also configured using the same configuration file. By default, the JMX Reporter will be enabled.\n\n## Metric Levels\n\nThe WSO2 Carbon Metrics APIs associate a Level with each Metric. These levels are similar to the Levels used in Logging Libraries. \n\nMetrics Levels are organized from most specific to least:\n\n  - OFF (most specific, no metrics)\n  - INFO\n  - DEBUG\n  - TRACE (least specific, a lot of data)\n  - ALL (least specific, all data)\n\nThe levels are configured in YAML file.\n\nSimilar to [Apache Log4j](http://logging.apache.org/log4j), the WSO2 Carbon Metrics implementation uses a Metric Hierarchy. The hierarchy is maintained via the Metric names.\n\nThe levels in Metrics configuration can be configured to any hierarchy. For example, if we use `jvm.memory.heap=INFO`, all metrics under `jvm.memory.heap` memory will have `INFO` as the configured level.\n\nIf there is no configured level for specific metric name hierarachy, the level configured in \"`rootLevel`\" will be used.\n\n## Components\n\nThis repository has multiple components.\n\n  - org.wso2.carbon.metrics.core - Provides the core Metrics and Management APIs. The main Metric Manager implementation uses the [Metrics library](http://metrics.dropwizard.io).\n  - org.wso2.carbon.metrics.jdbc.reporter - A JDBC Reporter for Metrics Library.\n  - org.wso2.carbon.metrics.das.reporter - A reporter to send metrics events to WSO2 Data Analytics Server (WSO2 DAS).\n  - org.wso2.carbon.metrics.das.capp - The artifacts used to create the main Carbon Application (C-App). This C-App is required by the DAS Reporter. The artifacts in this C-App are the event streams, event receivers and the event stores for all Metric types.\n  - org.wso2.carbon.metrics.jdbc.core - Extending Metrics Core to support the JDBC Reporter.\n  - org.wso2.carbon.metrics.das.core - Extending Metrics Core to support the DAS Reporter.\n\n## Maven Dependency\n\nIn order to use WSO2 Carbon Metrics in your components, you need to add following dependency to your `pom.xml`\n\n```\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.wso2.carbon.metrics\u003c/groupId\u003e\n    \u003cartifactId\u003eorg.wso2.carbon.metrics.core\u003c/artifactId\u003e\n    \u003cversion\u003e${carbon.metrics.version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Usage\n\nThe APIs to create Metrics are defined in `org.wso2.carbon.metrics.core.MetricService`. The APIs to manage Metrics, such as setting metric levels and adding reporters are defined in `org.wso2.carbon.metrics.core.MetricManagementService`.\n\nIn Carbon (OSGi) environment, these APIs are available as OSGi services.\n\nSee the sample [ServiceComponent](samples/org.wso2.carbon.metrics.sample.service/src/main/java/org/wso2/carbon/metrics/sample/service/internal/ServiceComponent.java).\n\nWhen using Metrics in standalone application, the Metrics can be initialized as follows.\n\n```\nMetrics metrics = new Metrics(\u003cConfigProvider\u003e);\nmetrics.activate();\n\nMetricService metricService = metrics.getMetricService();\nMetricManagementService metricManagementService = metrics.getMetricManagementService();\n\n```\n\nAfter getting a reference to the MetricService, the Metrics can be created as follows.\n\n```\n// Create a Gauge\nmetricService.gauge(MetricService.name(\"test\", \"gauge\"), Level.INFO, () -\u003e number);\n\n// Create a Counter\nCounter counter = metricService.counter(MetricService.name(\"test\", \"count\"), Level.INFO);\n// Increment\ncounter.inc();\n// Decrement\ncounter.dec();\n\n// Create a Meter\nMeter meter = metricService.meter(MetricService.name(\"test\", \"meter\"), Level.INFO);\n// Mark an event\nmeter.mark();\n\n// Create a Histogram\nHistogram histogram = metricService.histogram(MetricService.name(\"test\", \"histogram\"), Level.INFO);\n// Update the histogram\nhistogram.update(value);\n\n// Create a Timer\nTimer timer = metricService.timer(MetricService.name(\"test\", \"timer\"), Level.INFO);\n// Start the timer\nTimer.Context context = timer.start();\n// Stop the timer\ncontext.stop();\n```\n\nSee the sample [RandomNumberServiceImpl](samples/org.wso2.carbon.metrics.sample.service/src/main/java/org/wso2/carbon/metrics/sample/service/internal/RandomNumberServiceImpl.java).\n\n\n## License\n\nCopyright 2014 WSO2 Inc.\n\nLicensed under the Apache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwso2%2Fcarbon-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwso2%2Fcarbon-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwso2%2Fcarbon-metrics/lists"}