// ForwarderLoader1 is a more strictly typed version of ForwarderLoader
func ForwarderLoader1(ctx context.Context, forwardTo *config.ForwardTo) (protocol.Forwarder, *Forwarder, error) {
	proxyVersion, ok := ctx.Value("version").(string)
	if !ok || proxyVersion == "" {
		proxyVersion = "UNKNOWN_VERSION"
	}
	if forwardTo.FormatVersion == nil {
		forwardTo.FormatVersion = workarounds.GolangDoesnotAllowPointerToUintLiteral(3)
	}
	if *forwardTo.FormatVersion == 1 {
		log.WithField("forwardTo", forwardTo).Warn("Old formats not supported in signalfxforwarder.  Using newer format.  Please update config to use format version 2 or 3")
	}
	structdefaults.FillDefaultFrom(forwardTo, defaultConfigV2)
	log.WithField("forwardTo", forwardTo).Info("Creating signalfx forwarder using final config")
	fwd := NewSignalfxJSONForwarder(*forwardTo.URL, *forwardTo.TimeoutDuration,
		*forwardTo.DefaultAuthToken, *forwardTo.DrainingThreads,
		*forwardTo.DefaultSource, *forwardTo.SourceDimensions, proxyVersion)
	fwd.eventURL = *forwardTo.EventURL
	counter := &dpsink.Counter{}
	dims := protocol.ForwarderDims(*forwardTo.Name, "sfx_protobuf_v2")
	buffer := dpbuffered.NewBufferedForwarder(ctx, *(&dpbuffered.Config{}).FromConfig(forwardTo), fwd)
	return &protocol.CompositeForwarder{
		Sink:   dpsink.FromChain(buffer, dpsink.NextWrap(counter)),
		Keeper: stats.ToKeeperMany(dims, counter, buffer),
		Closer: protocol.CompositeCloser(protocol.OkCloser(buffer.Close)),
	}, fwd, nil
}
예제 #2
0
// ListenerLoader loads a listener for the carbon/graphite protocol from config
func ListenerLoader(ctx context.Context, sink dpsink.Sink, listenFrom *config.ListenFrom) (*Listener, error) {
	structdefaults.FillDefaultFrom(listenFrom, defaultListenerConfig)
	conf := listenerConfig{
		serverAcceptDeadline: *listenFrom.ServerAcceptDeadline,
		connectionTimeout:    *listenFrom.TimeoutDuration,
		name:                 *listenFrom.Name,
	}
	//  *listenFrom.Name
	return NewListener(
		ctx, sink, conf, *listenFrom.ListenAddr,
		*listenFrom.MetricDeconstructor, *listenFrom.MetricDeconstructorOptions)
}
예제 #3
0
// ForwarderLoader loads a carbon forwarder that is buffered
func ForwarderLoader(ctx context.Context, forwardTo *config.ForwardTo) (protocol.Forwarder, error) {
	structdefaults.FillDefaultFrom(forwardTo, defaultForwarderConfig)
	if forwardTo.Host == nil {
		return nil, errRequiredHost
	}
	fwd, err := NewForwarder(*forwardTo.Host, *forwardTo.Port, *forwardTo.TimeoutDuration, forwardTo.DimensionsOrder, *forwardTo.DrainingThreads)
	if err != nil {
		return nil, err
	}
	counter := &dpsink.Counter{}
	dims := protocol.ForwarderDims(*forwardTo.Name, "carbon")
	buffer := dpbuffered.NewBufferedForwarder(ctx, *(&dpbuffered.Config{}).FromConfig(forwardTo), fwd)
	return &protocol.CompositeForwarder{
		Sink:   dpsink.FromChain(buffer, dpsink.NextWrap(counter)),
		Keeper: stats.ToKeeperMany(dims, counter, buffer),
		Closer: protocol.CompositeCloser(protocol.OkCloser(buffer.Close), fwd),
	}, nil
}
예제 #4
0
// ListenerLoader loads a listener for signalfx protocol from config
func ListenerLoader(ctx context.Context, sink dpsink.Sink, listenFrom *config.ListenFrom) (*ListenerServer, error) {
	structdefaults.FillDefaultFrom(listenFrom, defaultConfig)

	log.WithField("listenFrom", listenFrom).Info("Creating signalfx listener using final config")
	return StartServingHTTPOnPort(ctx, sink, *listenFrom.ListenAddr, *listenFrom.TimeoutDuration, *listenFrom.Name)
}
예제 #5
0
// ForwarderLoader loads a CSV forwarder forwarding points from proxy to a file
func ForwarderLoader(forwardTo *config.ForwardTo) (*FilenameForwarder, error) {
	structdefaults.FillDefaultFrom(forwardTo, csvDefaultConfig)
	log.WithField("forwardTo", forwardTo).Info("Creating CSV using final config")
	return NewForwarder(*forwardTo.Name, *forwardTo.Filename)
}