func createHealthMetrics()

in internal/oraclemetrics/oraclemetrics.go [202:234]


func createHealthMetrics(ctx context.Context, statusData map[string]*ServiceHealth, cfg *configpb.Configuration) []*mrpb.TimeSeries {
	timeSeries := []*mrpb.TimeSeries{}
	for serviceName, serviceHealth := range statusData {
		ts := &mrpb.TimeSeries{
			Metric: &mpb.Metric{
				Type:   metricURL + "/health",
				Labels: map[string]string{"service_name": serviceName},
			},
			Resource: &mrespb.MonitoredResource{
				Type: "gce_instance",
				Labels: map[string]string{
					"project_id":  cfg.GetCloudProperties().GetProjectId(),
					"instance_id": cfg.GetCloudProperties().GetInstanceId(),
					"zone":        cfg.GetCloudProperties().GetZone(),
				},
			},
			Points: []*mrpb.Point{
				{
					Interval: &cpb.TimeInterval{
						EndTime: tspb.New(serviceHealth.LastChecked),
					},
					Value: &cpb.TypedValue{
						Value: &cpb.TypedValue_BoolValue{
							BoolValue: serviceHealth.Status == Healthy,
						},
					},
				},
			},
		}
		timeSeries = append(timeSeries, ts)
	}
	return timeSeries
}