Skip to content

Conversation

tdeebswihart
Copy link
Contributor

What changed?

This PR adds easy access to Zap's Stringer and Stringers fields.

Why?

Stringer fields are more efficient than String field. In the OSS repo alone we have 22 separate invocations of tag.NewStringTag(..., foo.String()) which would be better served by using a Stringer tag. This only calls String (which can be expensive) when the line is actually emitted.

Meaning fewer wasted cycles when calling String() for debug-level logs.

How did you test it?

  • I'm doing this manually elsewhere

@tdeebswihart tdeebswihart requested a review from a team as a code owner May 8, 2025 18:38
@tdeebswihart tdeebswihart enabled auto-merge (squash) May 8, 2025 19:24
Replace uses of `NewStringTag` where `String()` is called with
`NewStringerTag`
@tdeebswihart tdeebswihart force-pushed the tds-zap-stringer-tag branch from c55b8d5 to 24dc7e4 Compare May 8, 2025 19:24
@tdeebswihart tdeebswihart merged commit 3dcdfde into main May 8, 2025
53 checks passed
@tdeebswihart tdeebswihart deleted the tds-zap-stringer-tag branch May 8, 2025 19:45
tdeebswihart added a commit that referenced this pull request May 9, 2025
## What changed?

I've changed _some_ of the tags I altered in #7738 back to StringTags
from StringerTags and added usage recommendations to the StringerTag
(and StringersTag) methods.

## Why?

@prathyushpv rightly pointed out that some of the tags I changed in
#7738 are applied to the loggers themselves and not just the messages.
This means that the `String()` method will be invoked _every time_ a log
is to be emitted. This incurs extra allocations etc. etc.
josesa added a commit to josesa/temporal that referenced this pull request May 12, 2025
* main: (22 commits)
  Add host health metrics gauge (temporalio#7728)
  add rule expiration check (temporalio#7749)
  Add activity options to the pending activity info (temporalio#7727)
  Enable DLQ V2 for replication (temporalio#7746)
  chore: be smarter about when to use Stringer vs String (temporalio#7743)
  versioning entity workflows: enabling auto-restart pt1 (temporalio#7715)
  Refactor code generators (temporalio#7734)
  allow passive to generate replication tasks (temporalio#7713)
  Validate links in completion callbacks (temporalio#7726)
  CHASM: Engine Update/ReadComponent implementation (temporalio#7696)
  Enable transition history in dev env and tests (temporalio#7737)
  chore: Add Stringer tags (temporalio#7738)
  Add internal pod health check to DeepHealthCheck (temporalio#7709)
  Rename internal CHASM task processing interface (temporalio#7730)
  [Frontend] Log slow gRPC requests (temporalio#7718)
  Remove cap for dynamic config callback pool (temporalio#7723)
  Refactor updateworkflowoptions package (temporalio#7725)
  Remove a bunch of redundant utf-8 validation (temporalio#7720)
  [CHASM] Pure task processing - GetPureTasks, ExecutePureTasks (temporalio#7701)
  Send ActivityReset flag to the worker in heartbeat response (temporalio#7677)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants