Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Formatting Best Practices doc
Browse files Browse the repository at this point in the history
* Found some minor typos
* Found some grammar edits
* Consistently ending bullets with or without period
  • Loading branch information
mbbroberg committed Jan 20, 2016
1 parent 81a4198 commit 9c2cff8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/PLUGIN_BEST_PRACTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
- **Task level** - This config is useful when you need to pass configuration per metric or plugin in order to collect the metrics. Use `GetConfigPolicy()` to set configurable items for plugin. Values from Task config are available in `CollectMetrics()` method.

### Use `snap-plugin-utilities` library
The library and guide are available [here](https://github.com/intelsdi-x/snap-plugin-utilities). The library consists of following helper packages:
The library and guide is available [here](https://github.com/intelsdi-x/snap-plugin-utilities). The library consists of the following helper packages:
* **`config`** - The config package provides helpful methods to retrieve global config items.
* **`logger`** - The logger package wraps logrus package (https://github.com/Sirupsen/logrus). It sets logging from plugin to separate file. It adds caller function name to each message. It's best to use log level defined during `snapd` start.
* **`logger`** - The logger package wraps the logrus package. (https://github.com/Sirupsen/logrus). It sets logging from a plugin to separate files and adds a caller function name to each message. It's best to use log level defined during `snapd` start.
* **`ns`** - The ns package provides functions to extract namespace from maps, JSON and struct compositions. It is useful for situations when full knowledge of available metrics is not known at time when `GetMetricTypes()` is called.
* **`pipline`** - Creates array of Pipes connected by channels. Each Pipe can do single processing on data transmitted by channels
* **`source`** - The source package provides handy way of dealing with external command output. It can be used for continuous command execution (PCM like), or for single command calls.
* **`stack`** - The stack package provides simple implementation of stack.
* **`pipeline`** - Creates array of Pipes connected by channels. Each Pipe can perform a single process on data transmitted by channels.
* **`source`** - The source package provides handy ways of dealing with external command output. It can be used for continuous command execution (PCM like), or for single command calls.
* **`stack`** - The stack package provides simple implementation of a stack.

### Namespace definition
* The `GetMetricTypes()` method returns namespaces for your metrics. The good idea is to start with your organization (for example: "intel"), then enumerate information starting from most general to most detailed. Examples: `/intel/server/mem/free` or `/intel/linux/iostat/avg-cpu/%idle`.
* The `GetMetricTypes()` method returns namespaces for your metrics. For new metrics, it is a good idea to start with your organization (for example: "intel"), then enumerate information starting from most general to most detailed. Examples: `/intel/server/mem/free` or `/intel/linux/iostat/avg-cpu/%idle`.
* Do not use any special character in namespaces other than: "%", "-" and "_".
* When enumerating sources it's better to have them separated. For example:use `cpu/0` rather than `cpu0`.
* When enumerating metric sources, it is always better to have them separated. For example: use `cpu/0` rather than `cpu0`.

### Testability
It's highly recommended to deliver unit and integration tests with your code - use best practices for your language of choice to create testable code (for example in golang consider using dependency injection and interfaces).
It is highly recommended to deliver unit and integration tests with your code - use best practices for your language of choice to create testable code (for example in golang consider using dependency injection and interfaces).

0 comments on commit 9c2cff8

Please sign in to comment.