func (m *metrics) handleUnknownService(serviceName string, ctx context.Context) (system.Result, error) {
	m.loggingClient.Info(fmt.Sprintf("service %s not known to SMA as being in the ready-made list of clients", serviceName))

	if m.registryClient == nil {
		return nil, fmt.Errorf("registryClient not initialized; required to handle unknown service %s", serviceName)
	}

	// Service unknown to SMA, so ask the Registry whether `serviceName` is available.
	if err := m.registryClient.IsServiceAvailable(serviceName); err != nil {
		return nil, err
	}

	m.loggingClient.Info(fmt.Sprintf("Registry responded with %s serviceName available", serviceName))

	// Since serviceName is unknown to SMA, ask the Registry for a ServiceEndpoint associated with `serviceName`
	endpoint, err := m.registryClient.GetServiceEndpoint(serviceName)
	if err != nil {
		return nil, fmt.Errorf("on attempting to get ServiceEndpoint for serviceName %s, got error: %v", serviceName, err.Error())
	}

	// add the specified key to the map where the value will be the respective GeneralClient
	m.configClients[endpoint.ServiceId] = config.ClientInfo{
		Protocol: m.serviceProtocol,
		Host:     endpoint.Host,
		Port:     endpoint.Port,
	}

	params := types.EndpointParams{
		ServiceKey:  endpoint.ServiceId,
		Path:        "/",
		UseRegistry: true,
		Url:         m.configClients[endpoint.ServiceId].Url() + clients.ApiMetricsRoute,
		Interval:    internal.ClientMonitorDefault,
	}

	// Add the serviceName key to the map where the value is the respective GeneralClient
	m.genClients[endpoint.ServiceId] = general.NewGeneralClient(params, startup.Endpoint{RegistryClient: &m.registryClient})

	return m.fetchMetrics(endpoint.ServiceId, ctx)
}
// handleUnknownService fetches metrics from an unknown service (i.e. a service that does not have an entry in
// genClients).  It leverages the registry -- assuming it is enabled -- to query for the unknown service's
// endpoint settings.  If found, the service is added to genClients and the service's metrics are fetched and
// returned.
handleUnknownService fetches metrics from an unknown service .  It leverages the registry -- assuming it is enabled -- to query for the unknown service's
endpoint settings.  If found, the service is added to genClients and the service's metrics are fetched and
returned.
// handleUnknownService fetches metrics from an unknown service ( i . e . a service that does not have an entry in // genClients ) . It leverages the registry -- assuming it is enabled -- to query for the unknown service ' s // endpoint settings . If found the service is added to genClients and the service ' s metrics are fetched and // returned .
func (m *metrics) handleUnknownService(serviceName string, ctx context.Context) (system.Result, error) {
	m.loggingClient.Info(fmt.Sprintf("service %s not known to SMA as being in the ready-made list of clients", serviceName))
	if m.registryClient == nil {
		return nil, fmt.Errorf("registryClient not initialized; required to handle unknown service %s", serviceName)
	}
	if err := m.registryClient.IsServiceAvailable(serviceName); err != nil {
		return nil, err
	}
	m.loggingClient.Info(fmt.Sprintf("Registry responded with %s serviceName available", serviceName))
	endpoint, err := m.registryClient.GetServiceEndpoint(serviceName)
	if err != nil {
		return nil, fmt.Errorf("on attempting to get ServiceEndpoint for serviceName %s, got error: %v", serviceName, err.Error())
	}
	m.configClients[endpoint.ServiceId] = config.ClientInfo{
		Protocol: m.serviceProtocol,
		Host:     endpoint.Host,
		Port:     endpoint.Port,
	}
	params := types.EndpointParams{
		ServiceKey:  endpoint.ServiceId,
		Path:        "/",
		UseRegistry: true,
		Url:         m.configClients[endpoint.ServiceId].Url() + clients.ApiMetricsRoute,
		Interval:    internal.ClientMonitorDefault,
	}
	m.genClients[endpoint.ServiceId] = general.NewGeneralClient(params, startup.Endpoint{RegistryClient: &m.registryClient})
	return m.fetchMetrics(endpoint.ServiceId, ctx)
}
func ( m * metrics ) handleUnknownService ( serviceName string , ctx context . Context ) ( system . Result , error ) { m . loggingClient . Info ( fmt . Sprintf ( " " , serviceName ) ) if m . registryClient == nil { return nil , fmt . Errorf ( " " , serviceName ) } if err := m . registryClient . IsServiceAvailable ( serviceName ) ; err != nil { return nil , err } m . loggingClient . Info ( fmt . Sprintf ( " " , serviceName ) ) endpoint , err := m . registryClient . GetServiceEndpoint ( serviceName ) if err != nil { return nil , fmt . Errorf ( " " , serviceName , err . Error ( ) ) } m . configClients [ endpoint . ServiceId ] = config . ClientInfo { Protocol : m . serviceProtocol , Host : endpoint . Host , Port : endpoint . Port , } params := types . EndpointParams { ServiceKey : endpoint . ServiceId , Path : " " , UseRegistry : true , Url : m . configClients [ endpoint . ServiceId ] . Url ( ) + clients . ApiMetricsRoute , Interval : internal . ClientMonitorDefault , } m . genClients [ endpoint . ServiceId ] = general . NewGeneralClient ( params , startup . Endpoint { RegistryClient : & m . registryClient } ) return m . fetchMetrics ( endpoint . ServiceId , ctx ) }
handleUnknownService fetches metrics from an unknown service .
handleUnknownService fetches metrics from an unknown service .
// Service unknown to SMA, so ask the Registry whether `serviceName` is available. // Since serviceName is unknown to SMA, ask the Registry for a ServiceEndpoint associated with `serviceName` // add the specified key to the map where the value will be the respective GeneralClient // Add the serviceName key to the map where the value is the respective GeneralClient