Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

PISystem.GetRpcMetrics Method

  • Last UpdatedNov 18, 2025
  • 4 minute read
PISystem.GetRpcMetrics Method
Get the remote procedure call metrics for the server.

Namespace:  OSIsoft.AF
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public AFRpcMetric[] GetRpcMetrics()
Public Function GetRpcMetrics As AFRpcMetric()

Dim instance As PISystem
Dim returnValue As AFRpcMetric()

returnValue = instance.GetRpcMetrics()
public:
array<AFRpcMetric>^ GetRpcMetrics()
member GetRpcMetrics : unit -> AFRpcMetric[] 

Return Value

Type: AFRpcMetric
Returns an array of AFRpcMetric values that represent the remote procedure call metrics since the server was started.

Remarks

This will return the remote procedure call metrics for all clients communicating with the server. The execution time reported in the metrics is the execution time in the server to the call and will not include the time required to communicate with the client.

You can use the SubtractList(IListAFRpcMetric, IListAFRpcMetric) method to return the difference between two arrays of AFRpcMetric values. This is useful to determine the metrics since the last call by subtracting the array returned by the previous call to this method from the current array of metrics.

Examples

// This example demonstrates how to get and display RpcMetrics

// Get the Database
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
AFDatabase myDB = myPISystem.Databases.DefaultDatabase;

// Get current metrics
AFRpcMetric[] lastClientMetrics = myPISystem.GetClientRpcMetrics();
AFRpcMetric[] lastServerMetrics = myPISystem.GetRpcMetrics();

// Do some operations which load objects from the server
AFNamedCollectionList<AFElement> allElements =
    AFElement.LoadElementsToDepth(myDB.Elements, true, 4, 2000);

// Get new client metrics and display results
AFRpcMetric[] newClientMetrics = myPISystem.GetClientRpcMetrics();
IList<AFRpcMetric> diffClientMetrics = AFRpcMetric.SubtractList(newClientMetrics, lastClientMetrics);
Console.WriteLine("Client RPC, Count, RetryCount, Duration(ms), PerCall(ms)");
if (null != diffClientMetrics)
{
    foreach (AFRpcMetric item in diffClientMetrics)
    {
        Console.WriteLine("{0}, {1}, {2}, {3:F1}, {4:F3}",
            item.Name, item.Count, item.RetryCount, item.Milliseconds, item.MillisecondsPerCall);
    }
}

// Get new server metrics and display results
Console.WriteLine();
AFRpcMetric[] newServerMetrics = myPISystem.GetRpcMetrics();
IList<AFRpcMetric> diffServerMetrics = AFRpcMetric.SubtractList(newServerMetrics, lastServerMetrics);
Console.WriteLine("Server RPC, Count, RetryCount, Duration(ms), PerCall(ms)");
if (null != diffServerMetrics)
{
    foreach (AFRpcMetric item in diffServerMetrics)
    {
        Console.WriteLine("{0}, {1}, {2}, {3:F1}, {4:F3}",
            item.Name, item.Count, item.RetryCount, item.Milliseconds, item.MillisecondsPerCall);
    }
}
' This example demonstrates how to get and display RpcMetrics

' Get the Database
Dim myPISystems As New PISystems
Dim myPISystem As PISystem = myPISystems.DefaultPISystem
Dim myDB As AFDatabase = myPISystem.Databases.DefaultDatabase

' Get current metrics
Dim lastClientMetrics() As AFRpcMetric = myPISystem.GetClientRpcMetrics
Dim lastServerMetrics() As AFRpcMetric = myPISystem.GetRpcMetrics

' Do some operations which load objects from the server
Dim allElements As AFNamedCollectionList(Of AFElement) =
    AFElement.LoadElementsToDepth(myDB.Elements, True, 4, 2000)

' Get new client metrics and display results
Dim newClientMetrics() As AFRpcMetric = myPISystem.GetClientRpcMetrics
Dim diffClientMetrics As IList(Of AFRpcMetric) = AFRpcMetric.SubtractList(newClientMetrics, lastClientMetrics)
Console.WriteLine("Client RPC, Count, RetryCount, Duration(ms), PerCall(ms)")
If (Not (diffClientMetrics) Is Nothing) Then
    For Each item As AFRpcMetric In diffClientMetrics
        Console.WriteLine("{0}, {1}, {2}, {3:F1}, {4:F3}",
                          item.Name, item.Count, item.RetryCount, item.Milliseconds, item.MillisecondsPerCall)
    Next
End If

' Get new server metrics and display results
Console.WriteLine()
Dim newServerMetrics() As AFRpcMetric = myPISystem.GetRpcMetrics
Dim diffServerMetrics As IList(Of AFRpcMetric) = AFRpcMetric.SubtractList(newServerMetrics, lastServerMetrics)
Console.WriteLine("Server RPC, Count, RetryCount, Duration(ms), PerCall(ms)")
If (Not (diffServerMetrics) Is Nothing) Then
    For Each item As AFRpcMetric In diffServerMetrics
        Console.WriteLine("{0}, {1}, {2}, {3:F1}, {4:F3}",
                          item.Name, item.Count, item.RetryCount, item.Milliseconds, item.MillisecondsPerCall)
    Next
End If

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK


See Also

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in