From 4678e3bb4767dd84d142266c5599f520bc09881d Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Mon, 30 Dec 2024 20:29:20 +0530 Subject: [PATCH] Add verbose logs --- exporter/clickhouselogsexporter/usage.go | 5 +++++ usage/usage.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/exporter/clickhouselogsexporter/usage.go b/exporter/clickhouselogsexporter/usage.go index cf76331d..b774582b 100644 --- a/exporter/clickhouselogsexporter/usage.go +++ b/exporter/clickhouselogsexporter/usage.go @@ -48,6 +48,7 @@ var ( ) func UsageExporter(metrics []*metricdata.Metric, id uuid.UUID) (map[string]usage.Usage, error) { + fmt.Println("usage exporter called in clickhouse logsexporter") data := map[string]usage.Usage{} for _, metric := range metrics { if !strings.Contains(metric.Descriptor.Name, SigNozLogsCount) && !strings.Contains(metric.Descriptor.Name, SigNozLogsBytes) { @@ -56,6 +57,7 @@ func UsageExporter(metrics []*metricdata.Metric, id uuid.UUID) (map[string]usage exporterIndex := usage.GetIndexOfLabel(metric.Descriptor.LabelKeys, usage.ExporterIDKey) tenantIndex := usage.GetIndexOfLabel(metric.Descriptor.LabelKeys, usage.TenantKey) if exporterIndex == -1 || tenantIndex == -1 { + fmt.Println("error in usage parser failed to get index of labels", metric.Descriptor.Name, metric.Descriptor.LabelKeys) return nil, fmt.Errorf("usage: failed to get index of labels") } @@ -91,5 +93,8 @@ func UsageExporter(metrics []*metricdata.Metric, id uuid.UUID) (map[string]usage } } } + for _, d := range data { + fmt.Println("data.count, data.size, data.timestamp", d.Count, d.Size, d.TimeStamp) + } return data, nil } diff --git a/usage/usage.go b/usage/usage.go index a70d12cc..6d68934d 100644 --- a/usage/usage.go +++ b/usage/usage.go @@ -73,6 +73,7 @@ func (e *UsageCollector) Start() error { } func (c *UsageCollector) Stop() error { + fmt.Println("stopping usage collector") c.ir.Stop() c.ir.Flush() return nil @@ -81,6 +82,7 @@ func (c *UsageCollector) Stop() error { func (e *UsageCollector) ExportMetrics(ctx context.Context, metrics []*metricdata.Metric) error { usages, err := e.usageParser(metrics, e.exporterID) if err != nil { + fmt.Println("error in usage parser", err) return err } time := time.Now() @@ -88,16 +90,19 @@ func (e *UsageCollector) ExportMetrics(ctx context.Context, metrics []*metricdat usage.TimeStamp = time usageBytes, err := json.Marshal(usage) if err != nil { + fmt.Println("error in marshaling usage", err) return err } encryptedData, err := Encrypt([]byte(e.exporterID.String())[:32], usageBytes) if err != nil { + fmt.Println("error in encrypting usage", err) return err } // insert everything as a new row err = e.db.Exec(ctx, fmt.Sprintf("insert into %s.%s values ($1, $2, $3, $4, $5)", e.dbName, e.distributedTableName), tenant, CollectorID.String(), e.exporterID.String(), time, string(encryptedData)) if err != nil { + fmt.Println("error in inserting usage", err) return err } }