Quellcode durchsuchen

Feature #TASK_QT-21111 【私有发版v8.5】Euspace 日志级别默认设置为info & 部分日志调整为debug级别

Tom vor 1 Jahr
Ursprung
Commit
6d115940df

+ 2 - 2
containers/container.go

@@ -652,7 +652,7 @@ func (c *Container) onListenClose(pid uint32, addr netaddr.IPPort) {
 }
 
 func (c *Container) onAcceptOpen(pid uint32, fd uint64, src, dst netaddr.IPPort, timestamp uint64, failed bool, duration time.Duration) {
-	//klog.Infof("accept pid=%d id=%s dstaddr=%s srcaddr=%s", pid, c.id, dst.IP(), src.IP())
+	klog.Debugf("accept pid=%d id=%s dstaddr=%s srcaddr=%s", pid, c.id, dst.IP(), src.IP())
 	// if common.PortFilter.ShouldBeSkipped(dst.Port()) {
 	// 	return
 	// }
@@ -1200,7 +1200,7 @@ func (c *Container) runLogParser(logPath string) {
 			parser.Stop()
 			return
 		}
-		//klog.Infoln("started varlog logparser", "cg", c.cgroup.Id, "log", logPath)
+		klog.Debugln("started varlog logparser", "cg", c.cgroup.Id, "log", logPath)
 		c.logParsers[logPath] = &LogParser{parser: parser, stop: reader.Stop}
 		return
 	}

+ 3 - 3
containers/container_apm.go

@@ -79,7 +79,7 @@ func (c *Container) InitTrace(traceId uint64, r *l7.RequestData) error {
 func (c *Container) SendEvent(t *tracing.Trace, traceID uint64) {
 	if t.AllEventReady(traceID) {
 		t.SendEvent()
-		//klog.Infof("SendEvent %d", traceID)
+		klog.Debugf("SendEvent %d", traceID)
 		//fmt.Println(t.GetSpan())
 		//fmt.Println("===============")
 		delete(c.traceMap, traceID)
@@ -115,7 +115,7 @@ func (c *Container) onL7RequestApm(pid uint32, fd uint64, timestamp uint64, r *l
 		if r.TraceStart == TRACE_STATUS {
 			// klog.Infof("====ProtocolTrace start==== %d %d", pid, r.TraceId)
 			trace, err := c.getOrInitTrace(r.TraceId)
-			//klog.Infof("payload:[%s]", r.Payload)
+			klog.Debugf("payload:[%s]", r.Payload)
 			if err == nil {
 				method, requestURI, sn, sport := l7.ParseHttpHost(r.Payload)
 				ip, _ := netaddr.ParseIP(sn)
@@ -127,7 +127,7 @@ func (c *Container) onL7RequestApm(pid uint32, fd uint64, timestamp uint64, r *l
 			return nil
 		}
 		if r.TraceEnd == TRACE_STATUS {
-			//klog.Infof("====ProtocolTrace end==== %d %d", pid, r.TraceId)
+			klog.Debugf("====ProtocolTrace end==== %d %d", pid, r.TraceId)
 			trace, err := c.getOrInitTrace(r.TraceId)
 			if err == nil {
 				trace.TraceEndEvent(r)

+ 1 - 1
containers/dotnet.go

@@ -185,7 +185,7 @@ func (m *DotNetMonitor) connect(ctx context.Context) error {
 	if len(files) != 1 {
 		return fmt.Errorf("no socket found")
 	}
-	//klog.Infoln(".NET diagnostic socket:", files[0])
+	klog.Debugln(".NET diagnostic socket:", files[0])
 	c := dotnetdiag.NewClient(files[0], dotnetdiag.WithDialer(func(addr string) (net.Conn, error) {
 		return net.DialTimeout("unix", addr, dotNetDiagnosticTimeout)
 	}))

+ 2 - 2
containers/registry.go

@@ -266,7 +266,7 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 				if !c.Dead(now) {
 					continue
 				}
-				//klog.Infoln("deleting dead container:", id)
+				klog.Debugln("deleting dead container:", id)
 				for cg, cc := range r.containersByCgroupId {
 					if cc == c {
 						delete(r.containersByCgroupId, cg)
@@ -447,7 +447,7 @@ func (r *Registry) handleEvents(ch <-chan ebpftracer.Event) {
 					//fmt.Println("EventTypeL7Request", e.Pid, c.Isl7AttachSuccess())
 					//a, _ := json.Marshal(e.L7Request)
 					//fmt.Println("EventTypeL7Request", e.Pid, string(a))
-					//klog.Debugln("Payload:", string(e.L7Request.Payload))
+					klog.Debugln("Payload:", string(e.L7Request.Payload))
 					ip2fqdn := c.onL7RequestApm(e.Pid, e.Fd, e.Timestamp, e.L7Request)
 					r.ip2fqdnLock.Lock()
 					for ip, fqdn := range ip2fqdn {

+ 6 - 6
ebpftracer/tls.go

@@ -250,12 +250,12 @@ func (t *Tracer) AttachGoTlsUprobes(pid uint32, appInfo *AppInfo, codeType uint1
 				info.StartAddr = allocDetails.StartAddr
 				info.EndAddr = allocDetails.EndAddr
 			}
-			//klog.Infoln("Major:", major)
-			//klog.Infoln("Minor:", minor)
-			//klog.Infoln("Revision:", revision)
-			//klog.Infoln("goVersion", goVersion)
-			//klog.Infoln("info.StartAddr", info.StartAddr)
-			//klog.Infoln("info.EndAddr", info.EndAddr)
+			klog.Debugln("Major:", major)
+			klog.Debugln("Minor:", minor)
+			klog.Debugln("Revision:", revision)
+			klog.Debugln("goVersion", goVersion)
+			klog.Debugln("info.StartAddr", info.StartAddr)
+			klog.Debugln("info.EndAddr", info.EndAddr)
 			_, err = tracer.UpdateProcInfoToMap(t.collection, pid, info)
 			if err != nil {
 				klog.Error("failed to update program info", err)

+ 1 - 1
flags/flags.go

@@ -20,7 +20,7 @@ var (
 	DataServer          = kingpin.Flag("data-server", "The URL of the endpoint to send traces to").Envar("DATA_SERVER").Default("http://10.0.16.250:18080").String()
 	DumpApps            = kingpin.Flag("dump", "Dump app snap").Default("false").Bool()
 	Version             = kingpin.Flag("version", "show app version").Short('v').Bool()
-	LogLevel            = kingpin.Flag("log-level", "Log level").Envar("LOG_LEVEL").Default("error").String()
+	LogLevel            = kingpin.Flag("log-level", "Log level").Envar("LOG_LEVEL").Default("info").String()
 	EbpfFilePath        = kingpin.Flag("ebpf-path", "Set ebpf file path").Envar("EBPF_FILE").Default("").String()
 	CommonIni           = kingpin.Flag("common.ini", "Set ebpf file path").Envar("COMMON_INI").Default("/opt/cloudwise/omniagent/conf/common.ini").String()
 	ServerPrefix        = kingpin.Flag("server-prefix", "server-prefix").Envar("SERVER_PREFIX").Default("").String()

+ 5 - 3
pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/apm_exporter.go

@@ -2,10 +2,12 @@ package otlptrace
 
 import (
 	"crypto/md5"
+	"encoding/json"
 	"fmt"
 	. "github.com/coroot/coroot-node-agent/ebpftracer"
 	"github.com/coroot/coroot-node-agent/ebpftracer/l7"
 	"github.com/coroot/coroot-node-agent/utils"
+	klog "github.com/sirupsen/logrus"
 	"math"
 	"net/url"
 	"sort"
@@ -223,8 +225,8 @@ func tracetransformData(sdl []tracesdk.ReadOnlySpan) map[int][]RootDataT {
 	//}
 
 	//Transform the categorized map into a slice
-	/*data, _ := json.Marshal(sendDataMap)
-	klog.Info(string(data))*/
+	data, _ := json.Marshal(sendDataMap)
+	klog.Debug(string(data))
 	//fmt.Println(len(sendData))
 	//fmt.Println("sdl len:", len(sdl))
 	return sendDataMap
@@ -711,7 +713,7 @@ func buildAppMapFromEvent(traceRoot *RootDataT, sd apmTraceSpan) int {
 	//traceRoot.RespTime = mNode.PureTimex
 	//traceRoot.CollTime = mNode.StartTime
 	for _, attr := range sd.Attributes() {
-		//klog.Debugln("Appmap:", attr.Key, ":", attr.Value.AsInterface())
+		klog.Debugln("Appmap:", attr.Key, ":", attr.Value.AsInterface())
 		switch attr.Key {
 		case "http.uri":
 			traceRoot.Uri, traceRoot.Parameters, _ = parseURIToParams(attr.Value.AsString())

+ 3 - 3
pkg/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp/client_apm.go

@@ -29,7 +29,7 @@ func (d *client) UploadApmTraces(ctx context.Context, rootData []otlptrace.RootD
 	ctx, cancel := d.contextWithStop(ctx)
 	defer cancel()
 	mapLen := len(rootData)
-	//klog.Infoln("enter the UploadApmTraces newApmRequest")
+	klog.Debugln("enter the UploadApmTraces newApmRequest")
 	request, err := d.newApmRequest(rawRequest, mapLen, CodeType(codeType))
 	if err != nil {
 		return err
@@ -113,7 +113,7 @@ func (d *client) newApmRequest(body []byte, mapLen int, codeType CodeType) (requ
 	r.Header.Set("Content-Type", "text/plain;charset=utf-8")
 
 	r.Header.Set("routingKey", codeType.Topic())
-	//klog.Infoln(codeType.Topic())
+	klog.Debugln(codeType.Topic())
 	r.Header.Set("DataCount", strconv.Itoa(mapLen))
 
 	req := request{Request: r}
@@ -146,7 +146,7 @@ func (d *client) newApmRequest(body []byte, mapLen int, codeType CodeType) (requ
 
 		req.bodyReader = bodyReader(b.Bytes())
 	case ZstdCompression:
-		//klog.Infoln("enter the ZstdCompression newApmRequest")
+		klog.Debugln("enter the ZstdCompression newApmRequest")
 		r.ContentLength = -1
 		r.Header.Set("Content-Encoding", "zstd")
 		encoder, err := zstd.NewWriter(nil)

+ 4 - 3
tracing/apm_tracing.go

@@ -3,6 +3,7 @@ package tracing
 import (
 	"context"
 	"fmt"
+	klog "github.com/sirupsen/logrus"
 	"strconv"
 	"strings"
 	"sync/atomic"
@@ -122,7 +123,7 @@ func (t *Trace) endReadyEvent(needCount uint32) {
 }
 
 func (t *Trace) AllEventReady(traceID uint64) bool {
-	//klog.Infof("[AllEventReady (current/need)|start|end|traceid](%d/%d)%v|%v|%d", *t.currenEventCount, t.needEventCount, t.startEventReady, t.endEventReady, traceID)
+	klog.Debugf("[AllEventReady (current/need)|start|end|traceid](%d/%d)%v|%v|%d", *t.currenEventCount, t.needEventCount, t.startEventReady, t.endEventReady, traceID)
 	return t.startEventReady && t.endEventReady && *t.currenEventCount >= t.needEventCount
 }
 
@@ -243,8 +244,8 @@ func (t *Trace) TraceEndEvent(r *l7.RequestData) {
 
 	attr = append(attr, attribute.String("server.src_addr", r.DAddr.String()))
 	attr = append(attr, attribute.String("server.dst_addr", r.SAddr.String()))
-	//klog.Infof("TraceEndEvent SAddr.String %s", r.SAddr.String())
-	//klog.Infof("TraceEndEvent DAddr.String %s", r.DAddr.String())
+	klog.Debugf("TraceEndEvent SAddr.String %s", r.SAddr.String())
+	klog.Debugf("TraceEndEvent DAddr.String %s", r.DAddr.String())
 
 	t.appendTimestamp(&attr, r.StartAt, r.EndAt, r.Duration.Nanoseconds())
 	t.span.SetAttributes(attr...)