- 重要な情報
- はじめに
- 用語集
- ガイド
- エージェント
- インテグレーション
- OpenTelemetry
- 開発者
- API
- CoScreen
- アプリ内
- Service Management
- インフラストラクチャー
- アプリケーションパフォーマンス
- 継続的インテグレーション
- ログ管理
- セキュリティ
- UX モニタリング
- 管理
Supported OS
Datadog のメトリクス、APM、ログを使用して、OpenAI Python ライブラリのリクエストから、コストの見積もり、プロンプトとコンプリーションのサンプリング、エラー追跡、パフォーマンスメトリクスなどを取得します。
docker run -d --cgroupns host \
--pid host \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /proc/:/host/proc/:ro \
-v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
-e DD_API_KEY=<DATADOG_API_KEY> \
-p 127.0.0.1:8126:8126/tcp \
-p 127.0.0.1:8125:8125/udp \
-e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true \
-e DD_APM_ENABLED=true \
gcr.io/datadoghq/agent:latest
pip install ddtrace>=1.13
ddtrace-run
のプレフィックスを付けます。DD_SERVICE="my-service" DD_ENV="staging" DD_API_KEY=<DATADOG_API_KEY> ddtrace-run python <your-app>.py
注: Agent がデフォルト以外のホスト名やポートを使用している場合、DD_AGENT_HOST
、DD_TRACE_AGENT_PORT
、DD_DOGSTATSD_PORT
も必ず設定してください。
より高度な使い方については、APM Python ライブラリドキュメントを参照してください。
利用可能なすべての構成オプションについては、APM Python ライブラリドキュメントを参照してください。
ログのプロンプトとコンプリーションサンプリングを有効にするには、環境変数 DD_OPENAI_LOGS_ENABLED=1
を設定します。デフォルトでは、トレースされたリクエストの 10% がプロンプトとコンプリーションを含むログを出力します。
ログのサンプルレートを調整するには、APM ライブラリのドキュメントを参照してください。
注: ログを送信するには、ddtrace-run
を実行する際に DD_API_KEY
を指定する必要があります。
APM Python ライブラリを使用して Agent と通信できることを確認します。
ddtrace-run --info
次の出力が表示されるはずです。
Agent error: None
ddtrace-run
に --debug
フラグを渡すと、デバッグロギングが有効になります。
ddtrace-run --debug
データ送信時のエラーを表示します。
ERROR:ddtrace.internal.writer.writer:failed to send, dropping 1 traces to intake at http://localhost:8126/v0.5/traces after 3 retries ([Errno 61] Connection refused)
WARNING:ddtrace.vendor.dogstatsd:Error submitting packet: [Errno 61] Connection refused, dropping the packet and closing the socket
DEBUG:ddtrace.contrib.openai._logging.py:sent 2 logs to 'http-intake.logs.datadoghq.com'
openai.request.duration (gauge) | Request duration distribution. Shown as nanosecond |
openai.tokens.prompt (gauge) | Number of tokens used in the prompt of a request to OpenAI. Shown as token |
openai.tokens.completion (gauge) | Number of tokens used in the completion of a response from OpenAI. Shown as token |
openai.tokens.total (gauge) | Total number of tokens used in a request to OpenAI. Shown as token |
openai.request.error (count) | Number of errors. Shown as error |
openai.organization.ratelimit.requests.remaining (gauge) | Number of requests remaining in the rate limit. Shown as request |
openai.organization.ratelimit.tokens.remaining (gauge) | Number of tokens remaining in the rate limit. Shown as token |
openai.ratelimit.requests (gauge) | Number of requests in the rate limit. Shown as request |
openai.ratelimit.tokens (gauge) | Number of tokens in the rate limit. Shown as token |
openai.api.usage.n_requests (count) | Total number of requests Shown as request |
openai.api.usage.n_context (count) | Number of context tokens used Shown as token |
openai.api.usage.n_context_tokens_total (gauge) | Total number of context tokens used (all-time) Shown as token |
openai.api.usage.n_generated (count) | Number of generated response tokens Shown as token |
openai.api.usage.n_generated_tokens_total (gauge) | Total number of generated response tokens (all-time) Shown as token |
OpenAI インテグレーションには、イベントは含まれません。
OpenAI インテグレーションには、サービスのチェック機能は含まれません。
ご不明な点は、Datadog のサポートチームまでお問合せください。
お役に立つドキュメント、リンクや記事: