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

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

英語版と翻訳版に矛盾がある場合は、英語版が優先されます。詳細については、このページを参照してください。

問題を作成する

測定

構文

newrelic.measure(name: string, options?: Object<{ customAttributes?: Object, start?: number|PerformanceMark, end?: number|PerformanceMark }>)

ブラウザの BrowserPerformance イベントを報告します。

要件

説明

このAPIコールは、ユーザーが定義した名前とカスタム アトリビュートを含むブラウザBrowserPerformanceイベントを送信します。 これは、代替手段として、または自動マークおよび測定追跡と並行してイベントを手動で作成する場合に便利です。

パラメーター

パラメータ

説明

$name

ストリング

必須。タスクの名前またはカテゴリ。entryName属性として報告されます。

予約したNRQLの単語 を属性や値の名前に使うのは避けましょう。

$options

JSONオブジェクト

オプション。キャプチャしたイベントの設定を提供するために使用されるオブジェクト。 オブジェクト内のすべての属性はオプションです。options.customAttributes 、指定された属性ごとに作成されたイベントに最上位のプロパティと値を割り当てる、キー:値のペアのオブジェクトです。options.start 、開始時間として参照される、起点時間からミリ秒の浮動小数点値、または有効なPerformanceMarkオブジェクトのいずれかになります。options.start 、起点時刻から終了時刻として参照されるミリ秒の浮動小数点値、または有効なPerformanceMarkオブジェクトのいずれかになります。

options.startが定義されていない場合はデフォルトで0になります。options.endが定義されていない場合はデフォルトでperformance.now()になります。

カスタムアトリビュートでは、 NRQLの予約語を使用しないでください。

戻り値

このメソッドは、測定の詳細を含む JSON オブジェクトを返します。 startは開始時刻です。endは終了時刻です。duration開始から終了までの測定の長さです。customAttributesは、メジャーAPIコールに渡されるカスタム アトリビュートです。 返されたカスタムアトリビュート はユーザー定義のカスタムアトリビュートとマージされませんが、 BrowserPerformanceイベントの作成時にマージされます。

最小限の例

const myTask = newrelic.measure('checkout')
/** myTask **/
{
start: 0, // page origin time was used since start was not supplied
end: 1234, // performance.now() was used since end was not supplied
duration: 1234, // end - start
customAttributes: { } // no custom attributes were supplied
}
/** the browser agent buffers and later harvests the newly created BrowserPerformance event **/

開始時刻および/または終了時刻に数値引数を使用する

const myTask = newrelic.measure('checkout', {
start: 1234,
end: 5678
})
/** myTask **/
{
start: 1234, // options.start time was used directly
end: 5678, // options.end time was used directly
duration: 4444, // end - start
customAttributes: { } // no custom attributes were supplied
}
/** the browser agent buffers and later harvests the newly created BrowserPerformance event **/

PerformanceMark引数の使用

const startMark = performance.mark('my-start-mark') // startTime = 1234
// later
const endMark = performance.mark('my-end-mark') // startTime = 5678
const myTask = newrelic.measure('checkout', {
start: startMark,
end: endMark
})
/** myTask **/
{
start: 1234, // options.start.startTime was used since it was a BrowserPerformance entry
end: 5678, // options.end.startTime was used since it was a BrowserPerformance entry
duration: 4444, // end - start
customAttributes: { } // no custom attributes were supplied
}
/** the browser agent buffers and later harvests the newly created BrowserPerformance event **/

混合引数タイプ

const startMark = performance.mark('my-start-mark') // startTime = 1234
const myTask = newrelic.measure('checkout', {
start: startMark,
end: 5678
})
/** myTask **/
{
start: 1234, // options.start.startTime was used since it was a BrowserPerformance entry
end: 5678, // options.end time was used directly
duration: 4444, // end - start
customAttributes: { } // no custom attributes were supplied
}
/** the browser agent buffers and later harvests the newly created BrowserPerformance event **/

カスタム属性の使用

const myTask = newrelic.measure('checkout', {
start: 1234,
end: 5678,
customAttributes: {
foo: 'bar'
}
})
/** myTask **/
{
start: 1234, // options.start time was used directly
end: 5678, // options.end time was used directly
duration: 4444, // end - start
customAttributes: {
foo: 'bar'
}
}
/** the browser agent buffers and later harvests the newly created BrowserPerformance event **/
Copyright © 2026 New Relic株式会社。

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