다음을 통해 공유


add-telemetry 명령

기존 데이터 API 작성기 구성 파일에서 OpenTelemetry 및 Azure Application Insights 설정을 추가하거나 업데이트합니다. 섹션이 runtime.telemetry 없으면 만들어집니다. 지정되지 않은 옵션은 기존 값을 변경하지 않고 그대로 둡니다.

메모

원격 분석 설정은 .을 사용하여 dab configure구성할 수 없습니다. 모든 runtime.telemetry 변경 내용에 사용합니다dab add-telemetry.

개념 지침 및 엔드투엔드 연습은 OpenTelemetry 및 활동 추적 사용 및Azure Application Insights 사용을 참조하세요.

문법

dab add-telemetry [options]

한눈에 보기

Option 요약
-c, --config 구성 파일 경로입니다. 기본값 dab-config.json.

OpenTelemetry 섹션

Option 요약
--otel-enabled OpenTelemetry를 사용하거나 사용하지 않도록 설정합니다.
--otel-endpoint OpenTelemetry 수집기 엔드포인트 URL입니다.
--otel-protocol 프로토콜을 내보냅니다. 허용되는 값: grpc, httpprotobuf.
--otel-service-name 모든 원격 분석의 서비스 이름 태그입니다.
--otel-headers OpenTelemetry 수집기로 보낼 추가 헤더입니다.

Azure Application Insights 섹션

Option 요약
--app-insights-enabled Azure Application Insights를 사용하거나 사용하지 않도록 설정합니다.
--app-insights-conn-string Application Insights 연결 문자열입니다.

-c, --config

경로 구성 파일. dab-config.json 환경 변수는 존재하지 dab-config.<DAB_ENVIRONMENT>.json 않는 한 DAB_ENVIRONMENT 기본값으로 설정됩니다.

예시

dab add-telemetry \
  --config ./my-config.json \
  --otel-enabled true

--otel-enabled

OpenTelemetry 내보내기를 사용하거나 사용하지 않도록 설정합니다. 허용되는 값: true, . false

예시

dab add-telemetry \
  --otel-enabled true

결과 구성

{
  "runtime": {
    "telemetry": {
      "open-telemetry": {
        "enabled": true
      }
    }
  }
}

--otel-endpoint

OpenTelemetry 수집기 또는 백 엔드의 URL입니다. gRPC의 경우 .http://<host>:<port> HTTP의 경우 전체 경로(예 http://<host>:<port>/v1/traces: .)를 포함합니다.

예시

dab add-telemetry \
  --otel-enabled true \
  --otel-endpoint "http://localhost:4317"

결과 구성

{
  "runtime": {
    "telemetry": {
      "open-telemetry": {
        "enabled": true,
        "endpoint": "http://localhost:4317"
      }
    }
  }
}

--otel-protocol

OpenTelemetry 내보내기용 내보내기 프로토콜입니다. 허용되는 값: grpc, httpprotobuf. 기본값은 grpc입니다.

예시

dab add-telemetry \
  --otel-enabled true \
  --otel-endpoint "http://localhost:4318" \
  --otel-protocol "httpprotobuf"

결과 구성

{
  "runtime": {
    "telemetry": {
      "open-telemetry": {
        "enabled": true,
        "endpoint": "http://localhost:4318",
        "exporter-protocol": "httpprotobuf"
      }
    }
  }
}

--otel-service-name

모든 추적 및 메트릭에 연결된 서비스 이름 태그입니다. 원격 분석 백 엔드에서 서비스 식별자로 나타납니다. 기본값은 dab입니다.

예시

dab add-telemetry \
  --otel-enabled true \
  --otel-service-name "my-dab-api"

결과 구성

{
  "runtime": {
    "telemetry": {
      "open-telemetry": {
        "enabled": true,
        "service-name": "my-dab-api"
      }
    }
  }
}

--otel-headers

원격 분석을 수집기로 내보낼 때 포함할 추가 HTTP 헤더입니다. 쉼표로 구분된 key=value 목록을 사용합니다. API 키 또는 권한 부여 헤더가 필요한 인증된 수집기 엔드포인트에 이 옵션을 사용합니다.

예시

dab add-telemetry \
  --otel-enabled true \
  --otel-endpoint "https://collector.example.com:4317" \
  --otel-headers "api-key=my-secret-key"

--app-insights-enabled

Azure Application Insights 원격 분석을 사용하거나 사용하지 않도록 설정합니다. 허용되는 값: true, . false

예시

dab add-telemetry \
  --app-insights-enabled true

결과 구성

{
  "runtime": {
    "telemetry": {
      "application-insights": {
        "enabled": true
      }
    }
  }
}

--app-insights-conn-string

Azure Application Insights 리소스에 대한 연결 문자열입니다. 환경 변수 참조를 사용하여 소스 제어에 비밀을 커밋하지 않도록 합니다.

경고

구성 파일에서 직접 연결 문자열을 하드 코딩하지 마세요. 사용 @env('<variable-name>') 또는 비밀 관리자.

예시

dab add-telemetry \
  --app-insights-enabled true \
  --app-insights-conn-string "@env('APP_INSIGHTS_CONN_STRING')"

결과 구성

{
  "runtime": {
    "telemetry": {
      "application-insights": {
        "enabled": true,
        "connection-string": "@env('APP_INSIGHTS_CONN_STRING')"
      }
    }
  }
}

전체 예제: OpenTelemetry 및 Application Insights

다음 예제에서는 단일 명령에서 OpenTelemetry 및 Application Insights를 모두 사용하도록 설정합니다.

dab add-telemetry \
  --otel-enabled true \
  --otel-endpoint "http://localhost:4317" \
  --otel-protocol "grpc" \
  --otel-service-name "my-dab-api" \
  --app-insights-enabled true \
  --app-insights-conn-string "@env('APP_INSIGHTS_CONN_STRING')"

결과 구성

{
  "runtime": {
    "telemetry": {
      "open-telemetry": {
        "enabled": true,
        "endpoint": "http://localhost:4317",
        "service-name": "my-dab-api",
        "exporter-protocol": "grpc"
      },
      "application-insights": {
        "enabled": true,
        "connection-string": "@env('APP_INSIGHTS_CONN_STRING')"
      }
    }
  }
}