통사론
newrelic.measure(name: string, options?: Object<{ customAttributes?: Object, start?: number|PerformanceMark, end?: number|PerformanceMark }>)브라우저 BrowserPerformance 이벤트를 보고합니다.
요구 사항
브라우저 Pro 또는 Pro+SPA 에이전트(v1.291 이상)
npm을 통해 수분 에이전트를 설치하고 선택한 기능으로 사용자 정의 에이전트를 구축하는 경우,
Agent를 생성할 때generic_events기능을 활성화해야 합니다.features에 다음을 추가하세요.import { GenericEvents } from '@newrelic/browser-agent/features/generic_events';const options = {info: { ... },loader_config: { ... },init: { ... },features: [GenericEvents]}자세한 내용은 npm 브라우저 설치 설명서를 참조하세요.
설명
이 API 호출은 사용자가 정의한 이름과 사용자 정의 속성이 포함된 브라우저 BrowserPerformance 이벤트를 보냅니다. 이 기능은 대안으로 이벤트를 수동으로 생성하거나 자동 마크 및 측정 추적과 함께 사용하는 데 유용합니다.
매개변수
매개변수 | 설명 |
|---|---|
끈 | 필수의. 작업의 이름 또는 범주. 속성이나 값의 이름을 지정할 때 예약된 NRQL 단어 를 사용하지 마십시오. |
JSON 객체 | 선택 과목. 캡처된 이벤트에 대한 설정을 제공하는 데 사용되는 개체입니다. 객체의 모든 속성은 선택 사항입니다.
사용자 정의 속성에 예약된 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// laterconst endMark = performance.mark('my-end-mark') // startTime = 5678const 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 = 1234const 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 **/