翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
注釈、メタデータ、およびユーザー ID を記録する
注記
X-Ray SDK/デーモンメンテナンス通知 – 2026 年 2 月 25 日、 AWS X-Ray SDKs/Daemon はメンテナンスモードに移行します。 AWS では、X-Ray SDK とデーモンのリリースがセキュリティの問題にのみ対処するように制限されます。サポートタイムラインの詳細については、「X-Ray SDK とデーモンのサポートタイムライン」を参照してください。OpenTelemetry に移行することをお勧めします。OpenTelemetry への移行の詳細については、「X-Ray による計装から OpenTelemetry による計装への移行」を参照してください。
ゲームモデルクラスでは、アプリケーションはDynamoDB にゲームを保存するたびにメタデータ ブロックに Game オブジェクトを記録します。アプリケーションは個別にゲーム ID を、 フィルタ式 で使用できるように、注釈 に記録します。
例 src/main/java/scorekeep/GameModel.java –注釈とメタデータ
import com.amazonaws.xray.AWSXRay;
import com.amazonaws.xray.entities.Segment;
import com.amazonaws.xray.entities.Subsegment;
...
public void saveGame(Game game) throws SessionNotFoundException {
// wrap in subsegment
Subsegment subsegment = AWSXRay.beginSubsegment("## GameModel.saveGame");
try {
// check session
String sessionId = game.getSession();
if (sessionModel.loadSession(sessionId) == null ) {
throw new SessionNotFoundException(sessionId);
}
Segment segment = AWSXRay.getCurrentSegment();
subsegment.putMetadata("resources", "game", game);
segment.putAnnotation("gameid", game.getId());
mapper.save(game);
} catch (Exception e) {
subsegment.addException(e);
throw e;
} finally {
AWSXRay.endSubsegment();
}
}移動コントローラーでは、アプリケーションはユーザー ID を setUser を使用して記録します。ユーザー ID はセグメントの個別のフィールドに記録され、検索用にインデックスが作成されます。
例 src/main/java/scorekeep/MoveController.java – ユーザー ID
import com.amazonaws.xray.AWSXRay;
...
@RequestMapping(value="/{userId}", method=RequestMethod.POST)
public Move newMove(@PathVariable String sessionId, @PathVariable String gameId, @PathVariable String userId, @RequestBody String move) throws SessionNotFoundException, GameNotFoundException, StateNotFoundException, RulesException {
AWSXRay.getCurrentSegment().setUser(userId);
return moveFactory.newMove(sessionId, gameId, userId, move);
}