func (t Telemetry) Init() (*metrics.Metrics, error) {
	var (
		m   *metrics.Metrics
		err error
	)
	if t.Enabled {
		log.Info("enabling telemetry")
		serviceName := defaultServiceName
		if t.ServiceName != "" {
			serviceName = t.ServiceName
		}
		metricsConf := metrics.DefaultConfig(serviceName)
		var sinks metrics.FanoutSink
		for _, sc := range t.Sinks.GetSinks() {
			sink, err := sc.Init()
			if err == nil {
				sinks = append(sinks, sink)
			} else if err != ErrNilConfig {
				return nil, err
			}
		}
		m, err = metrics.NewGlobal(metricsConf, sinks)
		if err != nil {
			return nil, err
		}
	}

	return m, nil
}
// Configures metrics and adds FanoutSink with all configured sinks
Configures metrics and adds FanoutSink with all configured sinks
// Configures metrics and adds FanoutSink with all configured sinks
func (t Telemetry) Init() (*metrics.Metrics, error) {
	var (
		m   *metrics.Metrics
		err error
	)
	if t.Enabled {
		log.Info("enabling telemetry")
		serviceName := defaultServiceName
		if t.ServiceName != "" {
			serviceName = t.ServiceName
		}
		metricsConf := metrics.DefaultConfig(serviceName)
		var sinks metrics.FanoutSink
		for _, sc := range t.Sinks.GetSinks() {
			sink, err := sc.Init()
			if err == nil {
				sinks = append(sinks, sink)
			} else if err != ErrNilConfig {
				return nil, err
			}
		}
		m, err = metrics.NewGlobal(metricsConf, sinks)
		if err != nil {
			return nil, err
		}
	}
	return m, nil
}
func ( t Telemetry ) Init ( ) ( * metrics . Metrics , error ) { var ( m * metrics . Metrics err error ) if t . Enabled { log . Info ( " " ) serviceName := defaultServiceName if t . ServiceName != " " { serviceName = t . ServiceName } metricsConf := metrics . DefaultConfig ( serviceName ) var sinks metrics . FanoutSink for _ , sc := range t . Sinks . GetSinks ( ) { sink , err := sc . Init ( ) if err == nil { sinks = append ( sinks , sink ) } else if err != ErrNilConfig { return nil , err } } m , err = metrics . NewGlobal ( metricsConf , sinks ) if err != nil { return nil , err } } return m , nil }
Configures metrics and adds FanoutSink with all configured sinks
Configures metrics and adds FanoutSink with all configured sinks