LLBLGen Pro Support System ORM Profiler feed https://llblgen.com/tinyforum//Forum/59 This is the RSS feed for the forum ORM Profiler on the LLBLGen Pro Support System forum system. 30 en-us Routing ProfilerMessage through our own IChannel implementation by Otis <p>The initialize method creates the channel so the messages will be send to the client. If you just want to wrap things, you can pass the factory to our framework with a wrapper factory and do the interception yourself. So if you do the wrapping but not calling initialize, you'll have to gather the messages / data yourself but you also don't get the channel. Isn't that what you're after?</p> Otis https://llblgen.com/tinyforum/Thread/28772#152993 Fri, 27 Oct 2023 07:11:32 GMT Routing ProfilerMessage through our own IChannel implementation https://llblgen.com/tinyforum/Thread/28772#152993 Routing ProfilerMessage through our own IChannel implementation by AlexP <blockquote><p class="quote-nickname">Walaa wrote:</p> <p>That's it.</p> </blockquote> <p>I understand that invoking InterceptorCore.Initialize registers a NamedPipe channel. One that starts several threads and keeps a queue of ProfileMessage’s. Is it possible to NOT have this channel created? Right now we’re doing the replacement of the registered DbProviderFactory ourselves … using the ProfilerDbProviderFactory&lt;T&gt; provided by LLBLGen . This works and provides us with everything we need… but we would prefer using LLBLGen functionality. For obvious reasons.</p> AlexP https://llblgen.com/tinyforum/Thread/28772#152991 Thu, 26 Oct 2023 19:34:12 GMT Routing ProfilerMessage through our own IChannel implementation https://llblgen.com/tinyforum/Thread/28772#152991 Routing ProfilerMessage through our own IChannel implementation by Walaa <p>That's it.</p> Walaa https://llblgen.com/tinyforum/Thread/28772#152988 Thu, 26 Oct 2023 09:40:44 GMT Routing ProfilerMessage through our own IChannel implementation https://llblgen.com/tinyforum/Thread/28772#152988 Routing ProfilerMessage through our own IChannel implementation by AlexP <p>I think I found it, when I do the InterceptorCore Initialization first, before initliazing llblgen, it grabs the correct ProfilerDbProviderFactory.</p> <p>Or isn't this the trick?</p> AlexP https://llblgen.com/tinyforum/Thread/28772#152987 Thu, 26 Oct 2023 08:13:03 GMT Routing ProfilerMessage through our own IChannel implementation https://llblgen.com/tinyforum/Thread/28772#152987 Routing ProfilerMessage through our own IChannel implementation by AlexP <p>Hi,</p> <p>I'm trying to implement my own IChannel implementation for eventually routing ProfilerMessages through a DiagnosticSource. But it's not being called, why .. do we have to enable something? </p> <p>We're using LLBLGen 5.10.2 and Interceptor 2.0.7</p> <p><strong>Our very basic (for now) Channel</strong></p> <pre><code class="cs">public class MyChannel : IChannel { // private DiagnosticSource _source = new DiagnosticListener(&quot;LLBLGen&quot;); public void Send(ProfilerMessage message) { Debug.WriteLine(message.GetType(), nameof(LLBLGenDiagnosticsChannel)); //switch (message) //{ // case CommandExecutionStartedMessage msg: // _source.Write(&quot;QueryStart&quot;, null); // break; // case CommandExecutionEndedMessage msg: // _source.Write(&quot;QueryEnd&quot;, null); // break; //} } public void Flush() { } public void DisableMessageSending() { /* ignore, it should always keep running */ } public void EnableMessageSending() { /* ignore, it will always be running */ } } </code></pre> <p><strong>Initialization</strong></p> <pre><code class="cs">InterceptorCore.Initialize(&quot;MyApplicationName&quot;); InterceptorCore.RegisterChannel(new MyChannel()); InterceptorCore.EnableMessageSending(); // Disable all channels (as we can't remove them), our own channel will not be listening to this instruction // eventually we will replace/create the factories using ProfilerDbProviderFactory&lt;T&gt; ourselves to prevent // the NamedPipeChannel+threads to be registered ... or LLBLGen should provide a way of unregistering channels // InterceptorCore.DisableMessageSending(); </code></pre> <p><em>Using DbProviderFactories.GetFactoryClasses() I can see all factories have correctly be replaced by the ProfilerDbProviderFactory.</em></p> <p>Kind regards, Alexander</p> AlexP https://llblgen.com/tinyforum/Thread/28772#152986 Thu, 26 Oct 2023 07:44:26 GMT Routing ProfilerMessage through our own IChannel implementation https://llblgen.com/tinyforum/Thread/28772#152986 ORMProfiler not showing all postgresql queries (two providers) by ikalafatic <blockquote><p class="quote-nickname">Otis wrote:</p> <p>It's a bit tricky indeed. What you also could try is to delay the initialization of the interceptor. It's key that it's initialized before any ado.net work is done so a factory is cached already, but till then it might be you can get away with it: try to obtain the factories table from DbProviderFactories before you call initialize and check if the npgsql factory is there. </p> </blockquote> <p>Ha! You gave me a hint here <em>It's key that it's initialized before any ado.net work</em>. </p> <p>I tried with this and had both entries. </p> <pre><code class="cs"> var npgsqlFactory = DbProviderFactories.GetFactory(&quot;npgsql&quot;); string npgsqlFullTypeName = npgsqlFactory.GetType().FullName; var devartFactory = DbProviderFactories.GetFactory(&quot;Devart.Data.PostgreSql&quot;); string devartFullTypeName = devartFactory.GetType().FullName; </code></pre> <p>However, based on your hint above, it seems that I've initialized the interceptor too late, part of the application already accessed the DB where the original initialization of the interceptor happened. </p> <p>I have moved the interception initialization call to the earliest possible place of application start, and now I'm seeing everything in the profiler, as expected. </p> <blockquote><p class="quote-nickname">Otis wrote:</p> <p>Hmm... might be a timeout related thing on the database... no idea to be honest, it works fine normally but I have had it occasionally too, never have been able to track it down tho what it was caused by... Sorry for this, it can be annoying indeed <img src="/tinyforum/pics/emojis/disappointed.png" class="emoji" alt="disappointed"/> </p> </blockquote> <p>No worries <img src="/tinyforum/pics/emojis/simple_smile.png" class="emoji" alt="simple_smile"/> </p> <p>Thanks so much! </p> ikalafatic https://llblgen.com/tinyforum/Thread/28697#152584 Fri, 07 Apr 2023 11:39:19 GMT ORMProfiler not showing all postgresql queries (two providers) https://llblgen.com/tinyforum/Thread/28697#152584 ORMProfiler not showing all postgresql queries (two providers) by Otis <blockquote><p class="quote-nickname">ikalafatic wrote:</p> <p>Hi Otis,</p> <p>Thanks for quick reply. </p> <p>I have tried the following in web API project<br /> - 1.5 interceptor (EFv6.Net40) - I'm getting only EF/Devart queries<br /> - 2.0 interceptor (EFv6) - I'm getting only EF/Devart queries<br /> - 2.0 interceptor (NetFull) - I'm getting devart exceptions due to invalid cast from ProfilerDbConnection to DevartDbConnection </p> <p>Excerpt from Web.config</p> <pre><code class="cs"> &lt;system.data&gt; &lt;DbProviderFactories&gt; &lt;remove invariant=&quot;Devart.Data.PostgreSql&quot; /&gt; &lt;add name=&quot;dotConnect for PostgreSql&quot; invariant=&quot;Devart.Data.PostgreSql&quot; description=&quot;Devart dotConnect for PostgreSql&quot; type=&quot;Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql&quot; /&gt; &lt;remove invariant=&quot;Npgsql&quot; /&gt; &lt;add name=&quot;Npgsql&quot; invariant=&quot;Npgsql&quot; description=&quot;Npgsql&quot; type=&quot;Npgsql.NpgsqlFactory, Npgsql&quot; /&gt; &lt;/DbProviderFactories&gt; &lt;/system.data&gt; </code></pre> </blockquote> <p>Yes, that's what I suspected, and this makes the registration of the factory here being done after the interceptor already has been initialized. If the factory is present in the machine.config file, the factory would be in the table when the interceptor is initialized. </p> <blockquote> <p>Npgsql unfortunately doesn't have option to install in GAC anymore, but I could try and follow these guidelines https://stackoverflow.com/questions/65234620/npgsql-v5-0-0-gac-installation</p> </blockquote> <p>It's a bit tricky indeed. What you also could try is to delay the initialization of the interceptor. It's key that it's initialized before any ado.net work is done so a factory is cached already, but till then it might be you can get away with it: try to obtain the factories table from DbProviderFactories before you call initialize and check if the npgsql factory is there. </p> <p>The casting errors might be caused by the fact that EF uses wrapped connections, like I said, they're not compatible hence there's a separate interceptor. </p> <blockquote> <p>But I don't think that will help, because profiling works in windows service as intended, with same stack as WebAPI. Tried running with profiler 2.0.1 and old 1.5 interceptors (EFv6.NET40). System.Data/DbProviderFactories are identically defined there. </p> </blockquote> <p>Migth be the windows service initializes things in a slightly different order which makes the config file being read earlier than the interceptor initialization call is made, which makes the npgsql factory be present in the DbProviderfactories table. The whole interception process on .netfx is a bit complicated anyway, we overwrite entries in the static (in the appdomain) DbProviderfactories datatable, but EF (and llblgen too) cache factories once obtained, so they're no longer read from that table after the first time. </p> <blockquote> <p>BTW you might have a bug in forum (bad request - 400 on saving), I've just lost entire post and had to retype <img src="/tinyforum/pics/emojis/rage.png" class="emoji" alt="rage"/> </p> </blockquote> <p>Hmm... might be a timeout related thing on the database... no idea to be honest, it works fine normally but I have had it occasionally too, never have been able to track it down tho what it was caused by... Sorry for this, it can be annoying indeed <img src="/tinyforum/pics/emojis/disappointed.png" class="emoji" alt="disappointed"/> </p> Otis https://llblgen.com/tinyforum/Thread/28697#152583 Fri, 07 Apr 2023 10:58:24 GMT ORMProfiler not showing all postgresql queries (two providers) https://llblgen.com/tinyforum/Thread/28697#152583 ORMProfiler not showing all postgresql queries (two providers) by ikalafatic <p>Hi Otis,</p> <p>Thanks for quick reply. </p> <p>I have tried the following in web API project<br /> - 1.5 interceptor (EFv6.Net40) - I'm getting only EF/Devart queries<br /> - 2.0 interceptor (EFv6) - I'm getting only EF/Devart queries<br /> - 2.0 interceptor (NetFull) - I'm getting devart exceptions due to invalid cast from ProfilerDbConnection to DevartDbConnection </p> <p>Excerpt from Web.config</p> <pre><code class="cs"> &lt;system.data&gt; &lt;DbProviderFactories&gt; &lt;remove invariant=&quot;Devart.Data.PostgreSql&quot; /&gt; &lt;add name=&quot;dotConnect for PostgreSql&quot; invariant=&quot;Devart.Data.PostgreSql&quot; description=&quot;Devart dotConnect for PostgreSql&quot; type=&quot;Devart.Data.PostgreSql.PgSqlProviderFactory, Devart.Data.PostgreSql&quot; /&gt; &lt;remove invariant=&quot;Npgsql&quot; /&gt; &lt;add name=&quot;Npgsql&quot; invariant=&quot;Npgsql&quot; description=&quot;Npgsql&quot; type=&quot;Npgsql.NpgsqlFactory, Npgsql&quot; /&gt; &lt;/DbProviderFactories&gt; &lt;/system.data&gt; </code></pre> <p>Npgsql unfortunately doesn't have option to install in GAC anymore, but I could try and follow these guidelines https://stackoverflow.com/questions/65234620/npgsql-v5-0-0-gac-installation</p> <p>But I don't think that will help, because profiling works in windows service as intended, with same stack as WebAPI. Tried running with profiler 2.0.1 and old 1.5 interceptors (EFv6.NET40). System.Data/DbProviderFactories are identically defined there. </p> <p>BTW you might have a bug in forum (bad request - 400 on saving), I've just lost entire post and had to retype <img src="/tinyforum/pics/emojis/rage.png" class="emoji" alt="rage"/> </p> ikalafatic https://llblgen.com/tinyforum/Thread/28697#152582 Fri, 07 Apr 2023 07:17:28 GMT ORMProfiler not showing all postgresql queries (two providers) https://llblgen.com/tinyforum/Thread/28697#152582 ORMProfiler not showing all postgresql queries (two providers) by Otis <p>It's a bit problematic as Entity Framework 6 requires additional code in the interceptor which will cause problems when used in normal ADO.NET, hence the separate interceptor for EF. </p> <p>As you use both llblgen and ef in your app, which interceptor did you reference? Npgsql doesn't come with an installer, you registered its DbProviderFactory in the web.config file perhaps? If so, that's likely being processed too late, the DbProviderFactories table modifications have likely already taken place when the .NET runtime starts processing that file. </p> <p>Could you make sure npgsql's factory is registered in the machine.config file of .NET? (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config)</p> Otis https://llblgen.com/tinyforum/Thread/28697#152581 Fri, 07 Apr 2023 06:59:37 GMT ORMProfiler not showing all postgresql queries (two providers) https://llblgen.com/tinyforum/Thread/28697#152581 ORMProfiler not showing all postgresql queries (two providers) by ikalafatic <p>Hi,</p> <p>I'm having issue with ORM Profiler, I'll try to give in as much details as I can. </p> <p>First, quick intro and background. We have WebAPI that uses both Npgsql (5.0.10) and Devart for Postgresql (9.13). App is running on .NET 471.</p> <p>Npgsql is used with LLBLGen 5.6 queries, and Devart is used for queries with Entity framework. </p> <p>Code for interceptor initialization is as follows</p> <pre><code class="cs">SD.Tools.OrmProfiler.Interceptor.InterceptorCore.Initialize(&quot;WebAPI&quot;); </code></pre> <p>Once app is started, I'm seeing only Devart queries (EF) and raw SQL queries executed via connections opened by Devart over DbConnectionFactory, and I'm not seeing LLBLGEn/Npgsql queries. </p> <p>I have tried with ORMProfiler 2.0.1 and ORMProfiler 2.0.4. Also tried with different versions of interceptor libs, including 1.5 (Interceptor EFv6.NET40) and 2.0.3 (Interceptor.EFv6).</p> <p>If I use Interceptor.NetFull (2.0.3), then I'm having exceptions with Devart connections due to casting of ProfilerDbConnection to DevartDbConnection</p> <p>Now, fun part starts here. I have windows service with same stack as WebAPI (doing different thing obviously), which I can profile without any issues, both EF queries and LLBLGen queries. Same versions of Devart, Npgsql, LLBlgen, even with ORMProfiler 2.0 and old interceptor EFv6.NET40.</p> <p>Please assist, as I'm getting desperate here. </p> <p>Thanks.</p> ikalafatic https://llblgen.com/tinyforum/Thread/28697#152580 Thu, 06 Apr 2023 14:30:06 GMT ORMProfiler not showing all postgresql queries (two providers) https://llblgen.com/tinyforum/Thread/28697#152580