注釈、メタデータ、およびユーザー ID を記録する - AWS X-Ray

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

注釈、メタデータ、およびユーザー ID を記録する

ゲームモデルクラスでは、アプリケーションは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(); } }

移動コントローラーでは、アプリケーションはユーザー IDsetUser を使用して記録します。ユーザー 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); }