-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds the tenant ID to the trace. I also move the pprof logging from `FromContext` to the higher level `typeRepoSearcher`. The number of events was too high, because we logged missing tenants per document. I also fixed a bug where pprof logging didn't work at all, because we read the tenant enforcemnt ENV after we set the pprof profile, so the profile was always nil. Test plan: Checked locally that tenants show up in the traces and "missing_tenant" shows up as pprof profile.
- Loading branch information
1 parent
c52a9cd
commit c1295f9
Showing
4 changed files
with
58 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
package enforcement | ||
|
||
import "go.uber.org/atomic" | ||
import ( | ||
"os" | ||
|
||
"go.uber.org/atomic" | ||
) | ||
|
||
// EnforcementMode is the current tenant enforcement mode. It resides here | ||
// instead of in the tenant package to avoid a circular dependency. See | ||
// tenanttest.MockEnforce. | ||
var EnforcementMode atomic.String | ||
|
||
// ShouldLogNoTenant returns true if the tenant enforcement mode is logging or strict. | ||
// It is used to log a warning if a request to a low-level store is made without a tenant | ||
// so we can identify missing tenants. This will go away and only strict will be allowed | ||
// once we are confident that all contexts carry tenants. | ||
func ShouldLogNoTenant() bool { | ||
switch EnforcementMode.Load() { | ||
case "logging", "strict": | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
var EnforcementMode = atomic.NewString(os.Getenv("SRC_TENANT_ENFORCEMENT_MODE")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters