> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AI로 계측하기

> 코딩 어시스턴트와 언어별 SDK 가이드를 활용하여 ClickHouse Observability에 맞게 애플리케이션을 계측합니다.

코딩 어시스턴트를 활용해 애플리케이션의 언어 또는 프레임워크별 가이드에 따라 instrumentation을 추가하십시오. 어시스턴트는 진입점을 식별하고, 적절한 SDK를 설치하고, 텔레메트리 내보내기를 구성할 수 있습니다.

자동 계측은 지원되는 라이브러리와 프레임워크의 텔레메트리를 수집합니다. 언어와 애플리케이션에 따라 비즈니스 작업을 수집하려면 코드를 변경하거나 사용자 정의 스팬을 추가해야 할 수도 있습니다. 배포하기 전에 생성된 변경 사항을 검토하십시오.

## 시작하기 전에

애플리케이션 소스 코드, 리포지토리에 액세스할 수 있는 코딩 어시스턴트, ClickHouse Observability 대상이 필요합니다. 애플리케이션에 맞는 [언어별 SDK 가이드](https://clickhouse.com/docs/ko/clickstack/observability/ingesting-data/sdks.md)를 선택하십시오. 이 가이드에서 사용할 SDK 패키지, 지원되는 시그널, 익스포터 설정을 확인할 수 있습니다.

## 대상 구성

> [tab] 완전 관리형
>
> [베타 제공](https://clickhouse.com/docs/reference/settings/beta-and-experimental-features.md#beta-features)
>
> **팀 설정 → 데이터 → Managed Telemetry**를 열고 OTLP HTTP 엔드포인트와 수집 API key를 복사하십시오. 복사한 값은 버전 관리 대상에서 제외된 환경 파일이나 시크릿 저장소에 보관하십시오.
>
> ![마스킹된 OTLP HTTP 엔드포인트와 API Key가 표시된 Managed Telemetry 화면](https://mintcdn.com/private-7c7dfe99/Zk1feNn6fCQBpold/images/clickstack/getting-started/observability-managed-telemetry.png?fit=max\&auto=format\&n=Zk1feNn6fCQBpold\&q=85\&s=e63a2ac2e6ab996d3fc360ebe0f487a5)
>
> 서비스에 **시작하기** 페이지가 표시되는 경우에는 **AI로 계측하기** 아래의 **Copy prompt**를 선택해도 됩니다. **Set it up with an AI agent**에서 프롬프트를 복사한 후, 해당 대화 상자에 표시된 `CLICKSTACK_OTLP_ENDPOINT` 및 `CLICKSTACK_API_KEY` 변수를 설정하십시오. 그런 다음 아래의 나머지 검토 및 검증 단계를 진행하십시오.

> [tab] 자가 관리형
>
> ClickHouse Cloud 서비스에 연결되어 실행 중인 OpenTelemetry collector가 필요합니다. collector 구성 방법은 [OpenTelemetry로 데이터 수집하기](https://clickhouse.com/docs/ko/clickstack/observability/ingesting-data/opentelemetry.md#self-managed)를 참고하십시오.
>
> collector의 OTLP 엔드포인트와 collector에 구성된 수집 키를 사용하십시오. 인증 포맷과 익스포터 설정은 사용하는 언어의 SDK 가이드에서 **자가 관리형** 탭을 참고하십시오.

## 어시스턴트에 언어 가이드 제공하기

Claude Code, Cursor, Codex 등의 코딩 어시스턴트에서 애플리케이션 리포지토리를 여십시오. 다음 프롬프트를 복사한 후 자리표시자를 언어 가이드 URL, 배포 유형, 서비스 이름으로 바꾸십시오. 자격 증명을 프롬프트에 직접 붙여넣는 대신 환경 변수 이름을 지정하십시오.

```text wrap theme={null}
Instrument this application to send telemetry to ClickHouse Observability.

Language or framework guide: <LANGUAGE_SDK_GUIDE_URL>
Destination: <fully managed or self-managed>
Service name: <SERVICE_NAME>
Endpoint environment variable: <ENDPOINT_VARIABLE_NAME>
Ingestion key environment variable: <API_KEY_VARIABLE_NAME>

Read the linked guide and use the instructions for my destination.
Inspect the application's language, framework, dependencies, and startup
commands before making changes. If you cannot read the guide, ask me for
its contents rather than guessing SDK names or configuration.

Reuse existing OpenTelemetry instrumentation where present. Otherwise,
install the SDK and supported automatic instrumentation described in the
guide. Initialize instrumentation at the point required by that SDK.
Use the guide's protocol, endpoint, and authentication format, reading
connection values from the environment. Do not hardcode or print secrets.

Preserve the application's existing behavior. Check for duplicate SDK
initialization, exporters, and logging handlers, including those installed
by automatic instrumentation. If logs are supported, check both the
application's logging level and the SDK's export level so the test log
is captured once. Use the language guide's settings for these checks.

Explain which signals are supported and any operations that need manual
instrumentation. Do not assume every SDK exports logs, metrics, traces,
or session replay.

Update the startup command and document the required environment variables.
Run the application's existing checks and a local startup check. Exercise
an instrumented operation with a unique test marker. If logs are supported,
emit one test log during that operation at an enabled severity. Allow time
for batched export or flush telemetry before shutting down.

When you have destination access, find the test events there and verify
the service name, marker, and absence of duplicates. If log-to-trace
correlation is supported, check that the test log references the operation's
trace and span. Distinguish local export, endpoint acceptance, and events
stored in ClickHouse Observability; startup or an HTTP success response
alone does not prove storage.

Summarize the changes, tests performed, and results. Clearly state which
checks you could not run and give me the remaining verification steps.
```

이 프롬프트의 변수 이름은 연결 값이 저장된 위치를 나타냅니다. 이 변수가 SDK에 필요한 변수를 대체하지는 않으므로, 어시스턴트는 이를 해당 언어 가이드에 설명된 설정에 매핑해야 합니다. 브라우저 애플리케이션은 [브라우저 SDK 가이드](https://clickhouse.com/docs/ko/clickstack/observability/ingesting-data/sdks/browser.md)를 참고하고, 가이드에 설명된 브라우저 전용 엔드포인트 및 키 구성도 함께 적용하십시오.

## 애플리케이션 검토 및 실행

의존성, 초기화, 시작 관련 변경 사항을 검토하십시오. 어시스턴트가 올바른 대상과 인증 포맷을 선택했는지, 기존 instrumentation 코드를 그대로 유지했는지, 커밋되는 파일에 시크릿이 포함되지 않았는지 확인하십시오.

애플리케이션의 기존 테스트를 실행한 다음, 업데이트된 명령과 환경으로 애플리케이션을 시작하십시오. 계측된 라이브러리가 실제로 호출되도록 요청을 보내거나 작업을 수행하십시오. 자동 instrumentation으로 수집되지 않는 작업의 텔레메트리가 필요하면 SDK의 API로 사용자 정의 스팬을 추가하도록 어시스턴트에게 요청하십시오.

## 텔레메트리 확인

1. ClickHouse Observability에서 [검색](https://clickhouse.com/docs/ko/clickstack/observability/features/search.md)을 엽니다.
2. 해당하는 로그 또는 트레이스 소스를 선택하고, 테스트 활동이 포함된 시간 범위를 지정합니다.
3. 서비스 이름으로 필터링한 후 생성된 이벤트를 살펴봅니다. 예상한 요청 또는 작업이 표시되는지 확인하십시오.
4. SDK가 메트릭을 내보내는 경우 [차트 탐색기](https://clickhouse.com/docs/ko/clickstack/observability/features/dashboards/overview.md#navigate-chart-explorer)에서 메트릭을 확인합니다.

애플리케이션이 정상적으로 시작되었다고 해서 텔레메트리가 전달된 것은 아닙니다. 이벤트가 보이지 않으면 애플리케이션의 익스포터 오류, 엔드포인트, 프로토콜, 인증 설정을 확인하십시오. 자가 관리형 배포에서는 collector 로그도 함께 확인하십시오.

전체 애플리케이션 예시는 [HackerNews Analyzer 데모](https://clickhouse.com/docs/ko/clickstack/observability/example-datasets/instrument-application.md)를 참고하십시오.
