Skip to content

Commit

Permalink
Remove unused timeout configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Fischer committed Jul 24, 2020
1 parent 7de4fcb commit 88b71d1
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 26 deletions.
57 changes: 50 additions & 7 deletions receiver/statsdreceiver/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,65 @@
# StatsD Receiver

StatsD/DogStatsD receiver.
StatsD receiver for ingesting StatsD messages into the OpenTelemetry Collector.

## Sample Configuration
## Configuration

```yaml
receivers:
statsd:
# endpoint: "localhost:8125"
endpoint: "localhost:8125" # default
```
# timeout: "50s"
### endpoint
The `"<host>:<port>"` to listen on. By default listen on `"localhost:8125"`.
## Aggregation
Currently the `statsdreceiver` is not providing any aggregation. There are ideas such as the [Metrics Transform Processor Proposal](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/332) and a [Views API](https://github.com/open-telemetry/opentelemetry-specification/issues/466) that intend to enable control over Metric aggregation in a processor.

An alternative will be to implement some simple aggregation in this receiver.

## Metrics

General format is:

`<name>:<value>|<type>|@<sample-rate>|#<tag1-key>:<tag1-value>,<tag2-k/v>`

### Counter

`<name>:<value>|c`

### Gauge

`<name>:<value>|g`

### Timer/Histogram

`<name>:<value>|<ms/h>|@<sample-rate>`

## Testing

### Full sample config

```yaml
receivers:
statsd:
endpoint: "localhost:8125" # default
exporters:
logging:
file:
path: ./test.json
service:
pipelines:
metrics:
receivers: [statsd]
exporters: [logging]
```
exporters: [file]
```

### Local

A simple way to send a metric to `localhost:8125`:

`echo "test.metric:1|c" | nc -w 1 -u localhost 8125`
4 changes: 0 additions & 4 deletions receiver/statsdreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@
package statsdreceiver

import (
"time"

"go.opentelemetry.io/collector/config/configmodels"
)

// Config defines configuration for StatsD receiver.
type Config struct {
configmodels.ReceiverSettings `mapstructure:",squash"`

Timeout time.Duration `mapstructure:"timeout"`
}
2 changes: 0 additions & 2 deletions receiver/statsdreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package statsdreceiver
import (
"path"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -50,6 +49,5 @@ func TestLoadConfig(t *testing.T) {
NameVal: "statsd/receiver_settings",
Endpoint: "localhost:12345",
},
Timeout: 50 * time.Second,
}, r1)
}
1 change: 0 additions & 1 deletion receiver/statsdreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (f *Factory) CreateDefaultConfig() configmodels.Receiver {
NameVal: typeStr,
Endpoint: defaultBindEndpoint,
},
Timeout: defaultTimeout,
}
}

Expand Down
1 change: 1 addition & 0 deletions receiver/statsdreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.14

require (
github.com/census-instrumentation/opencensus-proto v0.2.1
github.com/golang/protobuf v1.3.5
github.com/stretchr/testify v1.5.1
go.opentelemetry.io/collector v0.3.1-0.20200601172059-a776048b653c
go.uber.org/zap v1.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ package protocol
import (
"errors"
"strings"
"time"

// TODO: don't use the opencensus-proto package???
metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
"github.com/golang/protobuf/ptypes/timestamp"
)

// DogStatsDParser supports the Parse method for parsing StatsD messages with Tags.
type DogStatsDParser struct{}
// StatsDParser supports the Parse method for parsing StatsD messages with Tags.
type StatsDParser struct{}

// Parse returns an OTLP metric representation of the input StatsD string.
func (p *DogStatsDParser) Parse(line string) (*metricspb.Metric, error) {
func (p *StatsDParser) Parse(line string) (*metricspb.Metric, error) {
parts := strings.Split(line, ":")
if len(parts) < 2 {
return nil, errors.New("not enough statsd message parts")
Expand All @@ -36,5 +38,19 @@ func (p *DogStatsDParser) Parse(line string) (*metricspb.Metric, error) {
MetricDescriptor: &metricspb.MetricDescriptor{
Name: parts[0],
},
Timeseries: []*metricspb.TimeSeries{
{
Points: []*metricspb.Point{
{
Timestamp: &timestamp.Timestamp{
Seconds: time.Now().UnixNano(),
},
Value: &metricspb.Point_Int64Value{
Int64Value: 7,
},
},
},
},
},
}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/stretchr/testify/assert"
)

func Test_DogStatsDParser_Parse(t *testing.T) {
func Test_StatsDParser_Parse(t *testing.T) {
// TODO: fill in StatsD message parsing test cases
tests := []struct {
name string
Expand All @@ -38,7 +38,7 @@ func Test_DogStatsDParser_Parse(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := &DogStatsDParser{}
p := &StatsDParser{}

got, err := p.Parse(tt.input)

Expand Down
2 changes: 1 addition & 1 deletion receiver/statsdreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func New(
r := &statsdReceiver{
logger: logger,
config: &config,
parser: &protocol.DogStatsDParser{},
parser: &protocol.StatsDParser{},
nextConsumer: nextConsumer,
server: server,
}
Expand Down
5 changes: 1 addition & 4 deletions receiver/statsdreceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ receivers:
statsd/receiver_settings:
endpoint: "localhost:12345"

# Used as read and write timeout for the HTTP server started by the receiver.
timeout: "50s"

processors:
exampleprocessor:

Expand All @@ -17,4 +14,4 @@ service:
metrics:
receivers: [statsd]
processors: [exampleprocessor]
exporters: [exampleexporter]
exporters: [exampleexporter]
3 changes: 2 additions & 1 deletion receiver/statsdreceiver/transport/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package transport
import (
"errors"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol"
"go.opentelemetry.io/collector/consumer"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion receiver/statsdreceiver/transport/udp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"strings"
"sync"

metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/consumer/consumerdata"

metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver/protocol"
)

Expand Down

0 comments on commit 88b71d1

Please sign in to comment.