본문 바로가기
WIKI 기술 지식 베이스

RUM과 트레이스 연결 (Connect RUM and Traces)

원문 보기 위키 갱신

웹·모바일 애플리케이션의 요청을 해당 백엔드 트레이스와 연결하는 방법을 알아봐요. Real User Monitoring과 APM 통합을 통해 프론트엔드와 백엔드 데이터를 하나의 렌즈로 볼 수 있어요.

출처: 문서

본문

{% image source="https://docs.dd-static.net/images/real_user_monitoring/connect_rum_and_traces/rum-trace-tab.a48c0837c522ae9e5f26dd251b797a5e.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/real_user_monitoring/connect_rum_and_traces/rum-trace-tab.a48c0837c522ae9e5f26dd251b797a5e.png?auto=format&fit=max&w=850&dpr=2 2x" alt="RUM and Traces" /%}

개요 (Overview)

Real User Monitoring(RUM)과의 APM 통합을 사용하면 웹·모바일 애플리케이션의 요청을 해당 백엔드 트레이스와 연결할 수 있어요. 이 조합을 통해 전체 프론트엔드와 백엔드 데이터를 하나의 렌즈로 볼 수 있어요.

RUM의 프론트엔드 데이터와 trace ID 주입의 백엔드·인프라·로그 정보를 사용해 스택 어디에서든 이슈를 정확히 찾고 사용자가 무엇을 경험하고 있는지 이해해요.

iOS 애플리케이션의 트레이스만 Datadog으로 보내려면 iOS Trace Collection을 참고해요.

사용 방법 (Usage)

사전 요구 사항 (Prerequisites)

  • RUM 애플리케이션이 대상으로 하는 서비스에 APM tracing을 설정했음.
  • 서비스가 HTTP 서버를 사용함.
  • HTTP 서버가 분산 추적을 지원하는 라이브러리를 사용함.
  • SDK에 따라 다음을 설정했음:
    • Browser SDK: RUM Explorer의 XMLHttpRequest(XHR) 또는 Fetch 리소스를 allowedTracingUrls에 추가했음.
    • Mobile SDK: 네이티브 또는 XMLHttpRequest(XHR)를 firstPartyHosts에 추가했음.
  • allowedTracingUrls 또는 firstPartyHosts에 대한 요청에 해당하는 트레이스가 있음.

RUM 설정 (Setup RUM)

참고: RUM과 Traces를 구성하면 RUM에서 APM 유료 데이터를 사용하게 되어 APM 청구에 영향을 줄 수 있어요.

{% tab title="Browser RUM" %}

  1. RUM Browser Monitoring을 설정해요.

  2. RUM SDK를 초기화해요. allowedTracingUrls 초기화 매개변수를 브라우저 애플리케이션에서 호출하는 내부 파스트파티(first-party) 오리진 목록으로 구성해요.

npm install의 경우:

import { datadogRum } from '@datadog/browser-rum'

datadogRum.init({
  clientToken: '<CLIENT_TOKEN>',
  applicationId: '<APPLICATION_ID>',
  site: 'datadoghq.com',
  //  service: 'my-web-application',
  //  env: 'production',
  //  version: '1.0.0',
  allowedTracingUrls: [
    "https://api.example.com",
    // Matches any subdomain of my-api-domain.com, such as https://foo.my-api-domain.com
    /^https:\/\/[^\/]+\.my-api-domain\.com/,
    // You can also use a function for advanced matching:
    (url) => url.startsWith("https://api.example.com")
  ],
  sessionSampleRate: 100,
  sessionReplaySampleRate: 100, // if not specified, defaults to 100
  trackResources: true,
  trackLongTasks: true,
  trackUserInteractions: true,
})

CDN install의 경우:

window.DD_RUM.init({
   clientToken: '<CLIENT_TOKEN>',
   applicationId: '<APPLICATION_ID>',
   site: 'datadoghq.com',
   //  service: 'my-web-application',
   //  env: 'production',
   //  version: '1.0.0',
   allowedTracingUrls: [
     "https://api.example.com",
     // Matches any subdomain of my-api-domain.com, such as https://foo.my-api-domain.com
     /^https:\/\/[^\/]+\.my-api-domain\.com/,
     // You can also use a function for advanced matching:
     (url) => url.startsWith("https://api.example.com")
   ],
   sessionSampleRate: 100,
   sessionReplaySampleRate: 100, // if not included, the default is 100
   trackResources: true,
   trackLongTasks: true,
   trackUserInteractions: true,
 })

RUM을 Traces에 연결하려면 service 필드에 브라우저 애플리케이션을 지정해야 해요.

allowedTracingUrls는 전체 URL(<scheme>://<host>[:<port>]/<path>[?<query>][#<fragment>])과 일치해요. 다음 유형을 허용해요:

  • string: 값으로 시작하는 모든 URL과 일치하므로, https://api.example.com은 https://api.example.com/v1/resource와 일치해요.
  • RegExp: URL의 하위 문자열 중 하나라도 제공된 RegExp와 일치하면 일치해요. 예를 들어 /^https:\/\/[^\/]+\.my-api-domain\.com/는 https://foo.my-api-domain.com/path 같은 URL과 일치하지만 https://notintended.com/?from=guess.my-api-domain.com과는 일치하지 않아요. 참고: ^를 사용하지 않는 한 RegExp는 URL의 시작에 고정(anchor)되지 않아요. 지나치게 넓은 패턴은 의도하지 않은 URL과 일치해 CORS 오류를 일으킬 수 있으니 주의하세요.
  • function: URL을 매개변수로 평가해요. true로 설정된 boolean을 반환하면 일치를 나타내요.

{% alert level="danger" %} RegExp를 사용할 때 패턴은 접두사가 아니라 전체 URL의 하위 문자열로 테스트돼요. 의도하지 않은 일치를 피하려면 RegExp를 ^로 고정하고 가능한 한 구체적으로 만들기 바랍니다. {% /alert %}

(선택 사항) 백엔드 트레이스의 정의된 비율을 유지하려면 traceSampleRate 초기화 매개변수를 구성해요. 설정하지 않으면 브라우저 요청에서 오는 트레이스의 100%가 Datadog으로 전송돼요. 예를 들어 백엔드 트레이스의 20%를 유지하려면:

import { datadogRum } from '@datadog/browser-rum'

datadogRum.init({
    ...otherConfig,
    traceSampleRate: 20
})

참고: traceSampleRate 는 RUM 세션 샘플링에 영향을 주지 않아요. 백엔드 트레이스만 샘플 아웃돼요.

(선택 사항) traceSampleRate를 설정했다면 백엔드 서비스의 샘플링 결정이 계속 적용되도록 traceContextInjection 초기화 매개변수를 sampled로 구성해요(기본값 sampled).

예를 들어 Browser SDK에서 traceSampleRate를 20%로 설정했다면:

  • traceContextInjection이 all로 설정되면 백엔드 트레이스의 20% 는 유지되고 80% 는 버려져요.

{% image source="https://docs.dd-static.net/images/real_user_monitoring/connect_rum_and_traces/traceContextInjection_all-2.e5e60848ccc43280ba4d010674d73d9d.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/real_user_monitoring/connect_rum_and_traces/traceContextInjection_all-2.e5e60848ccc43280ba4d010674d73d9d.png?auto=format&fit=max&w=850&dpr=2 2x" alt="traceContextInjection set to all" /%}

{% alert level="info" %} 엔드 투 엔드 추적은 Browser SDK가 초기화된 후에 발생하는 요청에 대해 사용 가능해요. 초기 HTML 문서와 초기 브라우저 요청의 엔드 투 엔드 추적은 지원되지 않아요. {% /alert %}

{% /tab %}

{% tab title="Android RUM" %}

  1. RUM Android Monitoring을 설정해요.

  2. Android Trace Collection을 설정해요.

  3. 모듈 수준 build.gradle 파일의 dd-sdk-android-okhttp 라이브러리에 Gradle 종속성을 추가해요:

    dependencies {
        implementation "com.datadoghq:dd-sdk-android-okhttp:x.x.x"
    }
    
  4. Android 애플리케이션에서 호출하는 내부 파스트파티 오리진 목록으로 OkHttpClient 인터셉터를 구성해요.

    val tracedHosts = listOf("example.com", "example.eu")
    
    val okHttpClient = OkHttpClient.Builder()
        .addInterceptor(DatadogInterceptor.Builder(tracedHosts).build())
        .addNetworkInterceptor(TracingInterceptor.Builder(tracedHosts).build())
        .eventListenerFactory(DatadogEventListener.Factory())
        .build()
    

기본적으로 나열된 호스트의 모든 하위 도메인이 추적돼요. 예를 들어 example.com을 추가하면 api.example.com과 foo.example.com에 대한 추적도 활성화돼요.

  1. (선택 사항) 백엔드 트레이스의 정의된 비율을 유지하려면 traceSampleRate 매개변수를 구성해요. 설정하지 않으면 애플리케이션 요청에서 오는 트레이스의 100%가 Datadog으로 전송돼요. 백엔드 트레이스의 20%를 유지하려면:

    val tracedHosts = listOf("example.com")
    
    val okHttpClient = OkHttpClient.Builder()
        .addInterceptor(
          DatadogInterceptor.Builder(tracedHosts)
              .setTraceSampleRate(20f)
              .build()
        )
        .build()
    

참고:

  • traceSampleRate 는 RUM 세션 샘플링에 영향을 주지 않아요. 백엔드 트레이스만 샘플 아웃돼요.
  • Datadog 구성에서 커스텀 추적 헤더 유형을 정의하고 GlobalTracer로 등록된 트레이서를 사용한다면, 사용 중인 SDK에 동일한 추적 헤더 유형이 설정되어 있는지 확인해요.

{% /tab %}

{% tab title="iOS RUM" %}

  1. RUM iOS Monitoring을 설정해요.

  2. urlSessionTracking 구성과 firstPartyHostsTracing 매개변수로 RUM과 URLSession 계측을 활성화해요:

    RUM.enable(
        with: RUM.Configuration(
            applicationID: "<rum application id>",
            urlSessionTracking: .init(
                firstPartyHostsTracing: .trace(
                    hosts: [
                        "example.com",
                        "api.yourdomain.com"
                    ]
                )
            )
        )
    )
    

기본적으로 나열된 호스트의 모든 하위 도메인이 추적돼요. 예를 들어 example.com을 추가하면 api.example.com과 foo.example.com에 대한 추적도 활성화돼요.

trace ID 주입은 URLSession에 URLRequest를 제공할 때 작동해요. URL 객체를 사용하면 분산 추적이 작동하지 않아요.

  1. (선택 사항) 상세 타이밍 분류(DNS 해석, SSL 핸드셰이크, 첫 바이트까지의 시간, 연결 시간, 다운로드 기간)를 위해 SessionDelegate 유형에 대해 URLSessionInstrumentation을 활성화해요:

    URLSessionInstrumentation.enableDurationBreakdown(
        with: .init(
            delegateClass: <YourSessionDelegate>.self
        )
    )
    
    let session = URLSession(
        configuration: ...,
        delegate: <YourSessionDelegate>(),
        delegateQueue: ...
    )
    

참고: 분산 추적은 자동으로 작동하지만, URLSessionInstrumentation을 활성화하면 트레이스 타이밍이 더 정확해져요.

  1. (선택 사항) 백엔드 트레이스의 정의된 비율을 유지하려면 sampleRate 매개변수를 설정해요. 설정하지 않으면 애플리케이션 요청에서 오는 트레이스의 100%가 Datadog으로 전송돼요.

백엔드 트레이스의 20%를 유지하려면:

RUM.enable(
    with: RUM.Configuration(
        applicationID: "<rum application id>",
        urlSessionTracking: .init(
            firstPartyHostsTracing: .trace(
                hosts: [
                    "example.com",
                    "api.yourdomain.com"
                ],
                sampleRate: 20
            )
        )
    )
)

참고: sampleRate 는 RUM 세션 샘플링에 영향을 주지 않아요. 백엔드 트레이스만 샘플 아웃돼요. {% /tab %}

{% tab title="React Native RUM" %}

  1. RUM React Native Monitoring을 설정해요.

  2. React Native 애플리케이션에서 호출하는 내부 파스트파티 오리진 목록을 정의하려면 firstPartyHosts 초기화 매개변수를 설정해요:

    const config = new DatadogProviderConfiguration(
        // ...
    );
    config.firstPartyHosts = ["example.com", "api.yourdomain.com"];
    

기본적으로 나열된 호스트의 모든 하위 도메인이 추적돼요. 예를 들어 example.com을 추가하면 api.example.com과 foo.example.com에 대한 추적도 활성화돼요.

  1. (선택 사항) 백엔드 트레이스의 정의된 비율을 유지하려면 resourceTracingSamplingRate 초기화 매개변수를 설정해요. 설정하지 않으면 애플리케이션 요청에서 오는 트레이스의 100%가 Datadog으로 전송돼요.

백엔드 트레이스의 20%를 유지하려면:

const config = new DatadogProviderConfiguration(
    // ...
);
config.resourceTracingSamplingRate = 20;

참고: resourceTracingSamplingRate 는 RUM 세션 샘플링에 영향을 주지 않아요. 백엔드 트레이스만 샘플 아웃돼요.

{% /tab %}

{% tab title="Flutter RUM" %}

  1. RUM Flutter Monitoring을 설정해요.

  2. 리소스 자동 추적 (Automatically track resources)의 지침을 따라 Datadog Tracking HTTP Client 패키지를 포함하고 HTTP 추적을 활성화해요. 여기에는 Flutter 애플리케이션에서 호출하는 내부 파스트파티 오리진 목록을 추가하기 위한 초기화 변경이 포함돼요:

    final configuration = DatadogConfiguration(
      // ...
      // added configuration
      firstPartyHosts: ['example.com', 'api.yourdomain.com'],
    )..enableHttpTracking()
    

{% /tab %}

{% tab title="Roku RUM" %}

{% callout %}

다음 Datadog 사이트 사용자에게 중요한 안내: app.ddog-gov.com, us2.ddog-gov.com

{% alert level="danger" %} Roku용 RUM은 {% placeholder "user-datadog-datacenter" /%} Datadog 사이트에서 사용할 수 없어요. {% /alert %}

{% /callout %}

  1. RUM Roku Monitoring을 설정해요.

  2. datadogroku_DdUrlTransfer 컴포넌트를 사용해 네트워크 요청을 수행해요.

        ddUrlTransfer = datadogroku_DdUrlTransfer(m.global.datadogRumAgent)
        ddUrlTransfer.SetUrl(url)
        ddUrlTransfer.EnablePeerVerification(false)
        ddUrlTransfer.EnableHostVerification(false)
        result = ddUrlTransfer.GetToString()
    

{% /tab %}

{% tab title="Kotlin Multiplatform RUM" %}

  1. RUM Kotlin Multiplatform Monitoring을 설정해요.

  2. Ktor 계측을 설정해요.

  3. Kotlin Multiplatform 애플리케이션에서 호출하는 내부 파스트파티 오리진 목록을 정의하려면 Datadog Ktor 플러그인 구성에서 tracedHosts 초기화 매개변수를 설정해요:

    val ktorClient = HttpClient {
        install(
            datadogKtorPlugin(
                tracedHosts = mapOf(
                    "example.com" to setOf(TracingHeaderType.DATADOG),
                    "example.eu" to setOf(TracingHeaderType.DATADOG)
                ),
                traceSampleRate = 100f
            )
        )
    }
    

기본적으로 나열된 호스트의 모든 하위 도메인이 추적돼요. 예를 들어 example.com을 추가하면 api.example.com과 foo.example.com에 대한 추적도 활성화돼요.

  1. (선택 사항) 백엔드 트레이스의 정의된 비율을 유지하려면 traceSampleRate 초기화 매개변수를 설정해요. 설정하지 않으면 애플리케이션 요청에서 오는 트레이스의 20%가 Datadog으로 전송돼요.

백엔드 트레이스의 100%를 유지하려면:

val ktorClient = HttpClient {
    install(
        datadogKtorPlugin(
            tracedHosts = mapOf(
                "example.com" to setOf(TracingHeaderType.DATADOG),
                "example.eu" to setOf(TracingHeaderType.DATADOG)
            ),
            traceSampleRate = 100f
        )
    )
}

참고: traceSampleRate 는 RUM 세션 샘플링에 영향을 주지 않아요. 백엔드 트레이스만 샘플 아웃돼요.

{% /tab %}

설정 확인 (Verifying setup)

RUM으로 APM 통합을 구성했는지 확인하려면 RUM을 설치한 SDK에 따라 다음 단계를 따르세요.

{% tab title="Browser" %}

  1. 애플리케이션의 페이지를 방문해요.
  2. 브라우저 개발자 도구에서 Network 탭으로 이동해요.
  3. 상관관계가 있어야 할 리소스 요청의 요청 헤더에 Datadog의 상관관계 헤더가 포함되어 있는지 확인해요.

{% /tab %}

{% tab title="Android" %}

  1. Android Studio에서 애플리케이션을 실행해요.
  2. 애플리케이션의 화면을 방문해요.
  3. Android Studio의 네트워크 검사기 (Network Inspector)를 열어요.
  4. RUM 리소스의 요청 헤더를 확인하고 SDK가 필요한 헤더를 설정했는지 검증해요.

{% /tab %}

{% tab title="iOS" %}

  1. Xcode에서 애플리케이션을 실행해요.
  2. 애플리케이션의 화면을 방문해요.
  3. Xcode의 Network Connections and HTTP Traffic instrument를 열어요.
  4. RUM 리소스의 요청 헤더를 확인하고 SDK가 필요한 헤더를 설정했는지 검증해요.

{% /tab %}

{% tab title="React Native" %}

  1. Xcode(iOS) 또는 Android Studio(Android)에서 애플리케이션을 실행해요.
  2. 애플리케이션의 화면을 방문해요.
  3. Xcode의 Network Connections and HTTP Traffic instrument 또는 Android Studio의 네트워크 검사기 (Network Inspector)를 열어요.
  4. RUM 리소스의 요청 헤더를 확인하고 SDK가 필요한 헤더를 설정했는지 검증해요.

{% /tab %}

{% tab title="Flutter" %}

  1. 선호하는 IDE 또는 flutter run으로 애플리케이션을 실행해요.
  2. 애플리케이션의 화면을 방문해요.
  3. Flutter의 Dev Tools를 열고 Network View로 이동해요.
  4. RUM 리소스의 요청 헤더를 확인하고 SDK가 필요한 헤더를 설정했는지 검증해요.

{% /tab %}

{% tab title="Kotlin Multiplatform" %}

  1. Xcode(iOS) 또는 Android Studio(Android)에서 애플리케이션을 실행해요.
  2. 애플리케이션의 화면을 방문해요.
  3. Xcode의 Network Connections and HTTP Traffic instrument 또는 Android Studio의 네트워크 검사기 (Network Inspector)를 열어요.
  4. RUM 리소스의 요청 헤더를 확인하고 SDK가 필요한 헤더를 설정했는지 검증해요.

{% /tab %}

RUM Explorer에서 트레이스로 (RUM Explorer to Traces)

{% image source="https://docs.dd-static.net/images/real_user_monitoring/connect_rum_and_traces/rum-trace-apm-link.34b60fa384659e9bd5230f03794afd0a.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/real_user_monitoring/connect_rum_and_traces/rum-trace-apm-link.34b60fa384659e9bd5230f03794afd0a.png?auto=format&fit=max&w=850&dpr=2 2x" alt="RUM and Traces" /%}

RUM Explorer에서 트레이스를 보려면:

  1. 세션 목록으로 이동하고 트레이스가 있는 세션을 클릭해요. @_dd.trace_id:*를 사용해 트레이스가 있는 리소스를 쿼리할 수도 있어요.

세션을 선택하면 요청 기간 분류, 각 스팬의 플레임 그래프, View Trace in APM 링크가 있는 세션 패널이 나타나요.

트레이스에서 RUM Explorer로 (Traces to RUM Explorer)

{% image source="https://docs.dd-static.net/images/real_user_monitoring/connect_rum_and_traces/rum-traces-to-rum.5866e11511b33bb0f2b3d4dd2cad7936.png?auto=format&fit=max&w=850 1x, https://docs.dd-static.net/images/real_user_monitoring/connect_rum_and_traces/rum-traces-to-rum.5866e11511b33bb0f2b3d4dd2cad7936.png?auto=format&fit=max&w=850&dpr=2 2x" alt="RUM and Traces" /%}

트레이스에서 RUM 이벤트를 보려면:

  1. 트레이스 뷰 내에서 VIEW를 클릭해 뷰의 수명 동안 생성된 모든 트레이스를 보거나, RESOURCE를 클릭해 Overview 탭에서 특정 리소스와 연결된 트레이스를 봐요.
  2. See View in RUM 또는 See Resource in RUM을 클릭해 RUM Explorer에서 해당 이벤트를 열어요.

지원 라이브러리 (Supported libraries)

아래는 네트워크 요청을 수신하는 서비스에 있어야 하는 지원 백엔드 라이브러리 목록이에요.

라이브러리 (Library) 최소 버전 (Minimum Version)
Python 0.22.0
Go 1.10.0
Java 0.24.1
Ruby 0.20.0
JavaScript 0.10.0
PHP 0.33.0
.NET 1.18.2

OpenTelemetry 지원 (OpenTelemetry support)

RUM은 OpenTelemetry 라이브러리로 계측된 백엔드에 리소스를 연결하기 위해 여러 프로파게이터 유형을 지원해요.

기본 주입 스타일은 tracecontext, Datadog이에요.

{% tab title="Browser RUM" %} 참고: OpenTelemetry를 사용하는 Next.js/Vercel 같은 백엔드 프레임워크를 사용한다면 다음 단계를 따르세요.

  1. 위에서 설명한 대로 RUM을 APM에 연결하도록 설정해요.

  2. allowedTracingUrls를 다음과 같이 수정해요:

    import { datadogRum } from '@datadog/browser-rum'
    
    datadogRum.init({
        ...otherConfig,
        allowedTracingUrls: [
          { match: "https://api.example.com", propagatorTypes: ["tracecontext"]}
        ]
    })
    

match는 위에서 설명한 단순 형태에서 사용할 때와 동일한 매개변수 유형(string, RegExp 또는 function)을 허용해요.

propagatorTypes는 원하는 프로파게이터의 문자열 목록을 허용해요:

{% /tab %}

{% tab title="iOS RUM" %}

  1. 위에서 설명한 대로 RUM을 APM에 연결하도록 설정해요.

  2. .trace(hosts:sampleRate:) 대신 .traceWithHeaders(hostsWithHeaders:sampleRate:)를 다음과 같이 사용해요:

      RUM.enable(
          with: RUM.Configuration(
              applicationID: "<rum application id>",
              urlSessionTracking: .init(
                  firstPartyHostsTracing: .traceWithHeaders(
                      hostsWithHeaders: [
                          "api.example.com": [.tracecontext]
                      ],
                      sampleRate: 100
                  )
              )
          )
      )
    

.traceWithHeaders(hostsWithHeaders:sampleRate:)는 Dictionary<String, Set<TracingHeaderType>>를 매개변수로 받아요. 여기서 키는 호스트이고 값은 지원되는 추적 헤더 유형 목록이에요.

TracingHeaderType은 다음 추적 헤더 유형을 나타내는 열거형이에요:

{% /tab %}

{% tab title="Android RUM" %}

  1. 위에서 설명한 대로 RUM을 APM에 연결하도록 설정해요.

  2. 사용할 내부 파스트파티 오리진 목록과 추적 헤더 유형으로 OkHttpClient 인터셉터를 다음과 같이 구성해요:

    val tracedHosts = mapOf("example.com" to setOf(TracingHeaderType.TRACECONTEXT),
                          "example.eu" to setOf(TracingHeaderType.DATADOG))
    
    val okHttpClient = OkHttpClient.Builder()
        .addInterceptor(DatadogInterceptor.Builder(tracedHosts).build())
        .addNetworkInterceptor(TracingInterceptor.Builder(tracedHosts).build())
        .eventListenerFactory(DatadogEventListener.Factory())
        .build()
    

TracingHeaderType은 다음 추적 헤더 유형을 나타내는 열거형이에요:

{% /tab %}

{% tab title="React Native RUM" %}

  1. RUM을 APM에 연결하도록 설정해요.

  2. 사용할 내부 파스트파티 오리진 목록과 추적 헤더 유형으로 RUM SDK를 다음과 같이 구성해요:

    const config = new DatadogProviderConfiguration(
        // ...
    );
    config.firstPartyHosts = [{
        match: "example.com",
        propagatorTypes: [
            PropagatorType.TRACECONTEXT,
            PropagatorType.DATADOG
        ]
    }];
    

PropagatorType은 다음 추적 헤더 유형을 나타내는 열거형이에요:

{% /tab %}

{% tab title="Flutter RUM" %}

  1. 위에서 설명한 대로 RUM을 APM에 연결하도록 설정해요.

  2. firstPartyHosts 대신 firstPartyHostsWithTracingHeaders를 다음과 같이 사용해요:

    final configuration = DatadogConfiguration(
      // ...
      // added configuration
      firstPartyHostsWithTracingHeaders: {
        'example.com': { TracingHeaderType.tracecontext },
      },
    )..enableHttpTracking()
    

firstPartyHostsWithTracingHeaders는 Map<String, Set<TracingHeaderType>>를 매개변수로 받아요. 여기서 키는 호스트이고 값은 지원되는 추적 헤더 유형 목록이에요.

TracingHeaderType은 다음 추적 헤더 유형을 나타내는 열거형이에요:

{% /tab %}

{% tab title="Kotlin Multiplatform RUM" %}

  1. RUM을 APM에 연결하도록 설정해요.

  2. 사용할 내부 파스트파티 오리진 목록과 추적 헤더 유형으로 RUM SDK를 다음과 같이 구성해요:

    val ktorClient = HttpClient {
        install(
            datadogKtorPlugin(
                tracedHosts = mapOf(
                    "example.com" to setOf(TracingHeaderType.DATADOG),
                    "example.eu" to setOf(TracingHeaderType.DATADOG)
                ),
                traceSampleRate = 100f
            )
        )
    }
    

TracingHeaderType은 다음 추적 헤더 유형을 나타내는 열거형이에요:

{% /tab %}

RUM 리소스가 트레이스에 연결되는 방법 (How RUM resources are linked to traces)

Datadog은 분산 추적 프로토콜을 사용하고 다음 HTTP 헤더를 설정해요. 기본적으로 trace context와 Datadog 특유의 헤더가 모두 사용돼요.

이 헤더들은 해당 프로파게이터 유형이 활성화된 경우에만 추가돼요. 기본적으로 RUM은 trace context와 함께 datadog 프로파게이터를 포함해요. 활성화된 프로파게이터를 보거나 변경하려면 OpenTelemetry 지원을 참고해요.

{% tab title="Datadog" %}

{% dl %}

{% dt %} x-datadog-trace-id {% /dt %}

{% dd %} Real User Monitoring SDK에서 생성. Datadog이 추적을 RUM 리소스와 연결할 수 있게 해 줌. {% /dd %}

{% dt %} x-datadog-parent-id {% /dt %}

{% dd %} Real User Monitoring SDK에서 생성. Datadog이 트레이스에서 첫 스팬을 생성할 수 있게 해 줌. {% /dd %}

{% dt %} x-datadog-origin: rum {% /dt %}

{% dd %} Real User Monitoring SDK에서 생성. Datadog이 트레이스의 출처를 감지할 수 있게 해 줌. {% /dd %}

{% dt %} x-datadog-sampling-priority {% /dt %}

{% dd %} Real User Monitoring SDK가 트레이스가 샘플링되었으면 1, 아니면 0으로 설정. {% /dd %}

{% /dl %}

{% /tab %}

{% tab title="W3C Trace Context" %}

{% dl %}

{% dt %} traceparent: [version]-[trace id]-[parent id]-[trace flags] {% /dt %}

{% dd %} version: 현재 사양은 version이 00으로 설정되어 있다고 가정. {% /dd %}

{% dd %} trace id: 128비트 trace ID, 32자 16진수. 출처 trace ID는 APM과의 호환성을 위해 64비트. {% /dd %}

{% dd %} parent id: 64비트 span ID, 16자 16진수. {% /dd %}

{% dd %} trace flags: 샘플링된 경우(01) 또는 샘플링되지 않은 경우(00) {% /dd %}

{% /dl %}

Trace ID 변환: 128비트 W3C trace ID는 원래의 64비트 출처 trace ID에 선행 0을 채워 만들어져요. 이는 W3C Trace Context 사양을 준수하면서 APM과의 호환성을 보장해요. 원래의 64비트 trace ID는 128비트 W3C trace ID의 하위 64비트가 돼요.

{% dl %}

{% dt %} tracestate: dd=s:[sampling priority];o:[origin] {% /dt %}

{% dd %} dd: Datadog의 공급업체 접두사. {% /dd %}

{% dd %} sampling priority: 트레이스가 샘플링되었으면 1, 아니면 0으로 설정. {% /dd %}

{% dd %} origin: Real User Monitoring에서 생성된 트레이스가 APM Index Span 수에 영향을 주지 않도록 항상 rum으로 설정. {% /dd %}

{% /dl %}

예시:

출처 trace ID (64-bit): 8448eb211c80319c

W3C Trace Context (128-bit): 00000000000000008448eb211c80319c

이 관계는 원래의 64비트 trace ID 8448eb211c80319c에 16개의 선행 0(0000000000000000)이 채워져 128비트 W3C trace ID가 만들어짐을 보여줘요.

{% dl %}

{% dt %} 완전한 traceparent 예시: {% /dt %}

{% dd %} traceparent: 00-00000000000000008448eb211c80319c-b7ad6b7169203331-01 {% /dd %}

{% dd %} tracestate: dd=s:1;o:rum {% /dd %}

{% /dl %}

{% /tab %}

{% tab title="b3 / b3 Multiple Headers" %}

{% dl %}

{% dt %} b3: [trace id]-[span id]-[sampled] {% /dt %}

{% dd %} trace id: 64비트 trace ID, 16자 16진수. {% /dd %}

{% dd %} span id: 64비트 span ID, 16자 16진수. {% /dd %}

{% dd %} sampled: True(1) 또는 False(0) {% /dd %}

{% dt %} b3 단일 헤더 예시: {% /dt %}

{% dd %} b3: 8448eb211c80319c-b7ad6b7169203331-1 {% /dd %}

{% dt %} b3 다중 헤더 예시: {% /dt %}

{% dd %} X-B3-TraceId: 8448eb211c80319c {% /dd %}

{% dd %} X-B3-SpanId: b7ad6b7169203331 {% /dd %}

{% dd %} X-B3-Sampled: 1 {% /dd %}

{% /dl %}

{% /tab %}

이 HTTP 헤더는 CORS 허용 목록에 없으므로, SDK가 모니터링하도록 설정된 요청을 처리하는 서버에서 Access-Control-Allow-Headers를 구성해야 해요. 서버는 또한 브라우저가 사이트 간 URL에서 추적이 허용될 때 모든 요청 전에 만드는 사전 요청 (preflight requests)(OPTIONS 요청)을 수락해야 해요.

트레이스 보존 (Trace retention)

수집된 트레이스는 Live Search 탐색기에서 15분 동안 사용할 수 있어요. 더 긴 기간 동안 트레이스를 보존하려면 APM 보존 필터를 생성해요. 이 보존 필터를 아무 스팬 태그에 범위를 지정해 중요 페이지와 사용자 동작에 대한 트레이스를 보존해요.

RUM Without Limits를 사용한다면 교차 제품 보존 필터 (cross-product retention filters)를 사용해 특정 RUM 세션과 연결된 APM 트레이스를 보존해 프론트엔드와 백엔드 간 상관관계를 최적화할 수도 있어요. 기본적으로 RUM 세션과 해당 트레이스의 1%는 추가 비용 없이 자동으로 보존돼요.

APM 할당량에 미치는 영향 (Effect on APM quotas)

RUM과 트레이스를 연결하면 APM 수집 볼륨이 크게 늘어날 수 있어요. traceSampleRate 초기화 매개변수를 사용해 브라우저와 모바일 요청에서 시작되는 백엔드 트레이스의 수집 비율을 제어해요.

교차 제품 보존 필터를 구성하면 APM 인덱스 볼륨도 늘어날 수 있어요. 교차 제품 보존 필터의 보존 비율을 사용해 인덱싱할 백엔드 트레이스의 비율을 제어해요.

더 알아보기 (Learn more)

도움이 되는 추가 문서, 링크, 아티클이에요: