From 58bb43bb6392068aeaa77edfd57c675901f763d7 Mon Sep 17 00:00:00 2001 From: dongxuny Date: Sun, 30 Jan 2022 22:57:39 +0800 Subject: [PATCH] Bump up rk-entry verstion to v1.0.1 --- boot/grpc_entry.go | 19 ++++++++++++++----- go.mod | 6 +++--- go.sum | 12 ++++++------ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/boot/grpc_entry.go b/boot/grpc_entry.go index 03b87f9..1a6fe63 100644 --- a/boot/grpc_entry.go +++ b/boot/grpc_entry.go @@ -490,7 +490,7 @@ func (entry *GrpcEntry) GetDescription() string { // Bootstrap GrpcEntry. func (entry *GrpcEntry) Bootstrap(ctx context.Context) { - event, logger := entry.logBasicInfo("Bootstrap") + event, logger := entry.logBasicInfo("Bootstrap", ctx) // 1: Parse gateway mapping file paths, this will record http to grpc path map into a map // which will be used for /apis call in CommonServiceEntry @@ -708,9 +708,9 @@ func (entry *GrpcEntry) startHttpServer(lis net.Listener, logger *zap.Logger) { // Interrupt GrpcEntry. func (entry *GrpcEntry) Interrupt(ctx context.Context) { - event, logger := entry.logBasicInfo("Interrupt") + event, logger := entry.logBasicInfo("Interrupt", ctx) - // 3: Interrupt CommonServiceEntry, SwEntry, TvEntry, PromEntry + // Interrupt CommonServiceEntry, SwEntry, TvEntry, PromEntry if entry.IsCommonServiceEnabled() { entry.CommonServiceEntry.Interrupt(ctx) } @@ -897,14 +897,23 @@ func (entry *GrpcEntry) IsPromEnabled() bool { } // Add basic fields into event. -func (entry *GrpcEntry) logBasicInfo(operation string) (rkquery.Event, *zap.Logger) { +func (entry *GrpcEntry) logBasicInfo(operation string, ctx context.Context) (rkquery.Event, *zap.Logger) { event := entry.EventLoggerEntry.GetEventHelper().Start( operation, rkquery.WithEntryName(entry.GetName()), rkquery.WithEntryType(entry.GetType())) + + // extract eventId if exists + if val := ctx.Value("eventId"); val != nil { + if id, ok := val.(string); ok { + event.SetEventId(id) + } + } + logger := entry.ZapLoggerEntry.GetLogger().With( zap.String("eventId", event.GetEventId()), - zap.String("entryName", entry.EntryName)) + zap.String("entryName", entry.EntryName), + zap.String("entryType", entry.EntryType)) // add general info event.AddPayloads( diff --git a/go.mod b/go.mod index ba226a4..c5bc5a1 100644 --- a/go.mod +++ b/go.mod @@ -9,9 +9,9 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.1 github.com/prometheus/client_golang v1.10.0 github.com/rookie-ninja/rk-common v1.2.3 - github.com/rookie-ninja/rk-entry v1.0.9 - github.com/rookie-ninja/rk-logger v1.2.8 - github.com/rookie-ninja/rk-query v1.2.8 + github.com/rookie-ninja/rk-entry v1.0.10 + github.com/rookie-ninja/rk-logger v1.2.9 + github.com/rookie-ninja/rk-query v1.2.9 github.com/soheilhy/cmux v0.1.5 github.com/stretchr/testify v1.7.0 go.opentelemetry.io/otel v1.3.0 diff --git a/go.sum b/go.sum index 30181cb..5d18b92 100644 --- a/go.sum +++ b/go.sum @@ -458,12 +458,12 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rookie-ninja/rk-common v1.2.3 h1:bID5I11Om4az+Bkk7/RxuaHei0MS6ya1jHGnrvrqZBg= github.com/rookie-ninja/rk-common v1.2.3/go.mod h1:M2DqLnf5rUK6ewOcSNYZY4LLSJX5dg9I8Wh9JoAs4xo= -github.com/rookie-ninja/rk-entry v1.0.9 h1:/ERvcoXhRpJ3yow4nt9sAjnkDJNGIsdjU0g8IpqdLCI= -github.com/rookie-ninja/rk-entry v1.0.9/go.mod h1:yrTBrp7ZJQmihT4G1ws+0jOjhlLTeNLIXUCHudJgpnw= -github.com/rookie-ninja/rk-logger v1.2.8 h1:JwARxEZIFIjFyWe1s0VEq+URlMVLeXehnEhqAH73DCE= -github.com/rookie-ninja/rk-logger v1.2.8/go.mod h1:BgOmPpVjIHCHhqo1tqf3jUd/71Rg+Ptwi6pBeaOnOQw= -github.com/rookie-ninja/rk-query v1.2.8 h1:zhHz/vDNp4jgby6fsyTeU+pKk8hpVCJsanQAWqroPww= -github.com/rookie-ninja/rk-query v1.2.8/go.mod h1:IXLUhgMsACtVDXEmPR7jiqEuoR4+NWsV/U4u9cy2eXE= +github.com/rookie-ninja/rk-entry v1.0.10 h1:ozy6JDiORE1g9AsQDy89DuklzzlvCB/FBmc8ltrsB3Y= +github.com/rookie-ninja/rk-entry v1.0.10/go.mod h1:nxU8v5cxhphzvYYcMTYleIBXgis5cUdzfUQNXNFPRy8= +github.com/rookie-ninja/rk-logger v1.2.9 h1:EK1QyRYzJumM++yroBN2w4o+Lz2k8MW/dgSXaNkvZbw= +github.com/rookie-ninja/rk-logger v1.2.9/go.mod h1:BgOmPpVjIHCHhqo1tqf3jUd/71Rg+Ptwi6pBeaOnOQw= +github.com/rookie-ninja/rk-query v1.2.9 h1:GpeJtDzbyDJHM2DWasHuXJVe/cq8qikIRSblPbKyvpo= +github.com/rookie-ninja/rk-query v1.2.9/go.mod h1:mfDyRrngle82pDWPv1puAclI1gOXkUu5WnCBPAOj1ww= github.com/rs/xid v1.3.0 h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4= github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=