-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
replicationcontrollers.go
32 lines (26 loc) · 1.48 KB
/
replicationcontrollers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package replicationcontroller // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver/internal/replicationcontroller"
import (
"go.opentelemetry.io/collector/pdata/pcommon"
corev1 "k8s.io/api/core/v1"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver/internal/constants"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver/internal/metadata"
)
func RecordMetrics(mb *metadata.MetricsBuilder, rc *corev1.ReplicationController, ts pcommon.Timestamp) {
if rc.Spec.Replicas != nil {
mb.RecordK8sReplicationControllerDesiredDataPoint(ts, int64(*rc.Spec.Replicas))
mb.RecordK8sReplicationControllerAvailableDataPoint(ts, int64(rc.Status.AvailableReplicas))
}
rb := mb.NewResourceBuilder()
rb.SetK8sNamespaceName(rc.Namespace)
rb.SetK8sReplicationcontrollerName(rc.Name)
rb.SetK8sReplicationcontrollerUID(string(rc.UID))
mb.EmitForResource(metadata.WithResource(rb.Emit()))
}
func GetMetadata(rc *corev1.ReplicationController) map[experimentalmetricmetadata.ResourceID]*metadata.KubernetesMetadata {
return map[experimentalmetricmetadata.ResourceID]*metadata.KubernetesMetadata{
experimentalmetricmetadata.ResourceID(rc.UID): metadata.GetGenericMetadata(&rc.ObjectMeta, constants.K8sKindReplicationController),
}
}