TraceCapture 정책

이 페이지는 ApigeeApigee Hybrid에 적용됩니다.

Apigee Edge 문서 보기

정책 아이콘

개요

TraceCapture 정책을 사용하면 Apigee 런타임의 trace 데이터에 추가 변수를 추가할 수 있습니다. Apigee 런타임에 대해 분산 trace를 사용 설정했으면 기본적으로 런타임이 사전 정의된 변수 집합을 trace합니다. 자세한 내용은 trace 보고서의 기본 trace 변수를 참조하세요. 하지만 Apigee 런타임이 추가 흐름, 정책, 커스텀 변수를 trace하도록 하려면 TraceCapture 정책을 사용합니다. 이 정책은 요청 또는 응답 흐름에서 사용할 수 있습니다. 분산 추적 보고서에서는 TraceCaptureExecution 스팬에서 TraceCapture 정책으로 추가된 변수를 볼 수 있습니다.

이 정책은 확장 가능한 정책이며, 이 정책을 사용하면 Apigee 라이선스에 따라 비용 또는 사용률이 영향을 받을 수 있습니다. 정책 유형 및 사용 영향에 대한 자세한 내용은 정책 유형을 참조하세요.

<TraceCapture>

TraceCapture 정책을 정의합니다.

기본값 해당 사항 없음
필수 여부 필수
유형 복합 유형
상위 요소 해당 사항 없음
하위 요소 <DisplayName>
<IgnoreUnresolvedVariables>
<ThrowExceptionOnLimit>
<Variables>

<TraceCapture> 요소는 다음 문법을 사용합니다.

구문

<?xml version="1.0" encoding="UTF-8"?>
<TraceCapture continueOnError="true" enabled="true" name="DistributedTraceCapture-1">
    <DisplayName>POLICY_DISPLAY_NAME</DisplayName>
    <Variables>
        <Variable name="TRACE_VARIABLE_NAME" ref="FLOW_VARIABLE_NAME">DEFAULT_VALUE</Variable>
        <Variable name="TRACE_VARIABLE_NAME" ref="FLOW_VARIABLE_NAME">DEFAULT_VALUE</Variable>
    </Variables>
    <IgnoreUnresolvedVariables>BOOLEAN_VALUE</IgnoreUnresolvedVariables>
    <ThrowExceptionOnLimit>BOOLEAN_VALUE</ThrowExceptionOnLimit>
</TraceCapture>

다음 예시는 TraceCapture 정책 정의를 보여줍니다.

<?xml version="1.0" encoding="UTF-8"?>
<TraceCapture continueOnError="true" enabled="true" name="DistributedTraceCapture-1">
    <DisplayName>Distributed-Trace-Capture-Policy-1</DisplayName>
    <Variables>
        <Variable name="trace-variable-1" ref="flow-variable-1">default-val-1</Variable>
        <Variable name="trace-variable-2" ref="flow-variable-2">default-val-2</Variable>
    </Variables>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <ThrowExceptionOnLimit>false</ThrowExceptionOnLimit>
</TraceCapture>

이 요소에는 다음과 같이 모든 정책에 공통된 속성이 있습니다.

속성 기본값 필수 여부 설명
name 해당 사항 없음 필수

정책의 내부 이름입니다. name 속성의 값에는 문자, 숫자, 공백, 하이픈, 밑줄, 마침표가 포함될 수 있습니다. 이 값은 255자(영문 기준)를 초과할 수 없습니다.

원하는 경우 <DisplayName> 요소를 사용하여 관리 UI 프록시 편집기의 정책에 다른 자연어 이름을 사용하여 정책에 라벨을 지정합니다.

continueOnError 거짓 선택사항 정책이 실패할 경우 오류가 반환되도록 하려면 false로 설정합니다. 이는 대부분의 정책에서 예상되는 동작입니다. 정책이 실패해도 흐름 실행이 계속되도록 하려면 true로 설정합니다. 참조:
enabled 선택사항 정책을 시행하려면 true로 설정합니다. 정책을 중지하려면 false로 설정합니다. 정책이 흐름에 연결되어 있어도 정책이 시행되지 않습니다.
async   거짓 지원 중단됨 이 속성은 지원이 중단되었습니다.

다음 표에서는 <TraceCapture>의 하위 요소를 간략하게 설명합니다.

하위 요소 필수 여부 설명
<DisplayName> 선택사항 정책의 커스텀 이름을 지정합니다.
<Variables> 선택사항 trace할 변수 목록을 지정합니다.
<IgnoreUnresolvedVariables> 선택사항 해결되지 않은 변수가 발생하면 처리를 중지할지 여부를 지정합니다.
<ThrowExceptionOnLimit> 선택사항 변수 크기가 256바이트 한도를 초과할 경우 변수를 잘라야 하는지 여부를 지정합니다.
기타 하위 요소
<MergeBehavior> 선택사항 응답 메시지의 병합 동작을 지정합니다.

하위 요소 참조

이 섹션에서는 <TraceCapture>의 하위 요소를 설명합니다.

<DisplayName>

name 속성 외에 이 요소를 사용하여 관리 UI 프록시 편집기에서 자연스러운 다른 이름으로 정책의 라벨을 지정합니다.

<DisplayName> 요소는 모든 정책에 공통으로 적용됩니다.

기본값 해당 사항 없음
필수 여부 선택사항. <DisplayName>을 생략하면 정책의 name 속성 값이 사용됩니다.
유형 문자열
상위 요소 <PolicyElement>
하위 요소 없음

<DisplayName> 요소는 다음 문법을 사용합니다.

구문

<PolicyElement>
  <DisplayName>POLICY_DISPLAY_NAME</DisplayName>
  ...
</PolicyElement>

<PolicyElement>
  <DisplayName>My Validation Policy</DisplayName>
</PolicyElement>

<DisplayName> 요소에 속성 또는 하위 요소가 없습니다.

<Variables>

trace할 변수 목록을 지정합니다.

기본값 해당 사항 없음
필수 여부 필수
유형 복합 유형
상위 요소 <TraceCapture>
하위 요소 <Variable>

<Variables> 요소는 다음 문법을 사용합니다.

구문

<Variables>
    <Variable name="TRACE_VARIABLE_NAME" ref="FLOW_VARIABLE_NAME">DEFAULT_VALUE</Variable>
    <Variable name="TRACE_VARIABLE_NAME" ref="FLOW_VARIABLE_NAME">DEFAULT_VALUE</Variable>
</Variables>

다음 예시는 flow-variable-1flow-variable-2 흐름 변수를 trace합니다.

<Variables>
    <Variable name="trace-variable-1" ref="flow-variable-1">default-val-1</Variable>
    <Variable name="trace-variable-2" ref="flow-variable-2">default-val-2</Variable>
</Variables>

<Variable>

trace 데이터에 추가할 변수를 지정합니다.

기본값 해당 사항 없음
필수 여부 필수
유형 복합 유형
상위 요소 <Variables>
하위 요소 없음

<Variable> 요소는 다음 문법을 사용합니다.

구문
<Variable name="TRACE_VARIABLE_NAME" ref="FLOW_VARIABLE_NAME">DEFAULT_VALUE</Variable>

다음 예시에서는 trace-variable-1 trace 변수를 flow-variable-1 흐름 변수의 값으로 설정합니다.

<Variable name="trace-variable-1" ref="flow-variable-1">default-val-1</Variable>

flow-variable-1 흐름 변수를 사용할 수 없으면 trace-variable-1이 기본값 default-val-1로 설정됩니다.

다음 표는 <Variable>의 속성을 설명합니다.

속성 필수 여부 유형 설명
name 필수 문자열 지정된 변수에 대해 수집되는 데이터를 참조하는 이름입니다. 이 이름은 분산 trace 보고서에 표시됩니다.
ref 필수 문자열 trace 데이터를 수집할 변수입니다. 이 변수는 Apigee에서 사전 정의된 흐름 변수 또는 API 프록시의 커스텀 변수일 수 있습니다.

<IgnoreUnresolvedVariables>

해결되지 않은 변수가 발생하면 처리를 중지할지 여부를 결정합니다.

기본값 해당 사항 없음
필수 여부 선택사항
유형 불리언
상위 요소 <TraceCapture>
하위 요소 없음

확인되지 않은 변수를 무시하고 계속 처리하려면 true로 설정합니다. 그렇지 않으면 false로 설정합니다. 기본값은 true입니다.

<IgnoreUnresolvedVariables>true로 설정하는 것은 <TraceCapture>continueOnErrortrue로 설정하는 것과 다릅니다. continueOnErrortrue로 설정하면 Apigee가 모든 오류를 무시하지만 변수의 오류를 무시하지 않습니다.

<IgnoreUnresolvedVariables> 요소는 다음 문법을 사용합니다.

구문

<IgnoreUnresolvedVariables>BOOLEAN_VALUE</IgnoreUnresolvedVariables>

다음 예시에서는 <IgnoreUnresolvedVariables>false로 설정합니다.

<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>

<ThrowExceptionOnLimit>

변수 크기가 256바이트 한도를 초과할 경우의 정책 동작을 지정합니다.

  • true로 설정되었으면 변수 크기가 한도를 초과할 때 정책이 오류를 발생시킵니다.
  • false로 설정되었으면 정책이 한도를 초과하는 변수를 자릅니다. 변수는 해당 한도 크기로 잘립니다.
기본값 해당 사항 없음
필수 여부 선택사항
유형 불리언
상위 요소 <TraceCapture>
하위 요소 없음

<ThrowExceptionOnLimit> 요소는 다음 문법을 사용합니다.

구문

<ThrowExceptionOnLimit>BOOLEAN_VALUE</ThrowExceptionOnLimit>

다음 예시에서는 <ThrowExceptionOnLimit> 값을 true로 설정합니다.

<ThrowExceptionOnLimit>false</ThrowExceptionOnLimit>

오류 코드

This section describes the fault codes and error messages that are returned and fault variables that are set by Apigee when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors and Handling faults.

Runtime errors

These errors can occur when the policy executes.

Fault code HTTP status Cause
steps.tracecapture.UnresolvedVariable 500

This error occurs if a variable specified in the TraceCapture policy is either:

  • Out of scope (not available in the specific flow where the policy is being executed)
  • or
  • Can't be resolved (is not defined)
steps.tracecapture.VariableValueLimitExceeded 500

This error occurs if the <ThrowExceptionOnLimit> element is set to true and the size of any variable exceeds 256 bytes.

Fault variables

Whenever there are execution errors in a policy, Apigee generates error messages. You can view these error messages in the error response. Many a time, system generated error messages might not be relevant in the context of your product. You might want to customize the error messages based on the type of error to make the messages more meaningful.

To customize the error messages, you can use either fault rules or the RaiseFault policy. For information about differences between fault rules and the RaiseFault policy, see FaultRules vs. the RaiseFault policy. You must check for conditions using the Condition element in both the fault rules and the RaiseFault policy. Apigee provides fault variables unique to each policy and the values of the fault variables are set when a policy triggers runtime errors. By using these variables, you can check for specific error conditions and take appropriate actions. For more information about checking error conditions, see Building conditions.

The following table describes the fault variables specific to this policy.

Variables Where Example
fault.name The fault.name can match to any of the faults listed in the Runtime errors table. The fault name is the last part of the fault code. fault.name Matches "UnresolvedVariable"
tracecapture.POLICY_NAME.failed POLICY_NAME is the user-specified name of the policy that threw the fault. tracecapture.trace-capture-1.failed = true
For more information about policy errors, see What you need to know about policy errors.