Skip to content

Commit

Permalink
zerolog: fix non-camelCase fields
Browse files Browse the repository at this point in the history
Fixes #258.
  • Loading branch information
jzelinskie committed Dec 27, 2021
1 parent 15bdb00 commit 8c768a1
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions internal/dashboard/dashboard.go
Expand Up @@ -111,14 +111,14 @@ func NewHandler(grpcAddr string, grpcTLSEnabled bool, datastoreEngine string, ds
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
tmpl, err := template.New("root").Parse(rootTemplate)
if err != nil {
log.Ctx(r.Context()).Error().AnErr("template-error", err).Msg("Got error when parsing template")
log.Ctx(r.Context()).Error().AnErr("templateError", err).Msg("Got error when parsing template")
fmt.Fprintf(w, "Internal Error")
return
}

isReady, err := ds.IsReady(r.Context())
if err != nil {
log.Ctx(r.Context()).Error().AnErr("template-error", err).Msg("Got error when checking database")
log.Ctx(r.Context()).Error().AnErr("templateError", err).Msg("Got error when checking database")
fmt.Fprintf(w, "Internal Error")
return
}
Expand All @@ -140,7 +140,7 @@ func NewHandler(grpcAddr string, grpcTLSEnabled bool, datastoreEngine string, ds

nsDefs, err := ds.ListNamespaces(r.Context(), headRevision)
if err != nil {
log.Ctx(r.Context()).Error().AnErr("datastore-error", err).Msg("Got error when trying to load namespaces")
log.Ctx(r.Context()).Error().AnErr("datastoreError", err).Msg("Got error when trying to load namespaces")
fmt.Fprintf(w, "Internal Error")
return
}
Expand Down Expand Up @@ -179,7 +179,7 @@ func NewHandler(grpcAddr string, grpcTLSEnabled bool, datastoreEngine string, ds
HasSampleSchema: hasSampleSchema,
})
if err != nil {
log.Ctx(r.Context()).Error().AnErr("template-error", err).Msg("Got error when executing template")
log.Ctx(r.Context()).Error().AnErr("templateError", err).Msg("Got error when executing template")
fmt.Fprintf(w, "Internal Error")
return
}
Expand Down
6 changes: 3 additions & 3 deletions internal/datastore/postgres/postgres.go
Expand Up @@ -314,7 +314,7 @@ func (pgd *pgDatastore) collectGarbageBefore(ctx context.Context, before time.Ti
return 0, 0, err
}

log.Ctx(ctx).Trace().Uint64("highest_transaction_id", highest).Msg("retrieved transaction ID for GC")
log.Ctx(ctx).Trace().Uint64("highestTransactionId", highest).Msg("retrieved transaction ID for GC")

return pgd.collectGarbageForTransaction(ctx, highest)
}
Expand All @@ -326,7 +326,7 @@ func (pgd *pgDatastore) collectGarbageForTransaction(ctx context.Context, highes
return 0, 0, err
}

log.Ctx(ctx).Trace().Uint64("highest_transaction_id", highest).Int64("relationships_deleted", relCount).Msg("deleted stale relationships")
log.Ctx(ctx).Trace().Uint64("highestTransactionId", highest).Int64("relationshipsDeleted", relCount).Msg("deleted stale relationships")
gcRelationshipsClearedGauge.Set(float64(relCount))

// Delete all transaction rows with ID < the transaction ID. We don't delete the transaction
Expand All @@ -336,7 +336,7 @@ func (pgd *pgDatastore) collectGarbageForTransaction(ctx context.Context, highes
return relCount, 0, err
}

log.Ctx(ctx).Trace().Uint64("highest_transaction_id", highest).Int64("transactions_deleted", transactionCount).Msg("deleted stale transactions")
log.Ctx(ctx).Trace().Uint64("highestTransactionId", highest).Int64("transactionsDeleted", transactionCount).Msg("deleted stale transactions")
gcTransactionsClearedGauge.Set(float64(transactionCount))
return relCount, transactionCount, nil
}
Expand Down
4 changes: 2 additions & 2 deletions internal/dispatch/caching/caching.go
Expand Up @@ -190,7 +190,7 @@ func (cd *Dispatcher) DispatchLookup(ctx context.Context, req *v1.DispatchLookup
if cachedResultRaw, found := cd.c.Get(requestKey); found {
cachedResult := cachedResultRaw.(lookupResultEntry)
if req.Metadata.DepthRemaining >= cachedResult.response.Metadata.DepthRequired {
log.Trace().Object("using cached lookup", req).Int("result count", len(cachedResult.response.ResolvedOnrs)).Send()
log.Trace().Object("cachedLookup", req).Int("resultCount", len(cachedResult.response.ResolvedOnrs)).Send()
cd.lookupFromCacheCounter.Inc()
return cachedResult.response, nil
}
Expand All @@ -200,7 +200,7 @@ func (cd *Dispatcher) DispatchLookup(ctx context.Context, req *v1.DispatchLookup

// We only want to cache the result if there was no error and nothing was excluded.
if err == nil && len(computed.Metadata.LookupExcludedDirect) == 0 && len(computed.Metadata.LookupExcludedTtu) == 0 {
log.Trace().Object("caching lookup", req).Int("result count", len(computed.ResolvedOnrs)).Send()
log.Trace().Object("cachingLookup", req).Int("resultCount", len(computed.ResolvedOnrs)).Send()

adjustedComputed := proto.Clone(computed).(*v1.DispatchLookupResponse)
adjustedComputed.Metadata.CachedDispatchCount = adjustedComputed.Metadata.DispatchCount
Expand Down
2 changes: 1 addition & 1 deletion internal/dispatch/dispatch.go
Expand Up @@ -55,7 +55,7 @@ type HasMetadata interface {
func CheckDepth(ctx context.Context, req HasMetadata) error {
metadata := req.GetMetadata()
if metadata == nil {
log.Ctx(ctx).Warn().Object("req", req).Msg("request missing metadata")
log.Ctx(ctx).Warn().Object("request", req).Msg("request missing metadata")
return fmt.Errorf("request missing metadata")
}

Expand Down
6 changes: 3 additions & 3 deletions internal/graph/check.go
Expand Up @@ -143,7 +143,7 @@ func (cc *ConcurrentChecker) checkSetOperation(ctx context.Context, req Validate
}
}
return func(ctx context.Context, resultChan chan<- CheckResult) {
log.Ctx(ctx).Trace().Object("set operation", req).Stringer("operation", so).Send()
log.Ctx(ctx).Trace().Object("setOperation", req).Stringer("operation", so).Send()
resultChan <- reducer(ctx, requests)
}
}
Expand Down Expand Up @@ -296,7 +296,7 @@ func any(ctx context.Context, requests []ReduceableCheckFunc) CheckResult {
for i := 0; i < len(requests); i++ {
select {
case result := <-resultChan:
log.Ctx(ctx).Trace().Object("any result", result.Resp).Send()
log.Ctx(ctx).Trace().Object("anyResult", result.Resp).Send()
responseMetadata = combineResponseMetadata(responseMetadata, result.Resp.Metadata)

if result.Err == nil && result.Resp.Membership == v1.DispatchCheckResponse_MEMBER {
Expand All @@ -306,7 +306,7 @@ func any(ctx context.Context, requests []ReduceableCheckFunc) CheckResult {
return checkResultError(result.Err, result.Resp.Metadata)
}
case <-ctx.Done():
log.Ctx(ctx).Trace().Msg("any canceled")
log.Ctx(ctx).Trace().Msg("anyCanceled")
return checkResultError(NewRequestCanceledErr(), responseMetadata)
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/graph/expand.go
Expand Up @@ -183,7 +183,7 @@ func (ce *ConcurrentExpander) expandSetOperation(ctx context.Context, req Valida

func (ce *ConcurrentExpander) dispatch(req ValidatedExpandRequest) ReduceableExpandFunc {
return func(ctx context.Context, resultChan chan<- ExpandResult) {
log.Ctx(ctx).Trace().Object("dispatch expand", req).Send()
log.Ctx(ctx).Trace().Object("dispatchExpand", req).Send()
result, err := ce.d.DispatchExpand(ctx, req.DispatchExpandRequest)
resultChan <- ExpandResult{result, err}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/graph/lookup.go
Expand Up @@ -340,7 +340,7 @@ func (cl *ConcurrentLookup) processSetOperation(ctx context.Context, req Validat
}
}
return func(ctx context.Context, resultChan chan<- LookupResult) {
log.Ctx(ctx).Trace().Object("set operation", req).Stringer("operation", so).Send()
log.Ctx(ctx).Trace().Object("setOperation", req).Stringer("operation", so).Send()
resultChan <- reducer(ctx, req, req.Limit, requests)
}
}
Expand Down Expand Up @@ -573,7 +573,7 @@ func (cl *ConcurrentLookup) lookupComputed(ctx context.Context, req ValidatedLoo

func (cl *ConcurrentLookup) dispatch(req ValidatedLookupRequest) ReduceableLookupFunc {
return func(ctx context.Context, resultChan chan<- LookupResult) {
log.Ctx(ctx).Trace().Object("dispatch lookup", req).Send()
log.Ctx(ctx).Trace().Object("dispatchLookup", req).Send()
result, err := cl.d.DispatchLookup(ctx, req.DispatchLookupRequest)
resultChan <- LookupResult{result, err}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/services/v1/schema.go
Expand Up @@ -95,7 +95,7 @@ func (ss *schemaServer) WriteSchema(ctx context.Context, in *v1.WriteSchemaReque
if err != nil {
return nil, rewriteSchemaError(ctx, err)
}
log.Ctx(ctx).Trace().Interface("namespace definitions", nsdefs).Msg("compiled namespace definitions")
log.Ctx(ctx).Trace().Interface("namespaceDefinitions", nsdefs).Msg("compiled namespace definitions")

// For each definition, perform a diff and ensure the changes will not result in any
// relationships left without associated schema.
Expand All @@ -115,7 +115,7 @@ func (ss *schemaServer) WriteSchema(ctx context.Context, in *v1.WriteSchemaReque

existingDefMap[nsdef.Name] = false
}
log.Ctx(ctx).Trace().Interface("namespace definitions", nsdefs).Msg("validated namespace definitions")
log.Ctx(ctx).Trace().Interface("namespaceDefinitions", nsdefs).Msg("validated namespace definitions")

// Ensure that deleting namespaces will not result in any relationships left without associated
// schema.
Expand Down Expand Up @@ -152,7 +152,7 @@ func (ss *schemaServer) WriteSchema(ctx context.Context, in *v1.WriteSchemaReque
removedNames = append(removedNames, nsdefName)
}

log.Ctx(ctx).Trace().Interface("namespace definitions", nsdefs).Strs("added/changed", names).Strs("removed", removedNames).Msg("wrote namespace definitions")
log.Ctx(ctx).Trace().Interface("namespaceDefinitions", nsdefs).Strs("addedOrChanged", names).Strs("removed", removedNames).Msg("wrote namespace definitions")

return &v1.WriteSchemaResponse{}, nil
}
Expand Down
8 changes: 4 additions & 4 deletions internal/services/v1alpha1/schema.go
Expand Up @@ -117,7 +117,7 @@ func (ss *schemaServiceServer) WriteSchema(ctx context.Context, in *v1alpha1.Wri
return nil, rewriteError(ctx, err)
}

log.Ctx(ctx).Trace().Interface("namespace definitions", nsdefs).Msg("compiled namespace definitions")
log.Ctx(ctx).Trace().Interface("namespaceDefinitions", nsdefs).Msg("compiled namespace definitions")

for _, nsdef := range nsdefs {
ts, err := namespace.BuildNamespaceTypeSystemWithFallback(nsdef, nsm, nsdefs, headRevision)
Expand All @@ -133,7 +133,7 @@ func (ss *schemaServiceServer) WriteSchema(ctx context.Context, in *v1alpha1.Wri
return nil, rewriteError(ctx, err)
}
}
log.Ctx(ctx).Trace().Interface("namespace definitions", nsdefs).Msg("validated namespace definitions")
log.Ctx(ctx).Trace().Interface("namespaceDefinitions", nsdefs).Msg("validated namespace definitions")

// If a precondition was given, decode it, and verify that none of the namespaces specified
// have changed in any way.
Expand Down Expand Up @@ -163,7 +163,7 @@ func (ss *schemaServiceServer) WriteSchema(ctx context.Context, in *v1alpha1.Wri
}
}

log.Trace().Interface("namespace definitions", nsdefs).Msg("checked schema revision")
log.Trace().Interface("namespaceDefinitions", nsdefs).Msg("checked schema revision")
}

names := make([]string, 0, len(nsdefs))
Expand All @@ -183,7 +183,7 @@ func (ss *schemaServiceServer) WriteSchema(ctx context.Context, in *v1alpha1.Wri
return nil, rewriteError(ctx, err)
}

log.Ctx(ctx).Trace().Interface("namespace definitions", nsdefs).Str("computed revision", computedRevision).Msg("wrote namespace definitions")
log.Ctx(ctx).Trace().Interface("namespaceDefinitions", nsdefs).Str("computedRevision", computedRevision).Msg("wrote namespace definitions")

return &v1alpha1.WriteSchemaResponse{
ObjectDefinitionsNames: names,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/migrate/migrate.go
Expand Up @@ -71,7 +71,7 @@ func migrateRun(cmd *cobra.Command, args []string) error {
}

func RegisterHeadFlags(cmd *cobra.Command) {
cmd.Flags().String("datastore-engine", "postgres", "type of datastore to initialize (e.g. postgres, cockroachdb, memory")
cmd.Flags().String("engine", "postgres", "type of datastore to initialize (e.g. postgres, cockroachdb, memory")
}

func NewHeadCommand(programName string) *cobra.Command {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/serve/devtools.go
Expand Up @@ -143,7 +143,7 @@ func shareStoreFromCmd(cmd *cobra.Command) (v0svc.ShareStore, error) {
return nil, fmt.Errorf("failed to create S3 share store: %w", err)
}

event = event.Str("endpoint", endpoint).Str("region", region).Str("bucket-name", bucketName).Str("access-key", accessKey)
event = event.Str("endpoint", endpoint).Str("region", region).Str("bucketName", bucketName).Str("accessKey", accessKey)

default:
return nil, errors.New("unknown share store")
Expand Down

0 comments on commit 8c768a1

Please sign in to comment.