• EnglishEspañol日本語한국어Português
  • ログイン今すぐ開始

この機械翻訳は、参考として提供されています。

In the event of any inconsistency between the English version and the translated version, the English versionwill take priority. Please visit this page for more information.

問題を作成する

Goアプリにブラウザ監視機能を追加

アプリに New Relic の Go エージェントをインストールした場合は、以下を使用することもできます。 ブラウザのパフォーマンスを監視します。ブラウザ エージェントをインストールするには、 コピー アンド ペーストの方法を使用するか、Go エージェント API を使用します。

GoエージェントブラウザAPIによるインストール

ブラウザ モニタリングのサポートを有効にするには、ブラウザ エージェントをロードして正しいアプリケーション名で設定する JavaScript スニペットを HTML ページに含める必要があります。このスニペットはTransaction.BrowserTimingHeaderメソッドで利用できます。ブラウザー監視のタイミング ヘッダーのサポートは、 Go エージェント バージョン 2.5.0 以降で利用できます。

Transaction.BrowserTimingHeader().WithTags()によって返されるバイト スライスを、HTML の<head>セクションのできるだけ早い段階で、 <meta charset>タグの後に含めます。

Transaction.BrowserTimingHeaderから返される JavaScript はリクエスト固有です。そのため、リクエストごとに呼び出す必要があります。

func indexHandler(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "<html><head>")
// The New Relic browser javascript should be placed as high in the
// HTML as possible. We suggest including it immediately after the
// opening <head> tag and any <meta charset> tags.
txn := newrelic.FromContext(req.Context())
hdr := txn.BrowserTimingHeader()
// BrowserTimingHeader() will always return a header whose methods can
// be safely called.
if js := hdr.WithTags(); js != nil {
w.Write(js)
}
io.WriteString(w, "</head><body>browser header page</body></html>")
}
Copyright © 2024 New Relic株式会社。

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.