()
| 91 | } |
| 92 | |
| 93 | func (t *App) initServer() (services.Service, error) { |
| 94 | t.cfg.Server.MetricsNamespace = metricsNamespace |
| 95 | t.cfg.Server.ExcludeRequestInLog = true |
| 96 | t.cfg.Server.MetricsNativeHistogramFactor = 1.1 |
| 97 | |
| 98 | if t.cfg.EnableGoRuntimeMetrics { |
| 99 | // unregister default Go collector |
| 100 | prometheus.Unregister(collectors.NewGoCollector()) |
| 101 | // register Go collector with all available runtime metrics |
| 102 | prometheus.MustRegister(collectors.NewGoCollector( |
| 103 | collectors.WithGoCollectorRuntimeMetrics(collectors.MetricsAll), |
| 104 | )) |
| 105 | } |
| 106 | |
| 107 | servicesToWaitFor := func() []services.Service { |
| 108 | svs := []services.Service(nil) |
| 109 | for m, s := range t.serviceMap { |
| 110 | // Server should not wait for itself. |
| 111 | if m != Server && m != InternalServer { |
| 112 | svs = append(svs, s) |
| 113 | } |
| 114 | } |
| 115 | return svs |
| 116 | } |
| 117 | |
| 118 | // add unary and stream timeout interceptors for the query-frontend if configured |
| 119 | // this same timeout is enforced for http in the initQueryFrontend() function |
| 120 | if t.cfg.Frontend.APITimeout > 0 && t.isModuleActive(QueryFrontend) { |
| 121 | t.cfg.Server.GRPCMiddleware = append(t.cfg.Server.GRPCMiddleware, interceptor.NewFrontendAPIUnaryTimeout(t.cfg.Frontend.APITimeout)) |
| 122 | t.cfg.Server.GRPCStreamMiddleware = append(t.cfg.Server.GRPCStreamMiddleware, interceptor.NewFrontendAPIStreamTimeout(t.cfg.Frontend.APITimeout)) |
| 123 | } |
| 124 | |
| 125 | return t.Server.StartAndReturnService(t.cfg.Server, t.cfg.StreamOverHTTPEnabled, servicesToWaitFor) |
| 126 | } |
| 127 | |
| 128 | func (t *App) initInternalServer() (services.Service, error) { |
| 129 | if !t.cfg.InternalServer.Enable { |
nothing calls this directly
no test coverage detected