• EnglishEspañol日本語한국어Português
  • 로그인지금 시작하기

이 한글 문서는 사용자의 편의를 위해 기계 번역되었습니다.

영문본과 번역본이 일치하지 않는 경우 영문본이 우선합니다. 보다 자세한 내용은 이 페이지를 방문하시기 바랍니다.

문제 신고

insert_distributed_trace_headers(Python 에이전트 API)

통사론

newrelic.agent.insert_distributed_trace_headers(list_of_headers)

이 방법은 분산 추적 내에서 트랜잭션을 연결하는 데 사용되는 헤더를 삽입하는 데 사용됩니다.

요구 사항

Python 에이전트 버전 5.6.0.135 이상.

분산 추적을 활성화 해야 합니다.

설명

이 API를 사용하려면 분산 추적을 사용하도록 설정 해야 합니다.

파트너 호출accept_distributed_trace_headers 과 함께 이 호출을 사용하는 방법에 대한 지침은 에이전트 API로 분산 추적 사용 을 참조하십시오.

이 호출은 분산 추적을 구현하는 데 사용됩니다. accept_distributed_trace_headers 메소드를 사용하여 수신 애플리케이션에서 읽을 수 있는 목록에 헤더를 삽입합니다.

매개변수

매개변수

설명

headers

목록

필수의. 헤더 목록입니다. 이 목록은 호출에 의해 변경됩니다(헤더는 (header_name, header_value)형식으로 목록에 삽입됨).

반환 값

None 를 반환합니다. 이 함수를 호출하면 입력 목록이 업데이트됩니다.

중요

추적에서 범위의 적절한 순서를 유지하려면 페이로드를 보내는 범위의 컨텍스트에서 페이로드를 생성해야 합니다.

백그라운드 작업 내에서 분산 추적 페이로드 만들기

단일 백그라운드 작업 내에서 외부 추적 을 생성할 때 insert_distributed_trace_headers 을 사용하는 예:

@newrelic.agent.background_task()
def main(url):
with newrelic.agent.ExternalTrace('my_external_library', url, method='GET'):
# Generate the payload in the context of the ExternalTrace
# span that sends it
headers = []
newrelic.agent.insert_distributed_trace_headers(headers)
response = my_external_library._get(url, headers=headers)
data = _process_response(response)

외부 추적 내부에 분산 추적 페이로드 만들기

외부 추적 을 생성할 때 insert_distributed_trace_headers 을 사용하는 예:

def _bind_url(url, *args, **kwargs):
# _bind_url is called with the args and kwargs sent to the `get`
# method below
return url
@newrelic.agent.external_trace('my_external_library', _bind_url, method='GET')
def get(url):
headers = []
newrelic.agent.insert_distributed_trace_headers(headers)
return my_external_library._get(url, headers=headers)
Copyright © 2024 New Relic Inc.

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