Skip to content

Commit

Permalink
Merge pull request #57 from dongxuny/master
Browse files Browse the repository at this point in the history
Bump up rk-entry verstion to v1.0.1
  • Loading branch information
dongxuny authored Jan 30, 2022
2 parents 791ca21 + 58bb43b commit 11aad23
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
19 changes: 14 additions & 5 deletions boot/grpc_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 11aad23

Please sign in to comment.