DataDog / dd-sdk-ios

Datadog SDK for iOS - Swift and Objective-C.
Apache License 2.0
220 stars 128 forks source link

Datadog v2.6.0 not sending trace to the dashboard #1634

Closed asetiyadi-MLB closed 10 months ago

asetiyadi-MLB commented 10 months ago

Describe the bug

We have iOS application (target iOS 16 and up) and are upgrading DD from v1.2.x to v2.6.0 and noticing that Trace is no longer sending data to dashboard (APM - Traces dashboard). The Logs - Analytics and RUM session work fine.

The setup is as follows:

fileprivate static func bootstrapOnce() {
      let core = Datadog.initialize(
        with: Datadog.Configuration(
          clientToken: configuration.clientToken,
          env: configuration.environment,
          site: configuration.endpoint),
        trackingConsent: .granted)

      Datadog.verbosityLevel = .debug

      Logs.enable(in: core)
      Trace.enable(in: core)

      let firstPartyHostsTracing = RUM.Configuration
        .URLSessionTracking.FirstPartyHostsTracing.trace(hosts: Set(configuration.tracedURLs))
      let urlSessionTracking = RUM.Configuration
        .URLSessionTracking(firstPartyHostsTracing: firstPartyHostsTracing)

      RUM.enable(
        with: RUM.Configuration(
          applicationID: configuration.rumApplicationID,
          uiKitViewsPredicate: DefaultUIKitRUMViewsPredicate(),
          uiKitActionsPredicate: DefaultUIKitRUMActionsPredicate(),
          urlSessionTracking: urlSessionTracking),
        in: core)
    }

The Datadog.Configuration has the following setup:

(Configuration(tracedURLs: ["qa-ids.xyz.com", "profile.xyz.com", "profile-qa.xyz.com", "xyzinfra.com", "xyz.com", "xyz.com", "bp-ingress-register-lx6pt6v5ra-ue.a.run.app", "ids.xyz.com"], rumApplicationID: "<rum-application-id>", clientToken: "<client-token>", endpoint: DatadogInternal.DatadogSite.us5, environment: "qa")) 

We turned on the Datadog.verbosityLevel = .debug and noticing the following:

[DATADOG SDK] 🐶 → 09:06:49.138 ⏳ (rum) Uploading batches...
[DATADOG SDK] 🐶 → 09:06:49.138 💡 (logging) No upload. Batch to upload: NO, System conditions: ✅
[DATADOG SDK] 🐶 → 09:06:49.139 Skipping RUMViewEvent with id: 97c701e5-0499-4a24-98dd-4a00cdfb1673 and versions: 1
[DATADOG SDK] 🐶 → 09:06:49.139 💡 (tracing) No upload. Batch to upload: NO, System conditions: ✅
[DATADOG SDK] 🐶 → 09:06:49.139 Skipping RUMViewEvent with id: 6f92fb87-2e99-4d64-9156-6cc19a199c6a and versions: 1
[DATADOG SDK] 🐶 → 09:06:49.139 Skipping RUMViewEvent with id: e1b357f5-1e99-450e-99e5-57744f6454c1 and versions: 1, 2, 3
[DATADOG SDK] 🐶 → 09:06:49.139 Skipping RUMViewEvent with id: 6f4240bb-665e-4e4f-b4b4-636c6aa2e661 and versions: 1
[DATADOG SDK] 🐶 → 09:06:49.596    → (rum) accepted, won't be retransmitted: [response code: 202 (accepted), request ID: 72BC0540-60D5-4A0B-884A-344651320008]
[DATADOG SDK] 🐶 → 09:07:09.113 ⏳ (rum) Uploading batches...
[DATADOG SDK] 🐶 → 09:07:09.116 Skipping RUMViewEvent with id: f031e7ac-03f3-42bb-8f17-8276d7d975a5 and versions: 2
[DATADOG SDK] 🐶 → 09:07:09.307    → (rum) accepted, won't be retransmitted: [response code: 202 (accepted), request ID: 906F7560-78FF-4259-BA04-10CFA54D6463]
[DATADOG SDK] 🐶 → 09:07:09.307 💡 (tracing) No upload. Batch to upload: NO, System conditions: ✅
[DATADOG SDK] 🐶 → 09:07:09.308 ⏳ (logging) Uploading batches...
[DATADOG SDK] 🐶 → 09:07:09.535    → (logging) accepted, won't be retransmitted: [response code: 202 (accepted), request ID: ABB2C3AD-216C-4C1D-85DD-3CE0D21E7FE5]
[DATADOG SDK] 🐶 → 09:07:27.141 💡 (rum) No upload. Batch to upload: NO, System conditions: ✅
[DATADOG SDK] 🐶 → 09:07:29.341 💡 (logging) No upload. Batch to upload: NO, System conditions: ✅
[DATADOG SDK] 🐶 → 09:07:29.342 💡 (tracing) No upload. Batch to upload: NO, System conditions: ✅

Expected behavior

Trace data should be sent to dashboard and visible in APM - Traces


Datadog SDK version:

v2.6.0

Last working Datadog SDK version:

v.1.2.x

Dependency Manager:

.package(url: "https://github.com/DataDog/dd-sdk-ios.git", .upToNextMajor(from: "2.6.0")),

Other toolset:

No

Xcode version:

Xcode 15.1.0

Swift version:

(swift-tools-version: 5.9)

Deployment Target:

iOS 16 and up.

maxep commented 10 months ago

Hi @asetiyadi-MLB ! Thank you for the report.

Are you trying to instrument distributed tracing or local traces? If you are looking for distributed tracing, you also need to enable the network instrumentation which seems to be missing in your configuration:

URLSessionInstrumentation.enable(
    with: .init(
        delegateClass: SessionDelegate.self
    )
)

let session = URLSession(
    configuration: .default,
    delegate: SessionDelegate(),
    delegateQueue: nil
)

If you are looking for local traces, could you share a snippet showing how you create and finish a span?

Thanks!

asetiyadi-MLB commented 10 months ago

@maxep Thank you for the pointer. We are using distributed tracing and that's exactly the part that I missed when migrating from 1.2.x to 2.6.0. It is working now. 🙏🏼