deep_health_check.go ×8

Frontier kind: Code frontier

unlabeled · c_7d0e5418afef

7 tests · 3076 LOC · 151 files · introduces 0 tests · 98 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
22 ranges98 lines · 4 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
452 ranges3076 lines · 151 files · Browse complete extent
All tests (intent)
7 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

4 files ranked by introduced lines: 98 introduced LOC across 22 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/deep_health_check.go 70 introduced LOC · 8 ranges

Open complete file

31 func (h *deepHealthCheckHandler) DeepHealthCheck(
32 ctx context.Context, now time.Time,
33 > ) (*historyservice.DeepHealthCheckResponse, error) { deep_health_check.go
34 > var checks []*healthspb.HealthCheck
35 >
36 > status, err := h.healthServer.Check(ctx, &grpchealthspb.HealthCheckRequest{Service: serviceName})
37 > if err != nil || status == nil {
38 metrics.HistoryHostHealthGauge.With(h.metricsHandler).Record(float64(enumsspb.HEALTH_STATE_NOT_SERVING))
39 return &historyservice.DeepHealthCheckResponse{
47 }
48
49 > checks = append(checks, &healthspb.HealthCheck{ deep_health_check.go
50 > CheckType: healthcheck.CheckTypeGRPCHealth,
51 > // Convert to SERVING to avoid false positives during initialization
52 > State: suppressStartupErrors(status.Status, now.Sub(h.startupTime), h.config.HealthHistoryInitializationTime()),
53 > Message: fmt.Sprintf("historyservice gRPC health check: %s", status.Status.String()),
54 > })
55 >
56 > // TODO: Remove AverageLatency check once Latency is used by default.
57 > checks = append(checks, errorIfOverThreshold(healthcheck.CheckTypeRPCLatency,
58 > h.historyHealthSignal.AverageLatency(), h.config.HealthRPCLatencyFailure(),
59 > "historyservice latency", true))
60 >
61 > for _, settings := range h.config.HealthRPCLatencyPercentiles().PercentileSettings {
62 > checks = append(checks, errorIfOverThreshold(
63 > healthcheck.CheckTypeRPCLatency+fmt.Sprintf("_P%0.2f", 100.0*settings.Percentile),
64 > h.historyHealthSignal.LatencyQuantile(settings.Percentile),
65 > float64(settings.Threshold.Milliseconds()),
66 > fmt.Sprintf("historyservice percentile latency (P%0.2f < %d, enforced: %t)", 100.0*settings.Percentile, settings.Threshold.Milliseconds(), settings.Enforced),
67 > settings.Enforced,
68 > ))
69 > }
70
71 > checks = append(checks, errorIfOverThreshold(healthcheck.CheckTypeRPCErrorRatio, deep_health_check.go
72 > h.historyHealthSignal.ErrorRatio(), h.config.HealthRPCErrorRatio(),
73 > "historyservice error ratio", true))
74 >
75 > // TODO: Remove AverageLatency check once Latency is used by default.
76 > checks = append(checks, errorIfOverThreshold(healthcheck.CheckTypePersistenceLatency,
77 > h.persistenceHealthSignal.AverageLatency(), h.config.HealthPersistenceLatencyFailure(),
78 > "persistenceservice latency", true))
79 >
80 > for _, settings := range h.config.HealthPersistenceLatencyPercentiles().PercentileSettings {
81 > checks = append(checks, errorIfOverThreshold(
82 > healthcheck.CheckTypePersistenceLatency+fmt.Sprintf("_P%0.2f", 100.0*settings.Percentile),
83 > h.persistenceHealthSignal.LatencyQuantile(settings.Percentile),
84 > float64(settings.Threshold.Milliseconds()),
85 > fmt.Sprintf("persistenceservice percentile latency (P%0.2f < %d, enforced: %t)", 100.0*settings.Percentile, settings.Threshold.Milliseconds(), settings.Enforced),
86 > settings.Enforced,
87 > ))
88 > }
89
90 > checks = append(checks, errorIfOverThreshold(healthcheck.CheckTypePersistenceErrRatio, deep_health_check.go
91 > h.persistenceHealthSignal.ErrorRatio(), h.config.HealthPersistenceErrorRatio(),
92 > "persistenceservice error ratio", true))
93 >
94 > overallState := enumsspb.HEALTH_STATE_SERVING
95 >
96 > for _, check := range checks {
97 > if check.State == enumsspb.HEALTH_STATE_NOT_SERVING {
98 overallState = check.State
99 break
101 }
102
103 > metrics.HistoryHostHealthGauge.With(h.metricsHandler).Record(float64(overallState)) deep_health_check.go
104 >
105 > return &historyservice.DeepHealthCheckResponse{
106 > State: overallState,
107 > Checks: checks,
108 > }, nil
109 }
110
111 func suppressStartupErrors(status grpchealthspb.HealthCheckResponse_ServingStatus,
112 dur time.Duration, threshold time.Duration,
113 > ) enumsspb.HealthState { deep_health_check.go
114 > if dur < threshold {
115 return enumsspb.HEALTH_STATE_SERVING
116 }
118 }
119
120 > func errorIfOverThreshold(checkType string, value float64, threshold float64, message string, enforced bool) *healthspb.HealthCheck { deep_health_check.go
121 > state := enumsspb.HEALTH_STATE_SERVING
122 > if value > threshold && enforced {
123 state = enumsspb.HEALTH_STATE_NOT_SERVING
124 }
125 > return &healthspb.HealthCheck{ deep_health_check.go
126 > CheckType: checkType,
127 > State: state,
128 > Value: value,
129 > Threshold: threshold,
130 > Message: message,
131 > }
132 }
133
go.temporal.io/server/common/persistence/health_signal_aggregator.go 10 introduced LOC · 5 ranges

Open complete file

134 }
135
136 > func (s *healthSignalAggregatorImpl) AverageLatency() float64 { health_signal_aggregator.go
137 > return s.latencyAverage.Average()
138 > }
139
140 > func (s *healthSignalAggregatorImpl) LatencyQuantile(quantile float64) float64 { health_signal_aggregator.go
141 > if !s.percentilesEnabled() {
142 s.logger.Debug("health signal percentile aggregator is disabled")
143 return 0
144 }
145 > if s.latencyDistribution == nil { health_signal_aggregator.go
146 return 0
147 }
148
149 > return s.latencyDistribution.Quantile(quantile) health_signal_aggregator.go
150 }
151
152 > func (s *healthSignalAggregatorImpl) ErrorRatio() float64 { health_signal_aggregator.go
153 > return s.errorRatio.Average()
154 > }
155
156 func (s *healthSignalAggregatorImpl) incrementShardRequestCount(shardID int32) {
go.temporal.io/server/common/rpc/interceptor/health_check.go 10 introduced LOC · 7 ranges

Open complete file

219 }
220
221 > func (s *healthSignalAggregatorImpl) AverageLatency() float64 { health_check.go
222 > if !s.aggregatorEnabled() {
223 s.logger.Debug("health signal average aggregator is disabled")
224 return 0
225 }
226 > return s.latencyAverage.Average() health_check.go
227 }
228
229 > func (s *healthSignalAggregatorImpl) LatencyQuantile(quantile float64) float64 { health_check.go
230 > if !s.percentilesEnabled() {
231 s.logger.Debug("health signal percentile aggregator is disabled")
232 return 0
233 }
234 > if s.latencyDistribution == nil { health_check.go
235 return 0
236 }
237
238 > return s.latencyDistribution.Quantile(quantile) health_check.go
239 }
240
241 > func (s *healthSignalAggregatorImpl) ErrorRatio() float64 { health_check.go
242 > if !s.aggregatorEnabled() {
243 s.logger.Debug("health signal aggregator is disabled")
244 }
245
246 > return s.errorRatio.Average() health_check.go
247 }
248
go.temporal.io/server/common/aggregate/moving_window_average.go 8 introduced LOC · 2 ranges

Open complete file

58 }
59
60 > func (a *MovingWindowAvgImpl) Average() float64 { moving_window_average.go
61 > a.Lock()
62 > defer a.Unlock()
63 >
64 > a.expireOldValuesLocked()
65 > if a.count == 0 {
66 return 0
67 }
69 }
70
71 > func (a *MovingWindowAvgImpl) expireOldValuesLocked() { moving_window_average.go
72 > for ; a.headIdx != a.tailIdx; a.headIdx = (a.headIdx + 1) % a.maxBufferSize {
73 if time.Since(a.buffer[a.headIdx].timestamp) < a.windowSize {
74 break