-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nick Fischer
committed
Jun 15, 2020
1 parent
ab093e2
commit 01393f6
Showing
11 changed files
with
1,524 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../Makefile.Common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# StatsD Receiver | ||
|
||
StatsD/DogStatsD receiver. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
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"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package statsdreceiver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package statsdreceiver | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config/configerror" | ||
"go.opentelemetry.io/collector/config/configmodels" | ||
"go.opentelemetry.io/collector/consumer" | ||
"go.uber.org/zap" | ||
) | ||
|
||
const ( | ||
// The value of "type" key in configuration. | ||
typeStr = "statsd" | ||
defaultBindEndpoint = "localhost:8125" | ||
defaultTimeout = time.Duration(time.Second * 30) | ||
) | ||
|
||
// Factory is the factory for StatsD receiver. | ||
type Factory struct { | ||
} | ||
|
||
// Type gets the type of the Receiver config created by this factory. | ||
func (f *Factory) Type() configmodels.Type { | ||
return configmodels.Type(typeStr) | ||
} | ||
|
||
// CustomUnmarshaler returns nil because we don't need custom unmarshaling for this config. | ||
func (f *Factory) CustomUnmarshaler() component.CustomUnmarshaler { | ||
return nil | ||
} | ||
|
||
// CreateDefaultConfig creates the default configuration for StatsD receiver. | ||
func (f *Factory) CreateDefaultConfig() configmodels.Receiver { | ||
return &Config{ | ||
ReceiverSettings: configmodels.ReceiverSettings{ | ||
TypeVal: configmodels.Type(typeStr), | ||
NameVal: typeStr, | ||
Endpoint: defaultBindEndpoint, | ||
}, | ||
Timeout: defaultTimeout, | ||
} | ||
} | ||
|
||
// CreateTraceReceiver creates a trace receiver based on provided config. | ||
func (f *Factory) CreateTraceReceiver( | ||
ctx context.Context, | ||
logger *zap.Logger, | ||
cfg configmodels.Receiver, | ||
nextConsumer consumer.TraceConsumerOld, | ||
) (component.TraceReceiver, error) { | ||
return nil, configerror.ErrDataTypeIsNotSupported | ||
} | ||
|
||
// CreateMetricsReceiver creates a metrics receiver based on provided config. | ||
func (f *Factory) CreateMetricsReceiver( | ||
logger *zap.Logger, | ||
cfg configmodels.Receiver, | ||
nextConsumer consumer.MetricsConsumerOld, | ||
) (component.MetricsReceiver, error) { | ||
c := cfg.(*Config) | ||
return New(logger, c.Endpoint, c.Timeout, nextConsumer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/statsdreceiver | ||
|
||
go 1.14 | ||
|
||
require ( | ||
go.opentelemetry.io/collector v0.3.1-0.20200601172059-a776048b653c | ||
go.uber.org/zap v1.10.0 | ||
) |
Oops, something went wrong.