Skip to content

GHCP -- Run: Ex9 Observability - #3600

Closed
neha-p6 wants to merge 1 commit into
learn/run/neha-p6-ex8from
learn/run/neha-p6-ex9
Closed

neha-p6 wants to merge 1 commit into
learn/run/neha-p6-ex8from
learn/run/neha-p6-ex9

Conversation

@neha-p6

@neha-p6 neha-p6 commented May 22, 2026

Copy link
Copy Markdown

Summary

  • Added consistent command-execution observability instrumentation across related files in components/main-chef-wrapper/cmd.
  • Chosen pattern: stderr info lines with operation metadata, matching the folder's dominant stderr logging style.
  • Added validation tests and updated logging documentation with explicit verification instructions and sample output.

Files touched:

  • components/main-chef-wrapper/cmd/observability.go
  • components/main-chef-wrapper/cmd/observability_test.go
  • components/main-chef-wrapper/cmd/passthrough_helpers.go
  • components/main-chef-wrapper/cmd/push.go
  • components/main-chef-wrapper/cmd/pushArchive.go
  • ai-track-docs/logging.md

Current State Audit

Target folder: components/main-chef-wrapper/cmd

Observed existing pattern:

  • Error output primarily uses stderr with ERROR: prefix (for example in env.go, version.go, push.go).
  • Command execution paths previously had no consistent start/success/error instrumentation across shared passthrough helpers and rollout-related command paths.

Instrumentation Pattern Chosen

Consistent line format emitted to stderr:

INFO: op=<operation> target=<binary> argc=<N> status=<start|success|error> [error="..."]

Notes:

  • Uses operation metadata and arg count only (argc) to avoid leaking argument values.
  • Emits start and terminal status (success or error) at passthrough boundaries.

Changes

  1. Added shared observability helper in observability.go:
  • buildObservationLine
  • emitCommandObservation
  • passThroughWithObservability
  1. Propagated pattern across related files:
  • passthrough_helpers.go
    • passThroughAnalyzeCommand now emits start/success/error via shared helper
    • passThroughWorkstationCommand now emits start/success/error via shared helper
  • pushArchive.go
    • push-archive command now uses shared passthrough helper
  • push.go
    • Added rollout validation observation events
    • Switched workstation and rollout-report passthrough calls to shared helper
  1. Added tests in observability_test.go:
  • Verifies consistent line format
  • Verifies error-line behavior
  • Verifies argument values are not leaked
  1. Updated docs in ai-track-docs/logging.md:
  • Added Ex9 section with scope, format, and validation instructions
  • Included sample expected output line

Validation and Evidence

Focused instrumentation tests:

cd components/main-chef-wrapper
go test ./cmd -run 'TestValidateRolloutSetupContract|TestBuildObservationLineDoesNotLeakArgs|TestEmitCommandObservationWritesConsistentInfoLine|TestEmitCommandObservationIncludesErrorDetails' -count=1 -v

Captured sample output:

sample-observation-line: INFO: op=push_archive target=chef argc=3 status=success

Side-effect check in related subsystem packages:

cd components/main-chef-wrapper
go test ./cmd ./integration ./lib

All passed.

Rollback

Rollback this Ex9 change entirely:

cd /Users/npansare/chef_workstation_repo/chef-workstation
git revert b46dcb6c
git push origin learn/run/neha-p6-ex9

ACCEPTANCE

  • Logging or metrics added across multiple related files
  • Documentation explains how to validate instrumentation
  • Evidence of logs/metrics captured in PR
  • Pattern is consistent across the folder

Track

  • Level: Run
  • Exercise: Ex9

Signed-off-by: neha-p6 <neha.pansare@progress.com>
@neha-p6 neha-p6 closed this May 22, 2026
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.

1 participant