Skip to content

Commit

Permalink
funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
PeSme committed Jan 21, 2024
1 parent fc13434 commit 5dc2edf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions pkg/trace/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
2 changes: 1 addition & 1 deletion pkg/trace/call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/trace/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ResolvedLogging(logging InfoLoggingResolved) log.Marshaler {
return nil
}
if logging == InfoLoggingEnabled {
return WithInfoLoggingDisabled()
return WithInfoLoggingEnabled()
}
return WithInfoLoggingDisabled()
}

0 comments on commit 5dc2edf

Please sign in to comment.