メインコンテンツまでスキップ

Configure TURN server metric data

Last updated on October 23, 2024
AGS Private Cloud

This feature is only available for AccelByte Gaming Services (AGS) Private Cloud.

Overview

A game client can send a specific metrics to the AccelByte Gaming Services (AGS) backend, allowing for increased observability for developers. However, peer-to-peer (P2P) networks employ the decentralized paradigm that makes it harder to observe their current production status. You can use TURN servers can alleviate this shortcoming of P2P networks and provide observability for the following:

  • The server going down
  • The server is under heavy load and for how long
  • The percentage of P2P game sessions using the relay
  • How many game clients have disconnected from the host and their reasons (either host or client disconnecting)
  • The number of CCU, server connections, and sessions

This article will show you how to use a TURN server to send specific metric data from your game to the AGS backend using the AGS Game SDK.

Monitor server status through Grafana

To view the status of your game's server, use the provided Grafana tools accessible through the AGS Admin Portal. Follow the steps below to do this.

  1. Log in to AGS Admin Portal and go to your game namespace.
  2. Go to Development Utilities > Grafana Cloud. You will be redirected to the Grafana login page.
  3. Use your AGS Admin Portal credentials to log into Grafana Cloud.
  4. In Grafana Cloud, go to Dashboards > Play Services Overview > Play Services - Overview.
  5. On the Play Services - Overview page in Grafana, expand TURN Server.
  6. Use these panels to monitor the TURN server for your game, adjusting the query parameters as desired.

Implement sending TURN server metric data

These sections provides code samples and shows you how to implement sending metric data from your TURN server to the AGS backend.

Send "Connect" metric data

The method below should be triggered after the player successfully connects to the host.

ヒント

It is recommended you assign the selectedRegion variable with the closest TURN Server region.

    string selectedRegion = "";
P2PConnectionType connectType = P2PConnectionType.Host;

AccelByteSDK.GetClientRegistry().GetApi().GetTurnManager().SendMetric(selectedRegion, connectType
, result =>
{
if (result.IsError)
{
// Do something if operation fails
UnityEngine.Debug.LogError($"failed to send connection metric [{result.Error.Code}]:{result.Error.Message}");
return;
}

// Do something if the operation is a success
});

Send "Disconnect" metric data

The method below should be triggered after the player disconnects from the host.

    AccelByteSDK.GetClientRegistry().GetApi().GetTurnManager().SendDisconnectedMetric(result =>
{
if (result.IsError)
{
//Do something if operation fails
UnityEngine.Debug.LogError($"failed to send disconnection metric [{result.Error.Code}]:{result.Error.Message}");
return;
}

// Do something if the operation is a success
});