func()

in colors-e2e/colors-be/metrics.go [146:183]


func (l *RequestLogger) MakeTimeSeriesWithDataPoint(responseCodeClass string, metricValue int64) *monitoringpb.TimeSeries {
	dataPoint := &monitoringpb.Point{
		Interval: &monitoringpb.TimeInterval{
			EndTime: &googlepb.Timestamp{
				Seconds: time.Now().Unix(),
			},
		},
		Value: &monitoringpb.TypedValue{
			Value: &monitoringpb.TypedValue_Int64Value{
				Int64Value: metricValue,
			},
		},
	}

	return &monitoringpb.TimeSeries{
		Metric: &metricpb.Metric{
			Type: "custom.googleapis.com/requests/request_count",
			Labels: map[string]string{
				"deployment_name":     l.serviceMetadata.deploymentName,
				"release_id":          l.serviceMetadata.releaseId,
				"response_code_class": responseCodeClass,
			},
		},
		Resource: &monitoredrespb.MonitoredResource{
			Type: "k8s_pod",
			Labels: map[string]string{
				"project_id":     l.serviceMetadata.projectId,
				"location":       l.serviceMetadata.clusterLocation,
				"cluster_name":   l.serviceMetadata.clusterName,
				"pod_name":       l.serviceMetadata.podName,
				"namespace_name": l.serviceMetadata.podNamespace,
			},
		},
		Points: []*monitoringpb.Point{
			dataPoint,
		},
	}
}