Update contributing documentation

This commit is contained in:
Daniel Nelson 2017-11-07 13:54:36 -08:00
parent bb14589469
commit 5141f8a2a0
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
4 changed files with 27 additions and 28 deletions

View File

@ -12,7 +12,7 @@ but any information you can provide on how the data will look is appreciated.
See the [OpenTSDB output](https://github.com/influxdata/telegraf/tree/master/plugins/outputs/opentsdb) See the [OpenTSDB output](https://github.com/influxdata/telegraf/tree/master/plugins/outputs/opentsdb)
for a good example. for a good example.
1. **Optional:** Help users of your plugin by including example queries for populating dashboards. Include these sample queries in the `README.md` for the plugin. 1. **Optional:** Help users of your plugin by including example queries for populating dashboards. Include these sample queries in the `README.md` for the plugin.
1. **Optional:** Write a [tickscript](https://docs.influxdata.com/kapacitor/v1.0/tick/syntax/) for your plugin and add it to [Kapacitor](https://github.com/influxdata/kapacitor/tree/master/examples/telegraf). Or mention @jackzampolin in a PR comment with some common queries that you would want to alert on and he will write one for you. 1. **Optional:** Write a [tickscript](https://docs.influxdata.com/kapacitor/v1.0/tick/syntax/) for your plugin and add it to [Kapacitor](https://github.com/influxdata/kapacitor/tree/master/examples/telegraf).
## GoDoc ## GoDoc
@ -52,7 +52,7 @@ See below for a quick example.
* Input Plugins must be added to the * Input Plugins must be added to the
`github.com/influxdata/telegraf/plugins/inputs/all/all.go` file. `github.com/influxdata/telegraf/plugins/inputs/all/all.go` file.
* The `SampleConfig` function should return valid toml that describes how the * The `SampleConfig` function should return valid toml that describes how the
plugin can be configured. This is include in `telegraf -sample-config`. plugin can be configured. This is include in `telegraf config`.
* The `Description` function should say in one line what this plugin does. * The `Description` function should say in one line what this plugin does.
Let's say you've written a plugin that emits metrics about processes on the Let's say you've written a plugin that emits metrics about processes on the
@ -183,7 +183,7 @@ See below for a quick example.
* To be available within Telegraf itself, plugins must add themselves to the * To be available within Telegraf itself, plugins must add themselves to the
`github.com/influxdata/telegraf/plugins/outputs/all/all.go` file. `github.com/influxdata/telegraf/plugins/outputs/all/all.go` file.
* The `SampleConfig` function should return valid toml that describes how the * The `SampleConfig` function should return valid toml that describes how the
output can be configured. This is include in `telegraf -sample-config`. output can be configured. This is include in `telegraf config`.
* The `Description` function should say in one line what this output does. * The `Description` function should say in one line what this output does.
### Output Example ### Output Example
@ -287,7 +287,7 @@ See below for a quick example.
* To be available within Telegraf itself, plugins must add themselves to the * To be available within Telegraf itself, plugins must add themselves to the
`github.com/influxdata/telegraf/plugins/processors/all/all.go` file. `github.com/influxdata/telegraf/plugins/processors/all/all.go` file.
* The `SampleConfig` function should return valid toml that describes how the * The `SampleConfig` function should return valid toml that describes how the
processor can be configured. This is include in `telegraf -sample-config`. processor can be configured. This is include in the output of `telegraf config`.
* The `Description` function should say in one line what this processor does. * The `Description` function should say in one line what this processor does.
### Processor Example ### Processor Example
@ -344,7 +344,7 @@ See below for a quick example.
* To be available within Telegraf itself, plugins must add themselves to the * To be available within Telegraf itself, plugins must add themselves to the
`github.com/influxdata/telegraf/plugins/aggregators/all/all.go` file. `github.com/influxdata/telegraf/plugins/aggregators/all/all.go` file.
* The `SampleConfig` function should return valid toml that describes how the * The `SampleConfig` function should return valid toml that describes how the
aggregator can be configured. This is include in `telegraf -sample-config`. aggregator can be configured. This is include in `telegraf config`.
* The `Description` function should say in one line what this aggregator does. * The `Description` function should say in one line what this aggregator does.
* The Aggregator plugin will need to keep caches of metrics that have passed * The Aggregator plugin will need to keep caches of metrics that have passed
through it. This should be done using the builtin `HashID()` function of each through it. This should be done using the builtin `HashID()` function of each
@ -457,29 +457,28 @@ func init() {
## Unit Tests ## Unit Tests
Before opening a pull request you should run the linter checks and
the short tests.
### Execute linter
execute `make lint`
### Execute short tests ### Execute short tests
execute `make test-short` execute `make test`
### Execute long tests ### Execute integration tests
As Telegraf collects metrics from several third-party services it becomes a Running the integration tests requires several docker containers to be
difficult task to mock each service as some of them have complicated protocols running. You can start the containers with:
which would take some time to replicate. ```
make docker-run
```
To overcome this situation we've decided to use docker containers to provide a And run the full test suite with:
fast and reproducible environment to test those services which require it. ```
For other situations make test-all
(i.e: https://github.com/influxdata/telegraf/blob/master/plugins/inputs/redis/redis_test.go) ```
a simple mock will suffice.
To execute Telegraf tests follow these simple steps: Use `make docker-kill` to stop the containers.
- Install docker following [these](https://docs.docker.com/installation/)
instructions
- execute `make test`
### Unit test troubleshooting
Try cleaning up your test environment by executing `make docker-kill` and
re-running

View File

@ -15,7 +15,6 @@ ifdef VERSION
LDFLAGS += -X main.version=$(VERSION) LDFLAGS += -X main.version=$(VERSION)
endif endif
all: all:
$(MAKE) deps $(MAKE) deps
$(MAKE) telegraf $(MAKE) telegraf
@ -50,6 +49,7 @@ test-all: lint
package: package:
./scripts/build.py --package --platform=all --arch=all ./scripts/build.py --package --platform=all --arch=all
clean: clean:
-rm -f telegraf -rm -f telegraf
-rm -f telegraf.exe -rm -f telegraf.exe

View File

@ -3,7 +3,7 @@
This is a Telegraf service plugin that start an http server and register multiple webhook listeners. This is a Telegraf service plugin that start an http server and register multiple webhook listeners.
```sh ```sh
$ telegraf -sample-config -input-filter webhooks -output-filter influxdb > config.conf.new $ telegraf config -input-filter webhooks -output-filter influxdb > config.conf.new
``` ```
Change the config file to point to the InfluxDB server you are using and adjust the settings to match your environment. Once that is complete: Change the config file to point to the InfluxDB server you are using and adjust the settings to match your environment. Once that is complete:

View File

@ -63,7 +63,7 @@ exit_if_fail go test -race ./...
# Simple Integration Tests # Simple Integration Tests
# check that one test cpu & mem output work # check that one test cpu & mem output work
tmpdir=$(mktemp -d) tmpdir=$(mktemp -d)
./telegraf -sample-config > $tmpdir/config.toml ./telegraf config > $tmpdir/config.toml
exit_if_fail ./telegraf -config $tmpdir/config.toml \ exit_if_fail ./telegraf -config $tmpdir/config.toml \
-test -input-filter cpu:mem -test -input-filter cpu:mem