flatten out audit tags, do not send as free-form (#20256)

move away from map[string]interface{} to map[string]string
to simplify the audit, and also provide concise information.

avoids large allocations under load(), reduces the amount
of audit information generated, as the current implementation
was a bit free-form. instead all datastructures must be
flattened.
This commit is contained in:
Harshavardhana
2024-08-13 15:22:04 -07:00
committed by GitHub
parent 516af01a12
commit e7a56f35b9
11 changed files with 100 additions and 109 deletions

View File

@@ -33,7 +33,7 @@ const contextLogKey = contextKeyType("miniolog")
// KeyVal - appended to ReqInfo.Tags
type KeyVal struct {
Key string
Val interface{}
Val string
}
// ObjectVersion object version key/versionId
@@ -77,7 +77,7 @@ func NewReqInfo(remoteHost, userAgent, deploymentID, requestID, api, bucket, obj
}
// AppendTags - appends key/val to ReqInfo.tags
func (r *ReqInfo) AppendTags(key string, val interface{}) *ReqInfo {
func (r *ReqInfo) AppendTags(key, val string) *ReqInfo {
if r == nil {
return nil
}
@@ -88,7 +88,7 @@ func (r *ReqInfo) AppendTags(key string, val interface{}) *ReqInfo {
}
// SetTags - sets key/val to ReqInfo.tags
func (r *ReqInfo) SetTags(key string, val interface{}) *ReqInfo {
func (r *ReqInfo) SetTags(key, val string) *ReqInfo {
if r == nil {
return nil
}
@@ -121,13 +121,13 @@ func (r *ReqInfo) GetTags() []KeyVal {
}
// GetTagsMap - returns the user defined tags in a map structure
func (r *ReqInfo) GetTagsMap() map[string]interface{} {
func (r *ReqInfo) GetTagsMap() map[string]string {
if r == nil {
return nil
}
r.RLock()
defer r.RUnlock()
m := make(map[string]interface{}, len(r.tags))
m := make(map[string]string, len(r.tags))
for _, t := range r.tags {
m[t.Key] = t.Val
}
@@ -135,7 +135,7 @@ func (r *ReqInfo) GetTagsMap() map[string]interface{} {
}
// PopulateTagsMap - returns the user defined tags in a map structure
func (r *ReqInfo) PopulateTagsMap(tagsMap map[string]interface{}) {
func (r *ReqInfo) PopulateTagsMap(tagsMap map[string]string) {
if r == nil {
return
}