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

OpenTelemetryで分散型アプリケーション の処理フローを可視化する

Avatar for Hank Ehly Hank Ehly
September 05, 2022

OpenTelemetryで分散型アプリケーション の処理フローを可視化する

Avatar for Hank Ehly

Hank Ehly

September 05, 2022
Tweet

More Decks by Hank Ehly

Other Decks in Technology

Transcript

  1. • Hank Ehly (ハンク イーリー) • ENECHANGE株式会社 • qiita.com/hankehly •

    github.com/hankehly • connpass.com/user/hankehly • New: Meety (カジュアル面談) 自己紹介
  2. X-Ray OpenTelemetryとは Collector Datadog Prometheus Jaeger ECS Cluster Lambda 1

    分散型アプリケーション Lambda 2 可視化/保存 収集/転送 DynamoDB
  3. フォーム送信(ブラウザー) 時間 トレースとは POST /api/tasks GET /firebase/auth Task.objects.create (Python) INSERT

    INTO tasks … (SQL) • 何が、どの順番で行われ、どのくらい時間かかったかが分かる • ボタン押下、HTTPリクエスト、Python関数実行、DBからレコード取得…
  4. { "name": "Example Trace", "context": { "trace_id": "0x5b8aa5a2d2c872e8321cf37308d69df2", "span_id": "0x5fb397be34d26b51",

    }, "start_time": "2022-04-29T18:52:58.114304Z", "end_time": "2022-04-29T18:52:58.114435Z", "events": [ { "name": "フォーム送信(ブラウザー)", "timestamp": "2022-04-29T18:52:58.114561Z" }, { "name": "POST /api/tasks", "timestamp": "2022-04-29T18:53:00.012345Z" }, { "name": "GET /firebase/auth", "timestamp": "2022-04-29T18:53:01.012345Z" } ... 処理フロー
  5. import os import sys def main(): os.environ.setdefault("DJANGO_SETTINGS_MODULE", "instrumentation_example.settings") try: from

    django.core.management import execute_from_command_line except ImportError as exc: ...
  6. import os import sys +from opentelemetry.instrumentation.django import DjangoInstrumentor                   def main():

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "instrumentation_example.settings") + DjangoInstrumentor().instrument()                                     try: from django.core.management import execute_from_command_line except ImportError as exc: ... 自動インストルメンテーション (モンキーパッチ)
  7. import os import sys +from opentelemetry.instrumentation.django import DjangoInstrumentor                   +from opentelemetry.instrumentation.botocore

    import BotocoreInstrumentor                 def main(): os.environ.setdefault("DJANGO_SETTINGS_MODULE", "instrumentation_example.settings") + DjangoInstrumentor().instrument()                                     + BotocoreInstrumentor().instrument()                                    try: from django.core.management import execute_from_command_line except ImportError as exc: ...
  8. import os import sys +from opentelemetry.instrumentation.django import DjangoInstrumentor                   +from opentelemetry.instrumentation.botocore

    import BotocoreInstrumentor                 +from opentelemetry.instrumentation.redis import RedisInstrumentor                 def main(): os.environ.setdefault("DJANGO_SETTINGS_MODULE", "instrumentation_example.settings") + DjangoInstrumentor().instrument()                                     + BotocoreInstrumentor().instrument()                                    + RedisInstrumentor().instrument()                                     try: from django.core.management import execute_from_command_line except ImportError as exc: ...