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

문제 신고

accept_distributed_trace_headers(Python 에이전트 API)

통사론

newrelic.agent.accept_distributed_trace_headers(headers, transport_type='HTTP')

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

요구 사항

Python 에이전트 버전 5.6.0.135 이상.

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

설명

이 호출을 사용하는 방법에 대한 컨텍스트를 보려면 먼저 파트너 API 호출insert_distributed_trace_headers에이전트 API로 분산 추적 사용을 읽으십시오.

이 호출은insert_distributed_trace_headers 에 의해 생성된 분산 추적 헤더를 구문 분석하여 트랜잭션을 연결하는 데 사용됩니다.

매개변수

매개변수

설명

headers

사전 또는 목록

필수의. 수락할 헤더입니다. (header_name, header_value)의 iterable 또는 사전으로 제공될 수 있습니다.

transport_type

선택사항, 기본값은 HTTP 입니다. 이 페이로드를 보낸 전송 유형입니다. HTTP , HTTPS , Kafka , JMS , IronMQ , AMQP , Queue 또는 Other 중 하나여야 합니다.

반환 값

성공하면 True 을 반환합니다.

실패하면 False 을 반환합니다. 페이로드 수락은 다음과 같은 몇 가지 이유로 실패할 수 있습니다.

  • 현재 거래가 활성화되어 있지 않습니다.
  • Accept가 트랜잭션 범위 밖에서 호출되었습니다.
  • 페이로드가 비어 있습니다.
  • 분산 추적을 사용할 수 없습니다.
  • accept_distributed_trace_* 페이로드가 생성된 후에 호출되었으며 이전에는 호출되지 않았습니다.
  • accept_distributed_trace_* 단일 트랜잭션에서 여러 번 호출되었습니다.
  • 페이로드를 구문 분석할 수 없습니다.
  • 페이로드가 신뢰할 수 없는 계정에서 전송되었습니다.

백그라운드 작업 내 분산 추적 페이로드 수락

백그라운드 작업에서 accept_distributed_trace_payload 을 사용하는 예:

@newrelic.agent.background_task()
def handle(request):
newrelic.agent.accept_distributed_trace_headers(request.headers)
_do_some_work()

대기열에서 소비

accept_distributed_trace_payload 을 사용하고 각 메시지에 대한 백그라운드 작업 을 만드는 예:

import newrelic.agent
newrelic.agent.initialize('newrelic.ini')
application = newrelic.agent.register_application(timeout=10.0)
def main(queue):
for message in queue.consume():
with newrelic.agent.BackgroundTask(application, 'Queue Consume'):
newrelic.agent.accept_distributed_trace_headers(message.headers,
transport_type='Queue')
_process_message(message)
Copyright © 2024 New Relic Inc.

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