Skip to content

Commit

Permalink
Removed commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
naman-jain-15 committed Jun 25, 2024
1 parent 9efc99e commit ad2b150
Showing 1 changed file with 0 additions and 178 deletions.
178 changes: 0 additions & 178 deletions receiver/datadogmetricreceiver/roles/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// }

0 comments on commit ad2b150

Please sign in to comment.