Skip to content
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

Flow tenant through processors as a string #3661

Merged
merged 3 commits into from
May 10, 2022

Conversation

esnible
Copy link
Contributor

@esnible esnible commented May 6, 2022

This PR replaces #3659 which passed the tenant ID string as part of a context. It is intended as the first part of a true replacement for the proof-of-concept #3605

cc @pavolloffay

@esnible esnible requested a review from a team as a code owner May 6, 2022 22:27
@esnible esnible requested a review from joe-elliott May 6, 2022 22:27
@codecov
Copy link

codecov bot commented May 6, 2022

Codecov Report

Merging #3661 (b01e658) into main (8fd5c0c) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3661      +/-   ##
==========================================
- Coverage   96.53%   96.48%   -0.05%     
==========================================
  Files         267      268       +1     
  Lines       15653    15668      +15     
==========================================
+ Hits        15111    15118       +7     
- Misses        453      459       +6     
- Partials       89       91       +2     
Impacted Files Coverage Δ
cmd/collector/app/model_consumer.go 100.00% <100.00%> (ø)
cmd/collector/app/options.go 100.00% <100.00%> (ø)
cmd/collector/app/root_span_handler.go 100.00% <100.00%> (ø)
cmd/collector/app/span_processor.go 100.00% <100.00%> (ø)
storage/tenant.go 100.00% <100.00%> (ø)
pkg/config/tlscfg/cert_watcher.go 92.63% <0.00%> (-2.11%) ⬇️
cmd/query/app/static_handler.go 94.01% <0.00%> (-1.80%) ⬇️
cmd/query/app/server.go 94.25% <0.00%> (-1.44%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8fd5c0c...b01e658. Read the comment docs.

@pavolloffay
Copy link
Member

@esnible is the intention here to make the writers tenant aware or have a writer per tenant and route to the appropriate writer in the span processor?

@esnible
Copy link
Contributor Author

esnible commented May 10, 2022

@pavolloffay The intention is to have the writers be tenant-aware.

@yurishkuro said "I see benefits to having per-tenant queues for better isolation" but later said "My suggestion would be to start with the simplest form: everything identical and shared, but tenancy exists at the data level." This is an attempt to get the tenant down to the SpanWriter with as little churn as possible as a first PR.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, a couple small fixes requested

@@ -86,3 +86,11 @@ type Operation struct {
Name string
SpanKind string
}

// tenantKeyType is a custom type for the key "tenant", following context.Context convention
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not to expose the constant, but to expose WithTenant(ctx, tenant) and GetTenant(ctx) functions, and make the constant private.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, these should probably be defined at storage/ level, not storage/spanstore

@@ -145,7 +146,8 @@ func (sp *spanProcessor) saveSpan(span *model.Span) {

startTime := time.Now()
// TODO context should be propagated from upstream components
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO context should be propagated from upstream components
// Since we save spans asynchronously from receiving them, we cannot reuse
// the inbound Context, as it may be cancelled by the time we reach this point,
// so we need to start a new Context.

return ""
}

return tenant.(string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we could make it safer

if s, ok := tenant.(string) {
    return s
}
return ""

storage/tenant.go Show resolved Hide resolved
// Verify that the dummy tenant from SpansOptions context made it to writer
assert.Equal(t, true, w.tenants[dummyTenant])
// Verify no other tenantKey context values made it to writer
assert.True(t, reflect.DeepEqual(w.tenants, map[string]bool{dummyTenant: true}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simply use assert.Equal(), it should compare the maps correctly iirc.

yurishkuro
yurishkuro previously approved these changes May 10, 2022
Signed-off-by: Ed Snible <snible@us.ibm.com>
Signed-off-by: Ed Snible <snible@us.ibm.com>
Signed-off-by: Ed Snible <snible@us.ibm.com>
@yurishkuro yurishkuro merged commit 483cf1a into jaegertracing:main May 10, 2022
albertteoh pushed a commit to albertteoh/jaeger that referenced this pull request Jul 13, 2022
* Flow tenant through processors as a string

Signed-off-by: Ed Snible <snible@us.ibm.com>

* GetTenant()/WithTenant() functions

Signed-off-by: Ed Snible <snible@us.ibm.com>

* Tests for WithTenant()/GetTenant()

Signed-off-by: Ed Snible <snible@us.ibm.com>
Signed-off-by: Albert Teoh <see.kwang.teoh@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants