From ad2b15053628944101a93ad5c43cf7b98abd5ed4 Mon Sep 17 00:00:00 2001 From: naman-jain-15 Date: Tue, 25 Jun 2024 15:10:37 +0530 Subject: [PATCH] Removed commented code --- receiver/datadogmetricreceiver/roles/roles.go | 178 ------------------ 1 file changed, 178 deletions(-) diff --git a/receiver/datadogmetricreceiver/roles/roles.go b/receiver/datadogmetricreceiver/roles/roles.go index eabadbe56581..5b3f685d2a2f 100644 --- a/receiver/datadogmetricreceiver/roles/roles.go +++ b/receiver/datadogmetricreceiver/roles/roles.go @@ -133,181 +133,3 @@ func convertRulesToString(rules []*processv1.PolicyRule) string { return result.String() } - -// func getOtlpExportReqFromDatadogRolesData(origin string, key string, ddReq *processv1.CollectorRole) (pmetricotlp.ExportRequest, error) { -// // assumption is that host is same for all the metrics in a given request - -// roles := ddReq.GetRoles() - -// if len(roles) == 0 { -// log.Println("no roles found so skipping") -// return pmetricotlp.ExportRequest{}, ErrNoMetricsInPayload -// } - -// metrics := pmetric.NewMetrics() -// resourceMetrics := metrics.ResourceMetrics() - -// for _, role := range roles { -// rm := resourceMetrics.AppendEmpty() -// resourceAttributes := rm.Resource().Attributes() - -// cluster_name := ddReq.GetClusterName() -// cluster_id := ddReq.GetClusterId() - -// commonResourceAttributes := commonResourceAttributes{ -// origin: origin, -// ApiKey: key, -// mwSource: "datadog", -// //host: "trial", -// } -// setMetricResourceAttributes(resourceAttributes, commonResourceAttributes) - -// scopeMetrics := rm.ScopeMetrics().AppendEmpty() -// instrumentationScope := scopeMetrics.Scope() -// instrumentationScope.SetName("mw") -// instrumentationScope.SetVersion("v0.0.1") -// scopeMetric := scopeMetrics.Metrics().AppendEmpty() -// //scopeMetric.SetName("kubernetes_state.role.count") -// scopeMetric.SetName("ddk8s.role.count") -// //scopeMetric.SetUnit(s.GetUnit()) - -// metricAttributes := pcommon.NewMap() - -// metadata := role.GetMetadata() -// resourceAttributes.PutStr("ddk8s.role.uid", metadata.GetUid()) -// metricAttributes.PutStr("ddk8s.role.namespace", metadata.GetNamespace()) -// metricAttributes.PutStr("ddk8s.role.cluster.id", cluster_id) -// metricAttributes.PutStr("ddk8s.role.cluster.name", cluster_name) -// metricAttributes.PutStr("ddk8s.role.name", metadata.GetName()) - -// currentTime := time.Now() -// milliseconds := (currentTime.UnixNano() / int64(time.Millisecond)) * 1000000 -// // fmt.Println("milliseconds",milliseconds) -// // fmt.Println("creation",metadata.GetCreationTimestamp() * 1000) -// createtime := (int64(milli//"time" -// //fmt.Println("diff is " , diff) - -// for _, tag := range role.GetTags() { - -// parts := strings.Split(tag, ":") -// if len(parts) != 2 { -// continue -// } - -// metricAttributes.PutStr(parts[0], parts[1]) -// } - -// rules := role.GetRules() -// metricAttributes.PutStr("ddk8s.role.rules", convertRulesToString(rules)) -// metricAttributes.PutStr("ddk8s.role.type", "Roles") -// metricAttributes.PutStr("ddk8s.role.labels", strings.Join(metadata.GetLabels(), "&")) -// metricAttributes.PutStr("ddk8s.role.annotations", strings.Join(metadata.GetAnnotations(), "&")) -// // current time in millis -// //fmt.Println("string is", convertRulesToString(rules)) -// var dataPoints pmetric.NumberDataPointSlice -// gauge := scopeMetric.SetEmptyGauge() -// dataPoints = gauge.DataPoints() - -// dp := dataPoints.AppendEmpty() -// dp.SetTimestamp(pcommon.Timestamp(milliseconds)) - -// dp.SetIntValue(int64(len(rules))) // setting a dummy value for this metric as only resource attribute needed -// attributeMap := dp.Attributes() -// metricAttributes.CopyTo(attributeMap) -// } - -// // metrics := pmetric.NewMetrics() -// // resourceMetrics := metrics.ResourceMetrics() -// // rm := resourceMetrics.AppendEmpty() -// // resourceAttributes := rm.Resource().Attributes() - -// // // assumption is that host is same for all the metrics in a given request -// // // var metricHost string -// // // metricHost = input.hostname - -// // // var metricHost string - -// // // for _, tag := range ddReq.GetTags() { - -// // // parts := strings.Split(tag, ":") -// // // if len(parts) != 2 { -// // // continue -// // // } - -// // // resourceAttributes.PutStr(parts[0], parts[1]) -// // // } - -// // // resourceAttributes.PutStr("kube_cluster_name", ddReq.GetClusterName()) -// // // resourceAttributes.PutStr("kube_cluster_id", ddReq.GetClusterId()) - -// // cluster_name := ddReq.GetClusterName() -// // cluster_id := ddReq.GetClusterId() - -// // commonResourceAttributes := commonResourceAttributes{ -// // origin: origin, -// // ApiKey: key, -// // mwSource: "datadog", -// // //host: "trial", -// // } -// // setMetricResourceAttributes(resourceAttributes, commonResourceAttributes) - -// // scopeMetrics := rm.ScopeMetrics().AppendEmpty() -// // instrumentationScope := scopeMetrics.Scope() -// // instrumentationScope.SetName("mw") -// // instrumentationScope.SetVersion("v0.0.1") - -// // for _, role := range roles { - -// // scopeMetric := scopeMetrics.Metrics().AppendEmpty() -// // //scopeMetric.SetName("kubernetes_state.role.count") -// // scopeMetric.SetName("ddk8s.role.count") -// // //scopeMetric.SetUnit(s.GetUnit()) - -// // metricAttributes := pcommon.NewMap() - -// // metadata := role.GetMetadata() -// // metricAttributes.PutStr("ddk8s.role.namespace", metadata.GetNamespace()) -// // metricAttributes.PutStr("ddk8s.role.cluster.id", cluster_id) -// // metricAttributes.PutStr("ddk8s.role.cluster.name", cluster_name) -// // metricAttributes.PutStr("ddk8s.role.uid", metadata.GetUid()) -// // metricAttributes.PutStr("ddk8s.role.name", metadata.GetName()) - -// // currentTime := time.Now() -// // milliseconds := (currentTime.UnixNano() / int64(time.Millisecond)) * 1000000 -// // // fmt.Println("milliseconds",milliseconds) -// // // fmt.Println("creation",metadata.GetCreationTimestamp() * 1000) -// // createtime := (int64(milliseconds/1000000000) - metadata.GetCreationTimestamp()) -// // //diff := milliseconds - (metadata.GetCreationTimestamp() * 1000) -// // fmt.Println("diff is ",createtime) -// // metricAttributes.PutInt("ddk8s.role.create.time", createtime) - -// // //fmt.Println("diff is " , diff) - -// // for _, tag := range role.GetTags() { - -// // parts := strings.Split(tag, ":") -// // if len(parts) != 2 { -// // continue -// // } - -// // metricAttributes.PutStr(parts[0], parts[1]) -// // } - -// // rules := role.GetRules() -// // metricAttributes.PutStr("ddk8s.role.rules", convertRulesToString(rules)) -// // // current time in millis -// // //fmt.Println("string is", convertRulesToString(rules)) -// // var dataPoints pmetric.NumberDataPointSlice -// // gauge := scopeMetric.SetEmptyGauge() -// // dataPoints = gauge.DataPoints() - -// // dp := dataPoints.AppendEmpty() -// // dp.SetTimestamp(pcommon.Timestamp(milliseconds)) - -// // dp.SetIntValue(int64(len(rules))) // setting a dummy value for this metric as only resource attribute needed -// // attributeMap := dp.Attributes() -// // metricAttributes.CopyTo(attributeMap) -// // } - -// return pmetricotlp.NewExportRequestFromMetrics(metrics), nil -// }