Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract logging middleware #9

Merged
merged 12 commits into from
May 17, 2024
Prev Previous commit
Next Next commit
remove service name
  • Loading branch information
gimmyxd committed May 2, 2024
commit ee8554f7542fe10884493aa7aa2bfea6c94bd61c
18 changes: 0 additions & 18 deletions grpcutil/middlewares/tracing/tracing_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package tracing

import (
"context"
"strings"
"time"

"github.com/aserto-dev/aserto-grpc/grpcutil"
"github.com/aserto-dev/header"
grpcmiddleware "github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/rs/zerolog"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"google.golang.org/grpc"
)

Expand All @@ -27,21 +24,6 @@ func (h tracingHook) Run(e *zerolog.Event, level zerolog.Level, msg string) {

serviceMethod, ok := grpc.Method(ctx)
if ok {
service := strings.SplitN(serviceMethod, "/", 2)[1]
serviceArr := strings.Split(service, ".")[1:4]
var serviceArrCap []string
for _, s := range serviceArr {
serviceArrCap = append(serviceArrCap, cases.Title(language.English, cases.Compact).String(s))
}
var serviceBuilder strings.Builder
for _, s := range serviceArrCap {
serviceBuilder.WriteString(s)
}
service = serviceBuilder.String()
if len(service) > 0 {
e.Str("service", service)
}

e.Str("method", serviceMethod)

}
Expand Down
Loading