Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Goのアプリケーションをトレース して劇的に改善した話

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Goのアプリケーションをトレース して劇的に改善した話

Avatar for saicologic

saicologic

July 07, 2022
Tweet

More Decks by saicologic

Other Decks in Technology

Transcript

  1. ©2021 Voicy, Inc. 自己紹介 三上 悟 Tech Lead at Voicy

    (元EM) @saicologic 2020年1月入社 6社目 専門はバックエンドエンジニア 17年目 Goの開発は2021年〜 PHP => Ruby => Node.js => Python => Go 趣味:ゲーム、自転車
  2. ©2021 Voicy, Inc. 認証   if a.needCheckRevoked { idToken, err =

    a.VerifyIDTokenAndCheckRevoked(ctx, bearerToken) } else { idToken, err = a.VerifyIDToken(ctx, bearerToken) } 認証の実装見ると、needCheckRevokedはFirebaseに問い合わせするが、 VerifyIDTokenは、Firebaseへの問い合せをおこないません
  3. ©2021 Voicy, Inc. 補足:認証 HTTP Header { "Authorization": "Bearer xxxxxx"

    } xxxxxxは、JWT(JSON Web Token) JWT=bearerTokenの中身です。
  4. ©2021 Voicy, Inc. 修正点 1. 認証ミドルウェアでContextにUserIDを付与した a. あらかじめユーザー登録するときに、 CustomClaims情報を付与しておくと、 JWTの中にUserID情

    報が入れられます。 VerifyIDTokenするとUserID取得できるので、ContextにいれてUserIDを引き 回せます。 2. ログのミドルウェアでContextからUserIDを取得して使う 呼び出し順番 ・UnaryServerInterceptor(auth.Authenticate) ・LoggerUnaryServerInterceptor(logger)