Skip to content

Commit a12ed70

Browse files
danielnelsoncalerogers
authored andcommitted
Add write timeout to Riemann output (influxdata#2576)
1 parent 90c53eb commit a12ed70

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ be deprecated eventually.
8484
- [#2513](https://github.com/influxdata/telegraf/issues/2513): create /etc/telegraf/telegraf.d directory in tarball.
8585
- [#2541](https://github.com/influxdata/telegraf/issues/2541): Return error on unsupported serializer data format.
8686
- [#1827](https://github.com/influxdata/telegraf/issues/1827): Fix Windows Performance Counters multi instance identifier
87+
- [#2576](https://github.com/influxdata/telegraf/pull/2576): Add write timeout to Riemann output
8788

8889

8990
## v1.2.1 [2017-02-01]

plugins/outputs/riemann/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ This plugin writes to [Riemann](http://riemann.io/) via TCP or UDP.
3434

3535
## Description for Riemann event
3636
# description_text = "metrics collected from telegraf"
37+
38+
## Riemann client write timeout, defaults to "5s" if not set.
39+
# timeout = "5s"
3740
```
3841

3942
### Required parameters:

plugins/outputs/riemann/riemann.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import (
77
"os"
88
"sort"
99
"strings"
10+
"time"
1011

1112
"github.com/amir/raidman"
1213
"github.com/influxdata/telegraf"
14+
"github.com/influxdata/telegraf/internal"
1315
"github.com/influxdata/telegraf/plugins/outputs"
1416
)
1517

@@ -22,6 +24,7 @@ type Riemann struct {
2224
TagKeys []string
2325
Tags []string
2426
DescriptionText string
27+
Timeout internal.Duration
2528

2629
client *raidman.Client
2730
}
@@ -54,6 +57,9 @@ var sampleConfig = `
5457
5558
## Description for Riemann event
5659
# description_text = "metrics collected from telegraf"
60+
61+
## Riemann client write timeout, defaults to "5s" if not set.
62+
# timeout = "5s"
5763
`
5864

5965
func (r *Riemann) Connect() error {
@@ -62,7 +68,7 @@ func (r *Riemann) Connect() error {
6268
return err
6369
}
6470

65-
client, err := raidman.Dial(parsed_url.Scheme, parsed_url.Host)
71+
client, err := raidman.DialWithTimeout(parsed_url.Scheme, parsed_url.Host, r.Timeout.Duration)
6672
if err != nil {
6773
r.client = nil
6874
return err
@@ -212,6 +218,8 @@ func (r *Riemann) tags(tags map[string]string) []string {
212218

213219
func init() {
214220
outputs.Add("riemann", func() telegraf.Output {
215-
return &Riemann{}
221+
return &Riemann{
222+
Timeout: internal.Duration{Duration: time.Second * 5},
223+
}
216224
})
217225
}

0 commit comments

Comments
 (0)