type key … const auditKey … type AuditContext … // Enabled checks whether auditing is enabled for this audit context. func (ac *AuditContext) Enabled() bool { … } // AddAuditAnnotation sets the audit annotation for the given key, value pair. // It is safe to call at most parts of request flow that come after WithAuditAnnotations. // The notable exception being that this function must not be called via a // defer statement (i.e. after ServeHTTP) in a handler that runs before WithAudit // as at that point the audit event has already been sent to the audit sink. // Handlers that are unaware of their position in the overall request flow should // prefer AddAuditAnnotation over LogAnnotation to avoid dropping annotations. func AddAuditAnnotation(ctx context.Context, key, value string) { … } // AddAuditAnnotations is a bulk version of AddAuditAnnotation. Refer to AddAuditAnnotation for // restrictions on when this can be called. // keysAndValues are the key-value pairs to add, and must have an even number of items. func AddAuditAnnotations(ctx context.Context, keysAndValues ...string) { … } // AddAuditAnnotationsMap is a bulk version of AddAuditAnnotation. Refer to AddAuditAnnotation for // restrictions on when this can be called. func AddAuditAnnotationsMap(ctx context.Context, annotations map[string]string) { … } // addAuditAnnotationLocked records the audit annotation on the event. func addAuditAnnotationLocked(ac *AuditContext, key, value string) { … } // WithAuditContext returns a new context that stores the AuditContext. func WithAuditContext(parent context.Context) context.Context { … } // AuditEventFrom returns the audit event struct on the ctx func AuditEventFrom(ctx context.Context) *auditinternal.Event { … } // AuditContextFrom returns the pair of the audit configuration object // that applies to the given request and the audit event that is going to // be written to the API audit log. func AuditContextFrom(ctx context.Context) *AuditContext { … } // WithAuditID sets the AuditID on the AuditContext. The AuditContext must already be present in the // request context. If the specified auditID is empty, no value is set. func WithAuditID(ctx context.Context, auditID types.UID) { … } // AuditIDFrom returns the value of the audit ID from the request context, along with whether // auditing is enabled. func AuditIDFrom(ctx context.Context) (types.UID, bool) { … } // GetAuditIDTruncated returns the audit ID (truncated) from the request context. // If the length of the Audit-ID value exceeds the limit, we truncate it to keep // the first N (maxAuditIDLength) characters. // This is intended to be used in logging only. func GetAuditIDTruncated(ctx context.Context) string { … }