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

# 시간 범위 청사진

> 컴퓨팅, 서버리스 함수, 컨테이너 및 런타임 청구를 위한 경과 시간에 따른 리소스 소비 추적.

## 사용 사례

시간 범위 청사진에서 지원하는 일반적인 시나리오를 살펴보세요:

<CardGroup cols={2}>
  <Card title="Serverless Functions" icon="function">
    함수 실행 시간과 메모리 사용량을 기준으로 청구합니다.
  </Card>

  <Card title="Container Runtime" icon="container-storage">
    사용량 기반 청구를 위해 컨테이너 실행 시간을 추적합니다.
  </Card>

  <Card title="Compute Instances" icon="server">
    VM 런타임을 모니터링하고 분 또는 시간 단위로 과금합니다.
  </Card>

  <Card title="Background Jobs" icon="briefcase">
    데이터 내보내기, 보고서 및 배치 작업의 처리 시간을 추적합니다.
  </Card>
</CardGroup>

<Info>
  컴퓨트 시간, 함수 실행 시간, 컨테이너 런타임 또는 기타 시간 기반 사용량을 기준으로 청구할 때 이상적입니다.
</Info>

## 빠른 시작

시간 지속에 따라 리소스 사용량을 추적합니다:

<Steps>
  <Step title="Install the SDK">
    ```bash theme={null}
    npm install @dodopayments/ingestion-blueprints
    ```
  </Step>

  <Step title="Get Your API Keys">
    * **Dodo Payments API Key**: [Dodo Payments Dashboard](https://app.dodopayments.com/developer/api-keys)에서 가져옵니다.
  </Step>

  <Step title="Create a Meter">
    [Dodo Payments Dashboard](https://app.dodopayments.com/)에서 측정기를 생성합니다:

    * **Event Name**: `time_range_usage` (또는 원하는 이름)
    * **Aggregation Type**: `sum` (총 지속 시간 추적용)
    * **Over Property**: `durationSeconds`, `durationMinutes` 또는 `durationMs`
  </Step>

  <Step title="Track Time Usage">
    <CodeGroup>
      ```javascript Serverless Functions theme={null}
      import { Ingestion, trackTimeRange } from '@dodopayments/ingestion-blueprints';

      const ingestion = new Ingestion({
        apiKey: process.env.DODO_PAYMENTS_API_KEY,
        environment: 'test_mode',
        eventName: 'function_execution'
      });

      // Track function execution time
      const startTime = Date.now();

      // Execute your function (example: image processing)
      const result = await yourImageProcessingLogic();

      const durationMs = Date.now() - startTime;

      await trackTimeRange(ingestion, {
        customerId: 'customer_123',
        durationMs: durationMs
      });
      ```

      ```javascript Container Runtime theme={null}
      import { Ingestion, trackTimeRange } from '@dodopayments/ingestion-blueprints';

      const ingestion = new Ingestion({
        apiKey: process.env.DODO_PAYMENTS_API_KEY,
        environment: 'test_mode',
        eventName: 'container_runtime'
      });

      // Track container runtime in seconds
      await trackTimeRange(ingestion, {
        customerId: 'customer_456',
        durationSeconds: 120
      });
      ```

      ```javascript VM Instance Runtime theme={null}
      import { Ingestion, trackTimeRange } from '@dodopayments/ingestion-blueprints';

      const ingestion = new Ingestion({
        apiKey: process.env.DODO_PAYMENTS_API_KEY,
        environment: 'test_mode',
        eventName: 'vm_runtime'
      });

      // Track VM runtime in minutes
      await trackTimeRange(ingestion, {
        customerId: 'customer_789',
        durationMinutes: 60
      });
      ```
    </CodeGroup>
  </Step>
</Steps>

## 구성

### 수집 구성

<ParamField path="apiKey" type="string" required>
  대시보드에서 가져온 Dodo Payments API 키입니다.
</ParamField>

<ParamField path="environment" type="string" required>
  환경 모드: `test_mode` 또는 `live_mode`.
</ParamField>

<ParamField path="eventName" type="string" required>
  측정기 구성과 일치하는 이벤트 이름입니다.
</ParamField>

### 시간 범위 추적 옵션

<ParamField path="customerId" type="string" required>
  청구 연결을 위한 고객 ID입니다.
</ParamField>

<ParamField path="durationMs" type="number">
  밀리초 단위 지속 시간. 초단위 이하 정밀도에 사용합니다.
</ParamField>

<ParamField path="durationSeconds" type="number">
  초 단위 지속 시간. 함수 실행 및 짧은 작업에 가장 일반적으로 사용됩니다.
</ParamField>

<ParamField path="durationMinutes" type="number">
  분 단위 지속 시간. VM과 같은 장시간 실행 리소스에 유용합니다.
</ParamField>

<ParamField path="metadata" type="object">
  CPU, 메모리, 리전 등 리소스에 대한 선택적 메타데이터입니다.
</ParamField>

## 모범 사례

<Tip>
  **적절한 단위 선택**: 짧은 작업에는 밀리초, 함수에는 초, 장시간 실행 리소스에는 분을 사용하세요.
</Tip>

<Warning>
  **정확한 시간 측정**: 특히 서버리스 함수의 경우 정확한 시간 추적을 위해 `Date.now()` 또는 `performance.now()`를 사용하세요.
</Warning>
