-
Notifications
You must be signed in to change notification settings - Fork 74
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
feat(server): move otlp server data from runs to its own table #3028
Conversation
if !traceDB.ShouldRetry() { | ||
return true, "TraceDB is not retryable" | ||
} | ||
|
||
maxTracePollRetry := job.PollingProfile.Periodic.MaxTracePollRetry() | ||
// we're done if we have the same amount of spans after polling or `maxTracePollRetry` times | ||
log.Printf("[PollerExecutor] Test %s Run %d: Job count %d, max retries: %d", job.Test.ID, job.Run.ID, job.EnqueueCount(), maxTracePollRetry) | ||
if job.EnqueueCount() == maxTracePollRetry { | ||
if job.EnqueueCount() >= maxTracePollRetry { |
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.
there was a weird bug where a job got incorrectly requeued after hitting the max retries limit. Since the new EnqueueConunt
was bigger than maxTracePollRetry
and the check was for equality, it got forever stuck in a polling loop
"trace_id" varchar not null primary key, | ||
"tenant_id" uuid, | ||
"trace" JSONB, | ||
"created_at" timestamp NOT NULL DEFAULT NOW() |
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.
this field gets autofilled on create. the rows are always inserted. for updates we use a delete+insert approach so we'll always have the correct value.
I think this might be useful for deleting old records from time to time
server/model/traceid.go
Outdated
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.
the code in this file was not being used
server/model/traces_test.go
Outdated
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.
this file was merged with this server/traces/traces_test.go
} | ||
|
||
if run.State != test.RunStateAwaitingTrace { | ||
// test is not waiting for trace, so we can completely ignore those as they might |
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.
test integrity is now safe, since the results are saved to another table. the ingestor has no impact on the runs table
return FromSpanList(flattenSpans) | ||
} | ||
|
||
func FromSpanList(input []*v1.Span) Trace { |
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.
this was extracted as an exported function so it could be reused by the ingestor more easily
) | ||
|
||
func TestTraces(t *testing.T) { |
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.
this was merged from server/model/traces_test.go
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.
Great job @schoren I really like that you moved the traces model and logic to its own package!
ctx, | ||
`INSERT INTO otlp_traces (tenant_id, trace_id, trace) VALUES ($1, $2, $3)`, | ||
sqlutil.TenantID(ctx), | ||
trace.ID.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.
Philosophical question: should we rely on each vendor to have a unique TraceID?
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.
This is a great question. I can't think of a simple way to make this more unique and still be able to accurately query the table. I will make the PK include the tenant_id so it's at least unique among tenants. I guess at some point we'll need to relate to to something else, but maybe we should wait to have this problem and better understand the usecase behind it
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.
Adding the tenant ID to the PK makes it non-nullable, so it's no good. all the queries are using the tenant_id, so while this is not enforced on the DB level, it is at the app level, making it essentially the same
Co-authored-by: Daniel Baptista Dias <danielbdias@users.noreply.github.com>
e3308be
to
d046ae4
Compare
This PR makes the OTLP server save data on its own table instead of directly updating the
run
table with the received spans.This avoids bugs caused by moving the queues from in memory to external.
There wasn't a good place to put the
traces
repository needed, so I took the resources approach, moved theTrace
out of themodel
package and into thetraces
package, and added the repo there. So, there are a lot of files changes that are just change the reference to the newtraces.Trace
and relatedChanges
model.Trace
and related structs intotraces.Trace
traces.TraceRepository
used to store and access otlp server db dataotlp.Ingestor
to interface with thetraces.TraceRepository
Checklist