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

#phpcon2022 エラーと向き合い、自信を持って サービス開発に取り組み、前に進む

#phpcon2022 エラーと向き合い、自信を持って サービス開発に取り組み、前に進む

PHP Conference Japan 2022での発表資料です

https://fortee.jp/phpcon-2022/proposal/ace60290-0c64-4a64-80ca-74fa5e27e446

※ 追加スライドを含む「配布版」はコチラ → https://speakerdeck.com/o0h/phpcon-2022

hideki kinjyo
PRO

September 25, 2022
Tweet

More Decks by hideki kinjyo

Other Decks in Programming

Transcript

  1. PHP Conference Japan 2022 Hideki Kinjyo GitHub: o0h / Twitter:

    @o0h_ 
 
 [ൃද൛]
  2. ࣗݾ঺հ / GitHub: @o0h / Twitter: @o0h_ FW CakePHP 


    
  3. ࣗ৴Λ࣋ͭɾɾʁ 

  4. ࣗ৴Λ࣋ͭɾɾʁ 

  5. ࣗ৴Λ࣋ͭɾɾʁ 

  6. ( )

  7. Ͳ͏͢ΔʁˠʮΤϥʔͱ޲͖߹͏ʯ 
 
 胸 

  8. 胸 1

  9. ͓͠ͳ͕͖ 1. - - 2. - - 3. - -

    4. - with Sentry- 5. 
  10. ͖͑͘͢ΎʔͣΈʔʂ Sentry 😀 

  11. ֓೦ɾݺͼํʹ͍ͭͯ : E_ALL : 
 ( ) : ( )

    : 
  12. §1 - -

  13. §1 .1

  14. ݸਓతͳؾ࣋ͪ 2 胸 

  15. ࢲతͳܦݧ or 
 2 薄 1. 2. 

  16. ࢲతͳܦݧᶃ 

  17. ࢲతͳܦݧᶃ Open (Sentry Raygun Errbit) Rate Limit 

  18. = ( )

  19. ϓϩҙࣝʹ݉Ͷඋ͑ΒΕΔ΂͖ʮྙཧʯ  [ग़య] 
 ᴷ Robert C. Martin,֯ ੐య. 


    Clean Craftsmanshipɹن཯ɺج४ɺྙཧ (Japanese Edition) Kindle ൛ P335
  20. None
  21. ࢲతͳܦݧᶄ PJ 

  22. ࢲతͳܦݧᶄ PJ ( ) 

  23. ڳΛுͬͯνʔϜͷதʹډΒΕΔ͔ (= ) 胸 

  24. ͲͪΒ΋ٹ͍͍ͨ 胸 

  25. ΍Δ΂͖͜ͱʹऔΓ૊Ή 
 胸 

  26. §2 - -

  27. §2 .1 .2

  28. ΍Γ͍ͨ͜ͱɺͦΕҎ֎ͷ͜ͱ 
 = 
 = 
 

  29. Ձ஋ΛੜΈग़͢ͷʹ࢖͍͑ͯΔ࣌ؒ͸ 49% 21% 38% 27%  [ग़య] 
 ᴷ Nicole

    Forsgren Ph.D.,Jez Humble,Gene Kim,෢ࣷ޿޾, ෢ࣷΔΈ. 
 LeanͱDevOpsͷՊֶ[Accelerate] ςΫϊϩδʔͷઓུత׆༻͕૊৫มֵΛՃ଎͢Δ P63
  30. ιϑτ΢ΣΞ։ൃͷʮ༧ఆ֎ʯͷΠϯύΫτ 21% 21 

  31. §2 .1 .2

  32. ݶΒΕͨ࿑ྗΛ૿΍͢ɾ׆͔͢ 

  33. ΤϥʔͷҰੜ 

  34. ίετͷҰੜ 

  35. ΤϥʔରԠʹ܎Δίετ 

  36. ಛఆ͕Ͱ͖ͯ΋ɾɾ૿͑ଓ͚͍ͯΔίετ , , , , , ( ) 1 ,

    , , , ,  [ग़య] 
 ᴷ Pete McBreen, ଜ্ խষ. 
 XPΤΫετϦʔϜϓϩάϥϛϯάջٙฤʕXP͸ιϑτ΢ΣΞ։ൃͷٹੈओͨΓ͑Δͷ͔ P130
  37. ʮܽؕͷಛఆʯ͕ͦ͜໽հͳ໰୊  [ग़య] 
 ᴷ Weinberg, Gerald M, େ໺ ₼࿠(؂༁).

    ϫΠϯόʔάͷγεςϜࢥߟ๏ P234
  38. ൃݟͷى఺ͷҧ͍ʹΑΔෆܦࡁੑ ( ) 1. 2. / 

  39. ൃݟͷى఺ͷҧ͍ʹΑΔෆܦࡁੑ 1. / (=outside-in) 2. / 

  40. ൃݟͷى఺ͷҧ͍ʹΑΔܦࡁੑ 1. 2. / (=inside-out) 

  41. 

  42. Ͳ͏ͨ͠Βʮ௚͠΍͍͢໰୊ʯʹͰ͖Δ͔ : ( ): : 

  43.  X Z

  44.  X Z • XͰରԠͰ͖Ε͹ɺ 
 ʮ2࣌ؒલͷίʔυͷҙਤʯΛࢥ͍ग़͚ͩ͢ͰࡁΉ 
 (ຊ൪σϏϡʔͨͯ͠ͷίʔυͳͷͰɺඃґଘऀ΋গͳͦ͏) •

    ZͷରԠʹͳΔͱɺ 
 ʮ3ϱ݄લͷίʔυͷҙਤʯΛ֬ೝ͢Δ͜ͱʹ 
 (ͦͷதʹɺܽؕՕॴ΁ͷґଘ΋ؚ·ΕΔ)
  45. ए͍಺ʹժΛఠΉ  [ग़య] 
 ᴷ Steve McConnell, ೔ཱΠϯϑΥϝʔγϣϯΞΧσϛʔ. ϥϐου σϕϩοϓϝϯτ

    P81
  46. §2ͷ·ͱΊ(͍·࿩ͨ͜͠ͱ) 
 

  47. §3 - -

  48. §3 .1 .2 0 .3

  49. ΤϥʔରԠͷ࢓૊Έʹ͍ͭͯʮ੒ख़౓ʯΛߟ͑Δ 
 
 

  50.  
 
 
 
 ( ) ( ) 


  51.  
 


  52. ʮྑ͍ʯΤϥʔରԠͷ࢓૊Έʹ͍ͭͯߟ͑Δ 1. 2. 

  53. 1. Τϥʔ͸ͲͷΑ͏ʹه࿥ɾ؅ཧ͞Ε͍ͯ·͔͢ 1. ( ) 1 =1(orN) =1 2. =1

    
  54. ( ) 

  55. ʮੜϩάཔΓʯͷ໰୊఺ => 

  56. ( ) 

  57. ʮू໿ࡁΈʯͷར఺ ( / ) 縮 ( ) ( ) =>

    
 ( ) 
  58. 2. Τϥʔʹ͸ͲͷΑ͏ʹؾͮ͘͜ͱ͕Ͱ͖·͔͢ : : :  PI͔ΒͷϫϯϙΠϯτΞυόΠεͷίʔφʔ👨🌾 ୅ΘΓʹʮૣ͍ɾ͏·͍ɾ͍҆ʯͰ΋ՄͰ͢ʂ

  59. νʔϜͰʮ޲͖߹͑ʯ͍ͯΔ͔: ੒ख़ʹ޲͚ͯ ( ) 
 => Push Proactive 

  60. §3 .1 .2 0 .3

  61. ͓͞Β͍: ࣌ؒͷܦաͱରԠίετͷؔ܎ 
 = 

  62. ʮγϑτϨϑτʯͱରԠίετͷؔ܎ = ( ) 

  63. ϦϦʔεલʹ༧๷͢Δɺͱ͍ͬͯ΋ɾɾɾ 

  64. ίεύͷྑ͍λΠϛϯάΛߟ͑Δ => => 

  65. ίεύͷྑ͍λΠϛϯάΛߟ͑Δ 結 

  66. ίεύͷྑ͍λΠϛϯάΛߟ͑Δ 
 Just-in-Time 

  67. Τϥʔ͸͍ͭى͜Δͷ͔ 1. : ( ) 2. : 
 ほほ( )

    ✕✕( ) 
  68. ʮൃݟίετʯͱʮӨڹ(ඃ֐)ʯͷόϥϯεΛऔΔ 駄 

  69. ʮ0࣍ରԠʯΛऔΓೖΕΔ = = = 0 ( ) = 1 0

    
  70. ʮ0࣍ରԠʯͷܦࡁੑ ( ) 

  71. ʮ0࣍ରԠʯͷܦࡁੑ 1. 2. 3. 

  72. ʮ0࣍ରԠʯͷϝϦοτᶃ 1. 2. 3. 

  73. ʮ0࣍ରԠʯͷϝϦοτᶄ 1. 2. ( ) 3. 

  74. ʮ0࣍ରԠʯͷϝϦοτᶅ 1. 2. 3. DevOps 

  75. §3 .1 .2 0 .3

  76. ௵͢΂͖Τϥʔͷ؍఺ 2 : 0 1縮 ( ) : 賢 1.

    boolean 2. 
  77. ൃੜͷbooleanͰ͸ͳ͘ɺൃੜස౓Ͱ؂ࢹ͢Δ Duplicate entry for primary key 
 : 
 or

    : 
 1 10,000,000,000,000,000,000,000,000,000 
  78. ΞϓϦҎ֎ͷՕॴɾ؍఺Ͱ؂ࢹ͢Δ 
 outside-in : 
 Http Status Code(404, 502, etc)

    
  79. §3ͷ·ͱΊ(͍·࿩ͨ͜͠ͱ) 0 : 
 

  80. §4 - with Sentry -

  81. §4 .1 Sentry .2 .3 .4 .5

  82. Sentry ( )SaaS ( / ) (β PHP ) 14

    
  83. GUI 

  84. ʲ଎श༻ʳίϨ͚ͩ͸཈͓͑ͯ͘ʂSentryͷجૅ֓೦  ( ) Sentry Event 胸 Event 1 Issue

    Event,Issue Alert
  85. §4 .1 Sentry .2 .3 .4 .5

  86. Πϯετʔϧํ๏ composer require sentry/sentry : SDK HTTP (php-http/async-client- implementation) sentry/sdk:

    HTTP FW : (Symfony/Larevel)  https://github.com/getsentry/sentry-php
  87. ΞΧ΢ϯτͷ࡞੒ͱΞϓϦέʔγϣϯઃఆ Sentry 1. https://sentry.io/signup/ 2. PJ Event 胸 URL(DSN) 

    https://sentry.io/for/php/
  88.  ϚεΫͰ͍͟͝·͢ ϚεΫͰ͍͟͝·͢ ϚεΫͰ͍͟͝·͢

  89. ಥવͷએ఻ʂʂʂʂ connehito/cake-sentry 
 PR Starろ awesome-cakephp 
 Sentry SDK 3rd

    party integrations 💪 
 cake4.4+ Laravel  ίωώτ͞Μͷٻਓ৘ใ΋೷͍ͯΈ͍ͯͩ͘͞ͶʂIUUQTISNPTDPQBHFTDPOOFIJUPKPCT
  90. §4 .1 Sentry .2 .3 .4 .5

  91. ͜͜·ͰͷʮͶΒ͍ʯΛSentry্Ͱ࣮ݱ͢Δ 1. ( ) 0 ( ) 2. ( )

    ( ) 
  92. ͜͜·ͰͷʮͶΒ͍ʯΛSentry্Ͱ࣮ݱ͢Δ 1. ( ) 0 ( ) 2. ( )

    ( ) 
  93. SentryͰ0࣍ରԠΛ࣮ફ͢Δ Alert Alert Create Alert Issues Set Conditions When: A

    new issue is created Then: Send a Slack noti fi cation 
 Slack Integration  Alert Alert
  94. SentryͰ0࣍ରԠΛ࣮ફ͢Δ When: The issue changes state from resolved to unresolved

    Then: Send a Slack noti fi cation 
  95. SentryͰසग़Τϥʔݕ஌Λ࣮ફ͢Δ When: Number of events in an issue is more

    than XXX( ) in XXX( ) Then: Send a Slack noti fi cation 
  96. ิ଍: SentryͰશ͘ѻΘͳ͍Τϥʔʹ͍ͭͯ Resolve Sentry UserNotExistsException Sentry SDK 胸 FW 

    ࢀߟ 
 'JMUFSJOHGPS4ZNGPOZc4FOUSZ%PDVNFOUBUJPO 
 IUUQTEPDTTFOUSZJPQMBUGPSNTQIQHVJEFTTZNGPOZDPO fi HVSBUJPO fi MUFSJOH fi MUFSJOHFSSPSFWFOUT
  97. ิ଍: SentryͰશ͘ѻΘͳ͍Τϥʔʹ͍ͭͯ Sentry 縮 縮 
 ( ) Amazon CloudWatch

    
  98. 
 
 🎉

  99. ͜͜·ͰͷʮͶΒ͍ʯΛSentry্Ͱ࣮ݱ͢Δ 1. ( ) 0 ( ) 2. ( )

    ( ) 
  100. ϋ΢εΩʔϐϯάͷ࣮ફ : 

  101. ϋ΢εΩʔϐϯάͷ࣮ફ 

  102. Issueͷ؅ཧ Issue Resolved Unresolved Issue Resolved : Web UI Slack

    Resolve 
  103. ࣗಈResolveᶃ: ؍࡯ظؒʹΑΔղܾ ( Event ) 
 Resolve Resolve 

  104. ࣗಈResolveᶄ: ϦϦʔεͷ࿈ಈʹΑΔղܾ 胸 胸 (Event) 
 (Resolved -> Regression) The

    next release: The current release: Another existing release: GitHub resolve 
  105. UnresolvedͳIssueͷReview/Reviewed Issue ( ack 踏 ) GitHub Issue tracker ぽ

     Review଴ͪIssueҰཡ ʮReviewࡁΈʯૢ࡞ͱมߋཤྺ
  106. UnresolvedͳIssueͷIgnore Issue (Ignore) Ignore Event 

  107. ͜͜·ͰͷʮͶΒ͍ʯΛSentry্Ͱ࣮ݱ͢Δ 1. ( ) 0 ( ) 2. ( )

    ( ) 
  108. IssueͷAssign Issue / Slack 縮 Issue Assign Alert 

  109. Issue্Ͱͷิ଍ɾίϝϯτ Issue Resolve Regression Issue 

  110. ͦͷଞ(ൃද࣌͸ׂѪʂʂ) Event 駄 駄 ex: POST body Request Context 

  111. §4 .1 Sentry .2 .3 .4 .5

  112. ӡ༻ظʹ޲͚ͯͷਐΊํͷ֓ཁ 1. 2. 3. 4. 

  113. ӡ༻ظʹ޲͚ͯͷਐΊํͷ֓ཁ 1. 2. 3. 4. 

  114. πʔϧΛೖΕ͚ͨͩͰ͸ʮελʔτ஍఺ͷखલʯ 1. ( 1 100 ) 2. 0 3. 縮

    4. Issue 
  115. πʔϧΛೖΕ͚ͨͩͰ͸ʮελʔτ஍఺ͷखલʯ 1. ( 1 100 ) 2. 0 3. 縮

    4. Issue 
  116. πʔϧΛೖΕ͚ͨͩͰ͸ʮελʔτ஍఺ͷखલʯ 1. ( 1 100 ) 2. 0 3. 4.

    Issue 
  117. πʔϧΛೖΕ͚ͨͩͰ͸ʮελʔτ஍఺ͷखલʯ 1. ( 1 100 ) 2. 0 3. 縮

    4. Issue 
  118. ӡ༻ظʹ޲͚ͯͷਐΊํͷ֓ཁ 1. 2. 3. 4. 

  119. ελʔτʹཱͱ͏: ݱঢ়ͷೝࣝͱ໨ඪͷઃఆ (1 1 etc) 

  120. ͲͷఆྔࢦඪΛ༻͍Δ͔ 2 1. 2. 

  121. Ϣʔβʔ΁ͷΠϯύΫτͷ؍఺ Sentry 1. Event ( ) 2. Event (Web )

    
  122. ιϑτ΢ΣΞͷ඼࣭ͷ؍఺ Sentry 1. Event 2. Event Issue 3. Issue 4.

    Unresolved Issue 5. Resolve Issue 6. Issue resolved 
  123. ݸਓతͳΦεεϝ 0 
 Unresolved Issue ( ) Open Resolve 


    
  124. ि͋ͨΓͷUnresolvedঢ়ଶͷIssue਺ cons 
 ( ) Event 1 1 

  125. ि͋ͨΓͷUnresolvedঢ়ଶͷIssue਺ pros 0 
 ( ) 

  126. ఆྔࢦඪͷऔಘɾ؂ࢹํ๏ Discover, Dashboard 
 https://docs.sentry.io/product/ dashboards/ API 
 https://docs.sentry.io/api/ events/

     SandboxΞΧ΢ϯτͰͷμογϡϘʔυͷྫ
  127. Wedding Park https://speakerdeck.com/kazatohiei/phperkaigi2022 https://engineers.weddingpark.co.jp/sentry/ 

  128. ӡ༻ظʹ޲͚ͯͷਐΊํͷ֓ཁ 1. 2. 3. 4. 

  129. طଘΤϥʔͷղফͷ։࢝ 1. : 2. : 

  130. طଘΤϥʔͷղফͷ։࢝ 1. : For Review 0縮 ( ) 2. :

    
  131. طଘΤϥʔͷղফͷ։࢝ 1. : 2. : 1 OKR ぽ 
 Key

    Result 1 
  132. §4 .1 Sentry .2 .3 .4 .5

  133. ͓͞Β͍: ݸਓతʹେࣄʹ͍ͯ͠Δ͜ͱ 1. 胸 2. 

  134. ͓͞Β͍: ݸਓతʹେࣄʹ͍ͯ͠Δ͜ͱ 1. 胸 2.  


  135. ͓͞Β͍: ݸਓతʹେࣄʹ͍ͯ͠Δ͜ͱ 1. 胸 2. 

  136. ໌೔͔Β࢝ΊΒΕΔͷ͔ ( ) 
 
 

  137. (ͨͿΜ)͍͘Βڧௐͯ͠΋ɺ͠଍Γͳ͍ίτ 
 

  138. (ͨͿΜ)͍͘Βڧௐͯ͠΋ɺ͠଍Γͳ͍ίτ 
 
 

  139. ڳΛுͬͯνʔϜͷதʹډ͍ͨ 

  140. ڳΛுͬͯνʔϜͷதʹډ͍ͨ 
 

  141. ໌೔͔ΒԿΛ࢝ΊΒΕΔͷ͔ 
 

  142. Ͳ͏΍ͬͯมԽΛଅ͔͢ 

  143. Ͳ͏΍ͬͯมԽΛଅ͔͢ BBQ 

  144. ྑ͍มԽ͸ྑ͍ఉ͔Β࢝·Δ ( ) 1. 2. 3. 

  145. ྑ͍มԽ͸ྑ͍ఉ͔Β࢝·Δ 1. 胸 2. 3. 

  146. ྑ͍มԽ͸ྑ͍ఉ͔Β࢝·Δ 1. 2. Sentry 3. 

  147. ྑ͍มԽ͸ྑ͍ఉ͔Β࢝·Δ 1. 2. 3. 0 Sentry (Resolve, Mark Reviewed )

    
  148. §5

  149. Τϥʔͱ޲͖߹͍ɺࣗ৴Λ࣋ͬͯ αʔϏε։ൃʹऔΓ૊ΈɺલʹਐΉ Sentry 

  150. ͓͠·͍ʂ ͓෇͖߹͍͍͖ͨͩ 
 ͋Γ͕ͱ͏͍͟͝·ͨ͠

  151. §X Appendix

  152. ࢀߟॻ੶ɾҾ༻ͨ͠ॻ੶ Clean Craftsmanship (Japanese Edition) E ff ective DevOps 4

    Fearless Change 48 Google ITIL ITIL Leading Beyond Change: A Practical Guide to Evolving Business Agility Lean DevOps [Accelerate] Observability Engineering: Achieving Production Excellence XP XP : ―― ( ) DevOps 9 ( 3 ) 9  ޒेԻॱ
  153. Web্ͷࢀߟϦιʔε / Sentry͕ఏڙ͍ͯ͠ΔϦιʔε Product Guides | Sentry Documentation 
 https://docs.sentry.io/product/

    API Reference | Sentry Documentation 
 https://docs.sentry.io/api/ Spend Less Time on Bugs & More Time on Features: Sentry + Sleuth | Sentry 
 https://sentry.io/resources/improve-and-automate-your-work fl ow/ Automate, Group, and Get Alerted: A Best Practices Guide to Monitoring your Code | Sentry 
 https://sentry.io/resources/automate-group-get-alerted/ Sentry - YouTube ろ 
 https://www.youtube.com/c/Sentry-monitoring 
  154. Web্ͷࢀߟϦιʔε / Sentryͷಋೖɾ׆༻ࣄྫ / PHPerKaigi2022 - Speaker Deck 
 https://speakerdeck.com/kazatohiei/phperkaigi2022

    Sentry | Wedding Park CREATORS Blog 
 https://engineers.weddingpark.co.jp/sentry/ Raygun Sentry - BASE 
 https://devblog.thebase.in/entry/raygun2sentry - 
 https://daisuki.nichiyoubi.land/entry/2020/07/01/ 123616#%E3%81%AA%E3%81%9C%E3%82%84%E3%82%8B%E3%81%AE%E3%81%8B 
  155. Web্ͷࢀߟϦιʔε / DevOpsɺϞχλϦϯά Monitoring Check Smells 
 https://benjiweber.co.uk/blog/2015/03/02/monitoring-check-smells/ 5 2020

    (1/2) CodeZine 
 https://codezine.jp/article/detail/12052 
 https://www.youtube.com/watch?v=9RPgdJyeA7Y&t=4784s State of DevOps Four Keys ( ) / Introduction to State of DevOps and Four Keys for Visualizing Productivity in Development Organizations expanded and revised edition - Speaker Deck 
 https://speakerdeck.com/isanasan/introduction-to-state-of-devops-and-four-keys-for-visualizing- productivity-in-development-organizations-expanded-and-revised-edition 
  156. Web্ͷࢀߟϦιʔε / ඼࣭ɾอकɾ༧๷ 
 https://blogs.itmedia.co.jp/morisaki/2012/04/post-7e5d.html - Cybozu Inside Out |

    
 https://blog.cybozu.io/entry/2016/05/18/103000 - / Growing Reliable Code PHPerKaigi 2022 - Speaker Deck 
 https://speakerdeck.com/twada/growing-reliable-code-phperkaigi-2022 / Agility and Quality Characteristics Developers Summit 2021 Summer - Speaker Deck 
 https://speakerdeck.com/twada/agility-and-quality-characteristics-developers-summit-2021-summer - pixiv inside 
 https://inside.pixiv.blog/shimashima/6247 
  157. Web্ͷࢀߟϦιʔε / ͦͷଞ(จԽɺ૊৫ͳͲ) I - 
 https://daisuki.nichiyoubi.land/entry/2021/12/11/182323 #scrumosaka / Scrum

    Fest Osaka 2021 Keynote - Speaker Deck 
 https://speakerdeck.com/bu ff erings/scrum-fest-osaka-2021-keynote / The Debt - Speaker Deck https:// speakerdeck.com/toricls/the-debt / You won't be in the team forever - Speaker Deck 
 https://speakerdeck.com/toricls/you-wont-be-in-the-team-forever