• 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.

문제 신고

add_custom_attribute(파이썬 에이전트 API)

통사론

newrelic.agent.add_custom_attribute(key, value)

트랜잭션에 사용자 정의 속성을 추가합니다.

설명

이 호출은 사용자 정의 속성 ( 트랜잭션 에 연결된 키/값 쌍)을 기록합니다.

트랜잭션이 오류와 연관되거나 해당 트랜잭션에 대해 트랜잭션 추적이 생성되는 경우 속성을 APM에서 찾을 수 있습니다. 속성은 New Relic UI에서도 찾고 쿼리할 수 있습니다.

중요

맞춤 속성을 만들기 전에 NRQL에서 사용하는 예약 용어 목록을 검토하세요.

속성

기인하다

설명

key

필수의. 키 이름입니다. 처음 255자만 유지됩니다.

value

문자열, 정수, 부동소수점, 부울

필수의. 현재 트랜잭션에 추가할 문자열 값입니다. 처음 255자만 유지됩니다.

반환 값

속성이 성공적으로 추가된 경우 True 을 반환합니다.

백그라운드 작업에 사용자 정의 속성 추가

백그라운드 작업 에 사용자 정의 속성을 추가하는 예:

@newrelic.agent.background_task()
def send_request():
response = requests.post('http://URL_path', headers=headers, data=data)
newrelic.agent.add_custom_attribute('url_path_status_code', response.status_code)

사용자 정의 속성을 사용하여 문제 해결

사용자 정의 속성을 사용하여 성능 문제를 해결할 수도 있습니다. 예를 들어 Memcache 인스턴스 풀에서 때때로 느린 응답 시간을 볼 수 있지만 어떤 인스턴스가 문제를 일으키는지 알 수 없습니다. 다음과 같이 서버를 나타내는 트랜잭션에 속성을 추가할 수 있습니다.

# Set server_ip to be the current server processing the transaction
newrelic.agent.add_custom_attribute("memcache_query_frontend_lookup", server_ip)
Copyright © 2024 New Relic Inc.

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