Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monitoring: TimeSeriesData_PointData behavior vs documentation #10115

Open
ilevinpanw opened this issue May 5, 2024 · 0 comments
Open

monitoring: TimeSeriesData_PointData behavior vs documentation #10115

ilevinpanw opened this issue May 5, 2024 · 0 comments
Labels
api: monitoring Issues related to the Cloud Monitoring API. triage me I really want to be triaged.

Comments

@ilevinpanw
Copy link

Client

Monitoring/MonitoringPB

Environment

N/A

Go Environment

go version go1.21.8 darwin/arm64

Code

Code taken directly from metric.pb.go:

// A point's value columns and time interval. Each point has one or more
// point values corresponding to the entries in `point_descriptors` field in
// the TimeSeriesDescriptor associated with this object.
type TimeSeriesData_PointData struct {
  state         protoimpl.MessageState
  sizeCache     protoimpl.SizeCache
  unknownFields protoimpl.UnknownFields
  
  // The values that make up the point.
  Values []*TypedValue `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`
  // The time interval associated with the point.
  TimeInterval *TimeInterval `protobuf:"bytes,2,opt,name=time_interval,json=timeInterval,proto3" json:"time_interval,omitempty"`
}

Sample code:

func materializeTimeSeriesData[T number](iter *monitoring.TimeSeriesDataIterator) ([]T, error) {
    res := make([]T, 0)
    
    resp, err := iter.Next()
    if errors.Is(err, iterator.Done) {
      return []T{}, nil
    }
    
    if err != nil {
      return nil, err
    }
    
    for _, p := range resp.GetPointData() {
      values := p.GetValues()
      pointData := values[0].GetValue()
      ...
    }
}

Expected behavior

It is expected according to the documentation that Values will always have a length of 1 and above.

Actual behavior

Due to some temporary issue with the GCP Metrics service, length of Values was zero. It also has the omitempty tag which is confusing.

I'd appreciate a clarification of what the intended behavior is. Thanks.

@ilevinpanw ilevinpanw added the triage me I really want to be triaged. label May 5, 2024
@product-auto-label product-auto-label bot added the api: monitoring Issues related to the Cloud Monitoring API. label May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: monitoring Issues related to the Cloud Monitoring API. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant