Feature Request: Migrate from klog to Zap for True Structured Logging Support
Summary
Replace the current klog-based logging implementation in csi-driver-smb with Uber's Zap logging library to enable proper structured logging with JSON output and improved observability.
Problem Statement
The current logging implementation in csi-driver-smb uses klog v2, which has significant limitations for structured logging:
- No Native JSON Output: klog's "structured" logging (
InfoS, ErrorS) outputs key=value format, not JSON
- Limited Field Types: klog doesn't handle complex field types well (nested objects, arrays)
- Poor Integration with Modern Observability: Most log aggregation systems (ELK, Grafana, Datadog) expect JSON logs
- Difficult Debugging: Key=value format is harder to parse and search compared to proper JSON
- No Context Propagation: Limited ability to carry request context through log messages
Current State Example
klog.InfoS("Processing mount request",
"volumeId", req.VolumeId,
"targetPath", req.TargetPath,
"mountOptions", req.VolumeCapability.GetMount().MountFlags)
Output:
I0409 12:34:56.123456 1234 nodeserver.go:45] "Processing mount request" volumeId="pvc-123" targetPath="/var/lib/kubelet/pods/..." mountOptions=[rw,file_mode=0777]
This format is:
- Not parseable as JSON
- Difficult to query in log aggregation systems
- Missing timestamps in structured format
- Lacks correlation IDs for tracing
Proposed Solution
Migrate to Uber Zap for structured logging with the following benefits:
1. True JSON Output
logger.Info("Processing mount request",
zap.String("volumeId", req.VolumeId),
zap.String("targetPath", req.TargetPath),
zap.Strings("mountOptions", req.VolumeCapability.GetMount().MountFlags),
zap.String("requestId", requestId))
Output:
{
"level": "info",
"ts": 1712345678.123456,
"caller": "smb/nodeserver.go:45",
"msg": "Processing mount request",
"volumeId": "pvc-123",
"targetPath": "/var/lib/kubelet/pods/...",
"mountOptions": ["rw", "file_mode=0777"],
"requestId": "req-abc123"
}
Feature Request: Migrate from klog to Zap for True Structured Logging Support
Summary
Replace the current klog-based logging implementation in csi-driver-smb with Uber's Zap logging library to enable proper structured logging with JSON output and improved observability.
Problem Statement
The current logging implementation in csi-driver-smb uses klog v2, which has significant limitations for structured logging:
InfoS,ErrorS) outputs key=value format, not JSONCurrent State Example
Output:
This format is:
Proposed Solution
Migrate to Uber Zap for structured logging with the following benefits:
1. True JSON Output
Output:
{ "level": "info", "ts": 1712345678.123456, "caller": "smb/nodeserver.go:45", "msg": "Processing mount request", "volumeId": "pvc-123", "targetPath": "/var/lib/kubelet/pods/...", "mountOptions": ["rw", "file_mode=0777"], "requestId": "req-abc123" }