Slide 1

Slide 1 text

© 2024 Wantedly, Inc. ࢄΒ͹ͬͨτϨʔεΛܨ͛Δٕज़ ΏΔSREษڧձ #8 LT Nov. 29 - Kazuki Obata / @donkomura_

Slide 2

Slide 2 text

© 2024 Wantedly, Inc. ࿩͍ͨ͜͠ͱ - ΦϒβʔόϏϦςΟͷߏ੒ཁૉʮτϨʔεʯ - όϥόϥʹͳͬͯ͠·͏ͱࠔΔ - ໰୊ͱͳΔՕॴɾϙΠϯτΛղઆ - εύϯΛܨ͛ͯτϨʔεʹ͢Δํ๏Λ঺հ - ίʔυϕʔεͰղઆ - ֶͼ

Slide 3

Slide 3 text

© 2024 Wantedly, Inc. APM ͰτϨʔεܨ͕Βͳ͍... - ىͬͨ͜͜ͱ - OpenCensus ͱ dd-trace ͷτϨʔε͕όϥόϥ - ܭ૷ͨ͠τϨʔεͱ Redis ͷτϨʔε͕όϥόϥ - ༗ޮͳ৘ใ͕ͺͬͱݟΕͳ͍☹ - Ͳ͕͜໰୊͔ɺϘτϧωοΫʹͳ͍ͬͯΔ͔Ұ໨Ͱ෼͔Βͳ͍ - εύϯ͕όϥόϥͰௐࠪͮ͠Β͍ https://docs.datadoghq.com/ja/tracing/glossary/

Slide 4

Slide 4 text

© 2024 Wantedly, Inc. ղܾࡦ τϨʔείϯςΩετΛ఻೻͢Δ

Slide 5

Slide 5 text

© 2024 Wantedly, Inc. τϨʔείϯςΩετΛ఻೻͢Δ - τϨʔείϯςΩετͱ͸ - τϨʔεIDɾεύϯIDɾ਌εύϯID Λ࣋ͬͨσʔλߏ଄ - ಉ͡τϨʔείϯςΩετ͔Βੜ੒͞Εͨεύϯ͸ಉ͡τϨʔεʹଐ͢Δ - ਌ࢠؔ܎΋ҡ࣋͞ΕΔ - ໰୊ͷݪҼ - TraceIDͷϑΥʔϚοτ͕ҟͳΔ - τϨʔείϯςΩετΛඞཁͳՕॴͰ࢖͍͑ͯͳ͍ - ผʑͷτϨʔείϯςΩετΛ࢖͍ͬͯͨ

Slide 6

Slide 6 text

© 2024 Wantedly, Inc. ͭͳ͛ํ 1. OpenCensus ͱ ddtrace ͷτϨʔεΛܨ͛Δ Go (dd-trace-go) ͷྫ // ϑΥʔϚοτΛ੔͑Δ carrier := tracer.TextMapCarrier{ tracer.DefaultTraceIDHeader: strconv.FormatUint(binary.BigEndian.Uint64(traceID[8:]), 10), tracer.DefaultParentIDHeader: strconv.FormatUint(binary.BigEndian.Uint64(spanID[:]), 10), } // ίϯςΩετͷੜ੒ sctx, _ := tracer.Extract(carrier) // εύϯͷੜ੒ span, ctx := tracer.StartSpanFromContext(ctx, "op1", tracer.ChildOf(sctx)) // ctx Λ࢖ͬͯଞͷεύϯΛੜ੒ span, ctx := tracer.StartSpanFromContext(ctx, "op2", tracer.ChildOf(sctx))

Slide 7

Slide 7 text

© 2024 Wantedly, Inc. ͭͳ͛ํ 2. Redis ͷτϨʔεΛܨ͛Δ Redigo ͷྫ // Redis ΫϥΠΞϯτͷ Wrapper Λ࢖͏ pool := &redis.Pool{ Dial: func() (redis.Conn, error) { return redigotrace.Dial("tcp", "127.0.0.1:6379", redigotrace.WithServiceName("my-redis-backend"), ) }, } // ίϯςΩετΛ࢖͍ճ͢ c.Do("SET", "food", "cheese", ctx) https://pkg.go.dev/gopkg.in/DataDog/[email protected]/contrib/gomodule/redigo

Slide 8

Slide 8 text

© 2024 Wantedly, Inc. ·ͱΊ - ཁ͢ΔʹτϨʔείϯςΩετΛ࢖͍·Θͤ͹ྑ͍ - ಉ͡τϨʔεIDΛ࢖͏ - εύϯͷ਌ࢠؔ܎ - ܨ͕ͬͯͳ͍ͱ͖͸τϨʔεIDΛ֬ೝ - τϨʔεID͕ҟͳ͍ͬͯͳ͍͔ - e.g. ϑΥʔϚοτ͕ҧ͏ɺencode/decode ͕ؒҧ͍ͬͯΔ - τϨʔείϯςΩετͷ఻೻͕Ͱ͖͍ͯΔ͔ - e.g. ctx ͷ౉͍ͯ͠ͳ͍ɺ࢖͍ͬͯͳ͍ ࢄΒ͹ͬͨτϨʔεΛܨ͛Δ