lostluck commented on a change in pull request #15657:
URL: https://github.com/apache/beam/pull/15657#discussion_r731994073
##########
File path: sdks/go/pkg/beam/core/metrics/sampler.go
##########
@@ -30,60 +30,24 @@ func NewSampler(ctx context.Context, store *Store)
StateSampler {
return StateSampler{store: store}
}
-func initialize() [4]*ExecutionState {
- var v [4]*ExecutionState
- for i := 0; i < 4; i++ {
- v[i] = &ExecutionState{}
- }
- return v
-}
-
func (s *StateSampler) Sample(ctx context.Context, t time.Duration) {
- ps := loadPTransformState(ctx)
- pid := PTransformLabels(ps.pid)
-
+ ps := loadCurrentState(ctx)
s.store.mu.Lock()
defer s.store.mu.Unlock()
- if _, ok := s.store.stateRegistry[pid]; !ok {
- s.store.stateRegistry[pid] = initialize()
- }
- if v, ok := s.store.stateRegistry[pid]; ok {
+ if v, ok := s.store.stateRegistry[ps.pid]; ok {
v[ps.state].TotalTime += t
v[TotalBundle].TotalTime += t
- }
- if _, ok := s.store.executionStore[pid]; !ok {
- s.store.executionStore[pid] = &executionTracker{}
- }
- if v, ok := s.store.executionStore[pid]; ok {
+ e := s.store.executionStore
- if v.transitionsAtLastSample != ps.transitions {
- // state change
- v.millisSinceLastTransition = 0
- v.numberOfTransitions = ps.transitions
- v.transitionsAtLastSample = ps.transitions
+ if e.transitionsAtLastSample != ps.transitions {
+ // state change detected
+ e.millisSinceLastTransition = 0
+ e.numberOfTransitions = ps.transitions
Review comment:
To be clear, sampler should have `transitionsAtLastSample` while
`numberOfTransitions` should go away. My original comment wasn't specific
enough.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]