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

Performance counters based on Event Source in .NET Core #195

Closed
rfatkullin opened this issue Sep 8, 2021 · 20 comments
Closed

Performance counters based on Event Source in .NET Core #195

rfatkullin opened this issue Sep 8, 2021 · 20 comments

Comments

@rfatkullin
Copy link

Are there plans about implementation performance counters based on Event Source?
SqlClient Data Provider for SQL Server already have it: dotnet/SqlClient#719

@rfatkullin rfatkullin changed the title Add support for producing Event Source based counters in .NET Core Performance counters based on Event Source in .NET Core Sep 8, 2021
@alexkeh
Copy link
Member

alexkeh commented Sep 8, 2021

Not immediately. There haven't been too many people asking yet for this feature. If developers upvote the Event counters enhancement, then the ODP.NET team will make it a priority to add to a future release.

Previously, developers asked for the more traditional counters support via System.Diagnostics, which is available in ODP.NET Core on Windows today.

@rfatkullin
Copy link
Author

Should developers upvote current issue?

@alexkeh
Copy link
Member

alexkeh commented Sep 8, 2021

Yes, if it's something they want. I believe that's how organizations gauge the desirability of each feature request.

The number of upvotes and comments informs me and the Oracle .NET dev team which features developers want the most.

@ronnyek
Copy link

ronnyek commented Dec 20, 2022

Is there an alternative to being able to monitor performance on a .net core application running managed data access? I'd like to start monitoring some oracle parameters under load and don't know if this is something that should even be possible.

@alexkeh
Copy link
Member

alexkeh commented Dec 20, 2022

@ronnyek You can use ODP.NET Core performance counters on Windows with System.Diagnostics.

@ronnyek
Copy link

ronnyek commented Dec 20, 2022

@ronnyek You can use ODP.NET Core performance counters on Windows with System.Diagnostics.

Would this be based on this example?
https://github.com/oracle/dotnet-db-samples/tree/master/samples/performance-counters

Do I really need an app.config with a .net core application? If not is there another way to tell the oracle drivers to enable the performance counters?

(I ran the powershell scripts to register the counters with windows, and can see them in performance monitor, just need to know how to tell my app to enable them)

@alexkeh
Copy link
Member

alexkeh commented Dec 20, 2022

For .NET Core, you wouldn't use app.config. You can set which counters to enable with the OracleConfiguration.PerformanceCounters property. The table in the doc indicates the value of each counter type.

https://docs.oracle.com/en/database/oracle/oracle-database/21/odpnt/featConnecting.html#GUID-4FA1C8D3-195B-4D7A-9E9D-9FB74C7F5312

@ronnyek
Copy link

ronnyek commented Dec 20, 2022

appreciate this response... hope it helps others too! Thanks again

@ronnyek
Copy link

ronnyek commented Dec 20, 2022

I noticed I cant add these performance counters to performance monitor... they show up, but selecting them and hitting add doesn't actually add them.
Running lodctr /q I get

[ODP.NET, Core Driver] Performance Counters (Enabled)
    DLL Name: netfxperf.dll
    Open Procedure: OpenPerformanceData
    Collect Procedure: CollectPerformanceData
    Close Procedure: ClosePerformanceData
    First Counter ID: 0x00000C04 (3076)
    Last Counter ID: 0x00000C1A (3098)
    First Help ID: 0x00000C05 (3077)
    Last Help ID: 0x00000C1B (3099)

And may be completely unrelated, but I notice other counters reference a dll with the same name, but include a relative path like so:

[ServiceModelEndpoint 3.0.0.0] Performance Counters (Enabled)
    DLL Name: %systemroot%\system32\netfxperf.dll
    Open Procedure: OpenPerformanceData
    Collect Procedure: CollectPerformanceData
    Close Procedure: ClosePerformanceData
    First Counter ID: 0x00000B9E (2974)
    Last Counter ID: 0x00000BC4 (3012)
    First Help ID: 0x00000B9F (2975)
    Last Help ID: 0x00000BC5 (3013)

Should I need to do anything special? I tried rebuilding registry etc, but still seems like perfmon is aware of the counters, just wont let me add them to an existing session

@alexkeh
Copy link
Member

alexkeh commented Dec 20, 2022

Run the ODP.NET Core app and leave it running. Go to PerfoMon and select the counters you're interested in. In the Instances window, you should see the app process. Select that process to monitor the counters.

You can see what the experience is supposed to be like by watching the second half of this video.
https://www.youtube.com/watch?v=mNwaYIazxlw

@alexkeh alexkeh added this to the ODP.NET 21.12.1 milestone Oct 13, 2023
@alexkeh
Copy link
Member

alexkeh commented Oct 13, 2023

Managed ODP.NET and ODP.NET Core plan to support .NET Metrics in lieu of event counters. Metrics has fewer limitations than event counters.

@alexkeh alexkeh removed this from the ODP.NET 21.12.1 milestone Oct 17, 2023
@mike-geiger
Copy link

Managed ODP.NET and ODP.NET Core plan to support .NET Metrics in lieu of event counters. Metrics has fewer limitations than event counters.

@alexkeh What's the timeline for metrics support? Oracle Support indicated to us this would be included in 23c.

@alexkeh
Copy link
Member

alexkeh commented Nov 30, 2023

@mike-geiger The plan is to include .NET metrics support early in 2024. It will be part of ODP.NET 23c. The specific minor version to include it with hasn't been decided yet.

@alexkeh alexkeh added this to the ODP.NET 23.3.2 milestone Jan 2, 2024
@alexkeh
Copy link
Member

alexkeh commented Mar 12, 2024

Managed ODP.NET and ODP.NET Core 23.3.2 is now available on NuGet Gallery with .NET Metrics support.

@alexkeh alexkeh closed this as completed Mar 12, 2024
@andrepaulo
Copy link

andrepaulo commented Oct 3, 2024

Am I able to enable the PerformanceCounters using my dotnet core web application through web.config or is it only available changing the code using the OracleConfiguration class?

@alexkeh
Copy link
Member

alexkeh commented Oct 3, 2024

web.config is a .NET Framework construct. .NET Core doesn't recognize web.config.

ODP.NET .NET Metrics are automatically enabled. When an ODP.NET app starts, the metric counters are available in memory. To access the counters, you need an app to be an active subscriber.

@andrepaulo
Copy link

Thanks Alex, I believe the usage with the change on the registry for windows also incurs into .NET Framework only, am I right?. So , for dotnet Core we need to implement the subscription using the OracleConfiguration class explicitly in the code. Is it right?

@alexkeh
Copy link
Member

alexkeh commented Oct 3, 2024

I think you're mixing the two different ODP.NET connection stats: Performance Counters and .NET Metrics.

.NET Metrics never had any Registry config; Perf Counters did. Perf Counters could also be registered in .NET config files. ODP.NET Core also support Perf Counters with OracleConfiguration.PerformanceCounters on Windows only.

.NET Metrics does not require any ODP.NET-specific settings to be set. It is mutli-platform and the long term method MS recommends for .NET apps. It is well-integrated with OpenTelemetry.

There are optional ODP.NET settings that can be used, such as setting the pool name so that it's easier to distinguish which pool is being measured in a graph.

@andrepaulo
Copy link

andrepaulo commented Oct 3, 2024

Thanks for clarifying it Alex, I was actually referring to the Perf Counters, which provides info like: 'NumberOfPooledConnections' or 'NumberOfActiveConnections'.
To be able to troubleshoot my application I tried:

  1. Config it changing the registry: HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ODP.NET\Assembly_Version (all available) (didn't work)
  2. Change the web.config of the app adding (did not work):
<configuration>
(...)
    <oracle.manageddataaccess.client>
        <version number="*">
          <settings>
            <setting name="PerformanceCounters" value="4095"/>
          </settings>
        </version>
    </oracle.manageddataaccess.client>
    (...)
</configuration>
  1. Generate another version of the application enabling it programmatically (WORKED) (but is not desired, once I didn't want to have to release a version only for debugging):
public void Configure(IApplicationBuilder app, ........
(...)
    OracleConfiguration.PerformanceCounters = 4095;
    OracleConfiguration.TraceFileLocation = @"c:\oracle-trace";
    OracleConfiguration.TraceLevel = 7;

Am I missing something? I mean, with a dotnet core webapp, are there any way of configuring it to be able to monitor on 'perfmon' without having to do the option 3?

@alexkeh
Copy link
Member

alexkeh commented Oct 3, 2024

In the future, create a new issue. This thread is about EventCounters and .NET Metrics, which is what I thought you were asking about.

.NET Core doesn't look at the Registry nor .NET config files.

Programmatic enablement is the only way. However, you can create your own application configuration file with a numeric setting. OracleConfiguration.PerformanceCounters can look for the value of that setting at runtime to indicate which counters you want.

Perf Counters support is not very strong in .NET Core and will likely remain that way. MS intends for .NET Metrics to be the method to track counters in .NET Core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants