Update Session Baggage #
Session baggage is a per-session key-value store. When RequestBaggagePluginWithSessionBaggage is active, the values in the session
baggage cache are automatically included in request baggage for every RPC handled by that session, propagating the context into logs.
You can update the session baggage cache from any backend service, player client or partner client using the updateSessionBaggageV1 (player sessions) or
updateSessionBaggagePartnerV1 (partner sessions) RPCs.
Update player session baggage #
suspend fun updatePlayerSessionBaggageExample(playerId: String) {
// Build the baggage entries to store on the session
val baggageData = mapOf(
"buildId" to "1.2.3",
"region" to "us-west-2",
)
val request = PlayerSessionRpc.UpdateSessionBaggageV1Request.newBuilder()
.putAllData(baggageData)
.build()
val result = requestRpcV2(request, PlayerSessionRpc.UpdateSessionBaggageV1Response::parseFrom)
result.onFailure {
// the update failed — session may not exist or entry limits were exceeded
// handle the error as appropriate: log, rethrow, etc.
}
result.onSuccess {
// baggage was stored; subsequent RPCs for this session will include these entries in logs
}
}
Update partner session baggage #
suspend fun updatePartnerSessionBaggageExample(pragmaId: String) {
// Build the baggage entries to store on the session
val baggageData = mapOf(
"gameInstanceId" to "abc-123",
"matchType" to "ranked",
)
val request = PartnerSessionRpc.UpdateSessionBaggagePartnerV1Request.newBuilder()
.putAllData(baggageData)
.build()
val result = requestRpcV2(request, PartnerSessionRpc.UpdateSessionBaggagePartnerV1Response::parseFrom)
result.onFailure {
// the update failed — session may not exist or entry limits were exceeded
// handle the error as appropriate: log, rethrow, etc.
}
result.onSuccess {
// baggage was stored; subsequent RPCs for this session will include these entries in logs
}
}
Note: Entries are merged into the existing session baggage cache. Subsequent calls add or overwrite individual keys; they do not clear previously stored entries. The total number of entries across all calls is subject to the
baggageEntryLimitconfigured on the session plugin. See Plugin configuration for limit defaults.