code: func (e *eventLogger) eventObserve(newEvent *v1.Event, key string) (*v1.Event, []byte, error) {
  	var (
  		patch []byte
  		err   error
  	)
  	eventCopy := *newEvent
  	event := &eventCopy
  
  	e.Lock()
  	defer e.Unlock()
  
  	// Check if there is an existing event we should update
  	lastObservation := e.lastEventObservationFromCache(key)
  
  	// If we found a result, prepare a patch
  	if lastObservation.count > 0 {
  		// update the event based on the last observation so patch will work as desired
  		event.Name = lastObservation.name
  		event.ResourceVersion = lastObservation.resourceVersion
  		event.FirstTimestamp = lastObservation.firstTimestamp
  		event.Count = int32(lastObservation.count) + 1
  
  		eventCopy2 := *event
  		eventCopy2.Count = 0
  		eventCopy2.LastTimestamp = metav1.NewTime(time.Unix(0, 0))
  		eventCopy2.Message = ""
  
  		newData, _ := json.Marshal(event)
  		oldData, _ := json.Marshal(eventCopy2)
  		patch, err = strategicpatch.CreateTwoWayMergePatch(oldData, newData, event)
  	}
  
  	// record our new observation
  	e.cache.Add(
  		key,
  		eventLog{
  			count:           uint(event.Count),
  			firstTimestamp:  event.FirstTimestamp,
  			name:            event.Name,
  			resourceVersion: event.ResourceVersion,
  		},
  	)
  	return event, patch, err
  }
docs: // eventObserve records an event, or updates an existing one if key is a cache hit