-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-Tenancy #7060
base: main
Are you sure you want to change the base?
Multi-Tenancy #7060
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ Changes requested. Reviewed everything up to 1931180 in 2 minutes and 20 seconds
More details
- Looked at
2796
lines of code in47
files - Skipped
0
files when reviewing. - Skipped posting
9
drafted comments based on config settings.
1. pkg/rules/db.go:156
- Draft comment:
Good: SQL statements now include a tenant filter by appending common.TenantSqlPredicate(ctx). This is important for multi-tenancy isolation. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
2. pkg/rules/manager.go:344
- Draft comment:
Minor: The tenant is retrieved from context in EditRule; ensure that the tenant value is set correctly upstream in auth middleware. - Reason this comment was not posted:
Confidence changes required:30%
<= threshold50%
None
3. pkg/telemetrystore/telemetrystore.go:90
- Draft comment:
Good: The provider wraps query execution with hook calls (WrapBeforeQuery and WrapAfterQuery) which is a clear design for extensible behavior. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
4. pkg/signoz/config.go:108
- Draft comment:
Suggestion: Consider logging a warning when deprecated environment variables are used, so users can transition to new ones. - Reason this comment was not posted:
Confidence changes required:30%
<= threshold50%
None
5. pkg/common/user.go:19
- Draft comment:
TenantSqlPredicate builds a SQL predicate by interpolating the tenant directly. For safety against SQL injection, consider using parameterized queries or sanitizing the tenant value thoroughly. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. pkg/telemetrystore/clickhousetelemetrystore/provider.go:50
- Draft comment:
When TenantDSN is set, the DSN passed to clickhouse.ParseDSN is still config.ClickHouse.DSN. Likely the intended behavior is to parse config.ClickHouse.TenantDSN instead, so the tenant connection uses the correct DSN. - Reason this comment was not posted:
Marked as duplicate.
7. pkg/rules/manager.go:344
- Draft comment:
The code directly type-asserts the tenant from the context (ctx.Value(constants.ContextTenantKey).(string)). Consider using the comma-ok idiom to avoid potential panics if the tenant is missing. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
8. pkg/rules/db.go:229
- Draft comment:
Building SQL queries by concatenating strings with tenant predicates (via common.TenantSqlPredicate(ctx)) can be error-prone. Consider using parameterized queries for improved security and maintainability. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
9. pkg/telemetrystore/telemetrystore.go:20
- Draft comment:
The TelemetryStore interface now requires both ClickHouseDB() and TenantClickHouseDB(). Ensure that callers handle the case when TenantClickHouseDB() may be nil. - Reason this comment was not posted:
Confidence changes required:50%
<= threshold50%
None
Workflow ID: wflow_yiUpZ75qVOtTVTRb
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
@@ -46,17 +47,38 @@ func New(ctx context.Context, providerSettings factory.ProviderSettings, config | |||
return nil, err | |||
} | |||
|
|||
var tenantConn driver.Conn | |||
if config.ClickHouse.TenantDSN != "" { | |||
options, err := clickhouse.ParseDSN(config.ClickHouse.DSN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUG: When TenantDSN is provided, the DSN parsed is still config.ClickHouse.DSN. It should instead use config.ClickHouse.TenantDSN to correctly initialize the tenant connection.
@@ -32,7 +32,8 @@ type ClickHouseQuerySettings struct { | |||
} | |||
|
|||
type ClickHouseConfig struct { | |||
DSN string `mapstructure:"dsn"` | |||
DSN string `mapstructure:"dsn"` | |||
TenantDSN string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Consider adding a mapstructure tag for TenantDSN to allow configuring it via config files.
Summary
This PR offers shared-instance multi-tenancy for SigNoz. It is not ready to be merged in its current form, but it is functional, and it meets my company's needs for multi-tenancy in our environment.
I am opening the PR to get feedback from owners and see if this is a direction the project wants to go, and hopefully find alignment before doing more preparation for merging. I'm not picky about or attached to the design. If there are aspects of design you'd like to see changed, I can spend some amount of time to make changes. I'm on #contributing in Slack.
Related Issues / PR's
Design Sketch
The scope of changes include:
Tenant identity
Telemetry data
service.name
.service.namespace
, which would help in de-duplicatingservice.name
across tenants.User data in sqllite
Open Items
tenant
parameter to the views match the authenticated tenant for the request. This parsing could be improved upon for generality, or discarded in favor of an alternate solution, e.g. custom per-tenant views.Important
Adds multi-tenancy support to SigNoz by introducing tenant-specific data isolation and access control mechanisms.
rules/db.go
andapp/dashboards/model.go
to include tenant filtering usingcommon.TenantSqlPredicate()
.CreateRuleTx
,EditRuleTx
, andDeleteRuleTx
inrules/db.go
to handle tenant-specific operations.TenantDSN
toClickHouseConfig
inconfig.go
for tenant-specific ClickHouse connections.TenantClickHouseUrl
environment variable.ContextTenantKey
inconstants.go
for tenant identification in context.server.go
andrules/manager.go
to include tenant information.provider.go
to handle tenant-specific ClickHouse connections.PrepareTracesQuery
intraces/v4/query_builder.go
.This description was created by
for 1931180. It will automatically update as commits are pushed.