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 UpdatedJan 12, 2026
  • 3 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.2.0.7

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);
    }
}

Version Information

AFSDK


See Also

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