From 38c2530ca49704df23e0e8a76210275aa206d095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0mejkal?= Date: Sun, 21 Jan 2024 22:15:17 +0100 Subject: [PATCH] funcs --- pkg/metrics/metrics.go | 6 +++--- pkg/trace/call.go | 12 ++++++++++++ pkg/trace/call_test.go | 2 +- pkg/trace/resolver.go | 2 +- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 4499a3a6..12a160f4 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -59,7 +59,7 @@ var httpCallLatency = promauto.NewHistogramVec( // nolint:gochecknoglobals // Wh Help: "The latency of the HTTP request, in seconds", Buckets: prometheus.DefBuckets, }, - []string{"app", "call", "statuscode", "statuscategory", "kind"}, // Labels + []string{"target", "call", "statuscode", "statuscategory", "kind"}, // Labels ) // ReportHTTPLatency reports the http_request_handled metric for a request. @@ -90,7 +90,7 @@ var grpcCallLatency = promauto.NewHistogramVec( // nolint:gochecknoglobals // Wh Help: "The latency of the gRPC request, in seconds", Buckets: prometheus.DefBuckets, }, - []string{"app", "call", "statuscode", "statuscategory", "kind"}, // Labels + []string{"target", "call", "statuscode", "statuscategory", "kind"}, // Labels ) // ReportGRPCLatency reports the grpc_request_handled metric for a request. @@ -121,7 +121,7 @@ var outboundCallLatency = promauto.NewHistogramVec( // nolint:gochecknoglobals / Help: "The latency of the outbound request, in seconds", Buckets: prometheus.DefBuckets, }, - []string{"app", "call", "statuscode", "statuscategory", "kind"}, // Labels + []string{"target", "call", "statuscode", "statuscategory", "kind"}, // Labels ) // ReportOutboundLatency reports the outbound_call_seconds metric for a request. diff --git a/pkg/trace/call.go b/pkg/trace/call.go index 82a3e5a7..ea260aa3 100644 --- a/pkg/trace/call.go +++ b/pkg/trace/call.go @@ -122,6 +122,18 @@ func SetCustomCallKind(ctx context.Context, ck metrics.CallKind) { } } +// GetCallName returns name of the current call +func GetCallName(ctx context.Context) string { + callInfo := callTracker.Info(ctx) + return callInfo.Name +} + +// IsInfoLoggingEnabled returns state of info logging +func IsInfoLoggingEnabled(ctx context.Context) bool { + callInfo := callTracker.Info(ctx) + return callInfo.Opts.EnableInfoLogging +} + // EndCall calculates the duration of the call, writes to metrics, // standard logs and closes the trace span. // diff --git a/pkg/trace/call_test.go b/pkg/trace/call_test.go index 2a04cf90..76f7b39b 100644 --- a/pkg/trace/call_test.go +++ b/pkg/trace/call_test.go @@ -339,11 +339,11 @@ func TestReportLatencyMetrics(t *testing.T) { }, protocmp.Transform())) assert.Check(t, cmp.Equal(metric.GetLabel(), []*dto.LabelPair{ - {Name: proto.String("app"), Value: proto.String("gobox")}, {Name: proto.String("call"), Value: proto.String("test")}, {Name: proto.String("kind"), Value: proto.String("internal")}, {Name: proto.String("statuscategory"), Value: proto.String("CategoryOK")}, {Name: proto.String("statuscode"), Value: proto.String("OK")}, + {Name: proto.String("target"), Value: proto.String("gobox")}, }, protocmp.Transform())) } diff --git a/pkg/trace/resolver.go b/pkg/trace/resolver.go index d9f07963..df8313ca 100644 --- a/pkg/trace/resolver.go +++ b/pkg/trace/resolver.go @@ -26,7 +26,7 @@ func ResolvedLogging(logging InfoLoggingResolved) log.Marshaler { return nil } if logging == InfoLoggingEnabled { - return WithInfoLoggingDisabled() + return WithInfoLoggingEnabled() } return WithInfoLoggingDisabled() }