Make Nexus log messages aggregatable (#11765)

## What changed

Kept dynamic data out of Nexus log messages and moved it to tags. Added
a review guideline requiring static logger messages and structured tags
for all dynamic content.

## Why

Ensures that Nexus logs are aggregatable.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Stephan Behnke
2026-08-27 15:07:29 -07:00
committed by GitHub
parent 5c2cb12aad
commit 5aa7a471d8
4 changed files with 35 additions and 9 deletions

View File

@@ -62,6 +62,7 @@ Apply these patterns when reviewing PRs or suggesting code changes.
- Follow existing patterns: "We have been passing through the frontend request in other libraries. Let's keep the same pattern here" - Follow existing patterns: "We have been passing through the frontend request in other libraries. Let's keep the same pattern here"
- Use existing utilities before creating new ones - Use existing utilities before creating new ones
- Use static logger messages and record all dynamic content in structured tags
- Follow CLI documentation conventions (capitalize proper nouns) - Follow CLI documentation conventions (capitalize proper nouns)
- Match existing metric tag formats (CONSTANT_CASE for enum values) - Match existing metric tag formats (CONSTANT_CASE for enum values)
- Use the same error message style (no punctuation for single sentences) - Use the same error message style (no punctuation for single sentences)

View File

@@ -66,6 +66,16 @@ func RequestID(requestID string) ZapTag {
return NewStringTag("request-id", requestID) return NewStringTag("request-id", requestID)
} }
// NextPageToken returns tag for NextPageToken
func NextPageToken(nextPageToken []byte) ZapTag {
return NewBinaryTag("next-page-token", nextPageToken)
}
// PageSize returns tag for PageSize
func PageSize(pageSize int) ZapTag {
return NewInt("page-size", pageSize)
}
// ========== Workflow tags defined here: ( wf is short for workflow) ========== // ========== Workflow tags defined here: ( wf is short for workflow) ==========
// WorkflowAction returns tag for WorkflowAction // WorkflowAction returns tag for WorkflowAction

View File

@@ -195,9 +195,9 @@ func (c *NexusEndpointClient) List(
return c.listAndFilterByName(ctx, request) return c.listAndFilterByName(ctx, request)
} }
pageSize := request.GetPageSize() pageSize := int(request.GetPageSize())
if pageSize == 0 { if pageSize == 0 {
pageSize = int32(c.config.listDefaultPageSize()) pageSize = c.config.listDefaultPageSize()
} else if err := c.validatePageSize(pageSize); err != nil { } else if err := c.validatePageSize(pageSize); err != nil {
return nil, err return nil, err
} }
@@ -205,10 +205,15 @@ func (c *NexusEndpointClient) List(
resp, err := c.persistence.ListNexusEndpoints(ctx, &p.ListNexusEndpointsRequest{ resp, err := c.persistence.ListNexusEndpoints(ctx, &p.ListNexusEndpointsRequest{
LastKnownTableVersion: 0, LastKnownTableVersion: 0,
NextPageToken: request.NextPageToken, NextPageToken: request.NextPageToken,
PageSize: int(pageSize), PageSize: pageSize,
}) })
if err != nil { if err != nil {
c.logger.Error(fmt.Sprintf("error listing Nexus endpoints from persistence. NextPageToken: %v PageSize: %d", request.NextPageToken, pageSize), tag.Error(err)) c.logger.Error(
"error listing Nexus endpoints from persistence",
tag.Error(err),
tag.NextPageToken(request.NextPageToken),
tag.PageSize(pageSize),
)
return nil, serviceerror.NewInternal("error listing Nexus endpoints") return nil, serviceerror.NewInternal("error listing Nexus endpoints")
} }
@@ -285,7 +290,13 @@ func (c *NexusEndpointClient) listAndFilterByName(
PageSize: pageSize, PageSize: pageSize,
}) })
if err != nil { if err != nil {
c.logger.Error(fmt.Sprintf("error listing Nexus endpoints from persistence with Name filter. CurrentPageToken: %v PageSize: %d Name: %v", currentPageToken, pageSize, request.Name), tag.Error(err)) c.logger.Error(
"error listing Nexus endpoints from persistence with Name filter",
tag.Error(err),
tag.NextPageToken(currentPageToken),
tag.PageSize(pageSize),
tag.Endpoint(request.Name),
)
return nil, serviceerror.NewInternal("error listing Nexus endpoints") return nil, serviceerror.NewInternal("error listing Nexus endpoints")
} }
@@ -398,14 +409,14 @@ func validateGetRequest(request *operatorservice.GetNexusEndpointRequest) error
return issues.GetError() return issues.GetError()
} }
func (c *NexusEndpointClient) validatePageSize(pageSize int32) error { func (c *NexusEndpointClient) validatePageSize(pageSize int) error {
// pageSize == 0 is treated as unset and will be changed to the default and does not go through this validation // pageSize == 0 is treated as unset and will be changed to the default and does not go through this validation
if pageSize < 0 { if pageSize < 0 {
return serviceerror.NewInvalidArgument("page_size is negative") return serviceerror.NewInvalidArgument("page_size is negative")
} }
maxPageSize := c.config.listMaxPageSize() maxPageSize := c.config.listMaxPageSize()
if pageSize > int32(maxPageSize) { if pageSize > maxPageSize {
return serviceerror.NewInvalidArgumentf("page_size exceeds limit of %d", maxPageSize) return serviceerror.NewInvalidArgumentf("page_size exceeds limit of %d", maxPageSize)
} }

View File

@@ -3,7 +3,6 @@ package matching
import ( import (
"context" "context"
"errors" "errors"
"fmt"
"maps" "maps"
"math" "math"
"math/bits" "math/bits"
@@ -1104,7 +1103,12 @@ func (pm *taskQueuePartitionManagerImpl) DispatchNexusTask(
opTimeout, err := time.ParseDuration(opTimeoutHeader) opTimeout, err := time.ParseDuration(opTimeoutHeader)
if err != nil { if err != nil {
// Operation-Timeout header is not required so don't fail request on parsing errors. // Operation-Timeout header is not required so don't fail request on parsing errors.
pm.logger.Warn(fmt.Sprintf("unable to parse %v header: %v", nexus.HeaderOperationTimeout, opTimeoutHeader), tag.Error(err), tag.WorkflowNamespaceID(request.NamespaceId)) pm.logger.Warn(
"unable to parse operation-timeout header",
tag.Error(err),
tag.NewStringTag(nexus.HeaderOperationTimeout, opTimeoutHeader),
tag.WorkflowNamespaceID(request.NamespaceId),
)
} else { } else {
opDeadline = time.Now().Add(opTimeout) opDeadline = time.Now().Add(opTimeout)
} }