-
Notifications
You must be signed in to change notification settings - Fork 874
Instrument NpgsqlBinaryImporter with OpenTelemetry #5921
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
Conversation
|
Could this go out in a minor version release or will OTel be looked at further down the line towards Npgsql 10? |
|
@kerams we don't generally do minor releases - yeah, this will have to wait for 10. |
|
Bump. .NET 10 (and supposedly npgsql) is around the corner and I'd hate to see this going to waste for another year. |
vonzshik
left a comment
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.
In general, looks good enough. Just a few things.
5480068 to
6391097
Compare
|
The new multiplexing tests are randomly failing in local (often) and in CI (sometimes). |
Ye, I do have an idea. You have another query just before initiating COPY, and with multiplexing there is a race between a reader from that query being disposed (this is when we signal the connector that it's free to handle another query) and starting COPY operation. Specifically, the issue is that after the reader is disposed, connector first checks whether it has other queries, and if there are none, then it returns to the pool. But because it races with COPY, what happens is that that connector is not yet in the pool and so for COPY we create another connector. Limiting the pool size to 1 should do the trick. |
I tried, but the test hangs while renting a new connector. I have found another solution, by setting |
vonzshik
left a comment
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.
@manandre thank you and I'm sorry for making you wait for my feedback. Overall looks good, mostly just a few small changes.
Now, the main issue is probably with callbacks, as I imagine people would prefer to at least have an ability to disable tracing. With us prioritizing the release of Npgsql 10 this week, one potential way we can go is we merge this PR as is and I'll add tracing and callbacks to other COPY operations in a separate PR (so as to not force you to work overtime due to me being busy with other stuff).
test/Npgsql.Tests/TracingTests.cs
Outdated
| // We're not interested in temp table creation's activity | ||
| Assert.That(activities.Count, Is.EqualTo(1)); | ||
| activities.Clear(); |
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.
Maybe add another callback, to disable both physical tracing and queries?
|
@vonzshik FYI I have already prepared a branch to instrument other COPY operations. |
f337816 to
9b5fc7b
Compare
@manandre that's actually great! While I didn't check every single thing, overall it seems quite good. Main thing left there is it add callbacks to public enum CopyOperationType
{
BinaryImport,
BinaryExport,
TextImport,
TextExport,
RawBinary
}
public NpgsqlTracingOptionsBuilder ConfigureCopyOperationFilter(Func<string, CopyOperationType, bool>? copyOperationFilter)
{
// TODO
return this;
}
public NpgsqlTracingOptionsBuilder ConfigureCopyOperationEnrichmentCallback(Action<Activity, string, CopyOperationType>? copyOperationEnrichmentCallback)
{
// TODO
return this;
}
public NpgsqlTracingOptionsBuilder ConfigureCopyOperationSpanNameProvider(Func<string, CopyOperationType, string?>? copyOperationSpanNameProvider)
{
// TODO
return this;
}UPD: discussed with @roji, we probably do not want enum at all, so just 3 callbacks and reuse them for every COPY operation. |
|
@manandre as we'd like to release Npgsql 10, I think I'll take over this PR to bring it to completion ASAP (unless I run into issues). Can you please comment here in the next couple hours if you're available to do work on it? |
|
@roji I am on it, I have already implemented the new callbacks, I still have to add an unit test. |
|
Thank you, sirs. |
|
@manandre I think this is almost the last thing left that we want to get in for 10. Let me know where you're at and how you'd like to finish this - I'll get a bit to eat and will be back in ~1 hour to review etc. |
|
Unit test added. |
|
Let's wrap everything up in this single PR. It's very likely we'll be releasing Npgsql 10.0, I'll be available from the morning to review and iterate over it. |
f8ac57d to
634fb1d
Compare
|
@roji Everything added and rebased on latest main branch |
roji
left a comment
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.
Hey @manandre, thanks for the quick work. Here's a batch of comments - let me know what you're availability is like. We absolutely want to release Npgsql 10.0 today, if you're not available I might take over the PR, or we may defer it.
|
@roji I am not available before this evening. You can take it over. |
|
FYI am starting to work on this now. |
97bdbc6 to
3308f81
Compare
await using var dataSource = CreateDataSource(ds => ds.ConfigureTracing(o => o.EnablePhysicalOpenTracing(false)));@roji It must be applied in all copy tests to avoid random failures. |
vonzshik
left a comment
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.
Looks good, I think? Just have to look at test failures.
@manandre you're right, I forgot about multiplexing when working on the tests. |
Closes #5838