Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions DatadogSDKTesting-unexported-symbols.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Symbols to hide (make local / private_extern) in DatadogSDKTesting.framework.
#
# WHY: every dependency we statically link into the framework exports its
# symbols by default. When a project-under-test links its OWN copy of the same
# dependency (e.g. opentelemetry-swift), dyld coalesces the duplicate weak
# type-metadata symbols to a single definition process-wide. If the two copies
# differ in version/layout, one image ends up reading objects through the
# other's metadata -> `swift_getObjectType` walks a bad pointer -> SEGV_ACCERR.
# Marking these symbols non-exported stops dyld from coalescing them: each image
# binds to its own copy. Only the public DatadogSDKTesting API stays exported.
#
# Passed to ld64 via `-unexported_symbols_list` (see UNEXPORTED_SYMBOLS_FILE /
# OTHER_LDFLAGS on the framework target). Patterns use fnmatch globs and are
# matched against the full mangled symbol name (leading underscore included).
#
# CAVEAT: this only prevents dyld symbol coalescing. It does NOT change the
# mangled names, so name-keyed Swift runtime lookups (dynamic casts, Codable,
# NSClassFromString) can still cross images in rare cases. For a hard guarantee
# use module renaming instead. See the OpenTelemetry-isolation discussion.
#
# NOTE: Swift mangles the module name as a length-prefixed component
# (e.g. `16OpenTelemetryApi`, 16 == strlen). It appears not only at the start of
# symbols the module DEFINES but also mid-string in every symbol that REFERENCES
# one of its types, so the globs are intentionally unanchored (`*...*`).
# Keying on the length prefix keeps us from clobbering our own identifiers such
# as `OpenTelemetryContextProvider` (mangled `28OpenTelemetry...`).

# --- opentelemetry-swift-core ---
*16OpenTelemetryApi*
*16OpenTelemetrySdk*

# --- swift-code-coverage ---
*12CodeCoverage*
*21CodeCoverageCollector*
*18CodeCoverageParser*

# --- Kronos ---
*6Kronos*

# --- SigmaSwiftStatistics ---
*20SigmaSwiftStatistics*

# --- EventsExporter (internal SDK module, not part of the public product) ---
*14EventsExporter*

# --- KSCrash (C/ObjC + Swift) ---
# Modules: KSCrashRecording / RecordingCore / RecordingCoreSwift / ReportingCore
# / Core / Filters / Sinks / Installations / DemangleFilter / etc.
# NOTE: hiding C/ObjC symbols stops the linker-level duplicate, but the ObjC
# runtime still registers classes by name and KSCrash installs process-wide
# signal/exception handlers; if a project-under-test also links KSCrash that
# handler-install conflict is a separate concern this list does NOT solve.
# All KSCrash C functions are namespaced under `ks` (`_ksobjc_`, `_kscm_`,
# `_ksjson_`, `_kscrash_`, ...); inline log wrappers are under `_i_ks`.
*KSCrash*
_ks*
_i_ks*
_OBJC_CLASS_$_KS*
_OBJC_METACLASS_$_KS*
2 changes: 2 additions & 0 deletions DatadogSDKTesting.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2775,6 +2775,7 @@
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
UNEXPORTED_SYMBOLS_FILE = "$(SRCROOT)/DatadogSDKTesting-unexported-symbols.txt";
};
name = Debug;
};
Expand Down Expand Up @@ -2816,6 +2817,7 @@
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
UNEXPORTED_SYMBOLS_FILE = "$(SRCROOT)/DatadogSDKTesting-unexported-symbols.txt";
};
name = Release;
};
Expand Down
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,6 @@ You can add custom tags inside your test methods. The static property `DDTest.cu
DDTest.current!.setTag(key: "key1", value: "value1")
```

## Using OpenTelemetry (only for Swift)

The Datadog Swift testing framework uses [OpenTelemetry](https://github.com/open-telemetry/opentelemetry-swift) as the tracing technology under the hood. You can access the OpenTelemetry tracer using `DDInstrumentationControl.openTelemetryTracer` and can use any OpenTelemetry api. For example, for adding a tag/attribute:

```swift
import DatadogSDKTesting
import OpenTelemetryApi

let tracer = DDInstrumentationControl.openTelemetryTracer as? Tracer
let span = tracer?.spanBuilder(spanName: "ChildSpan").startSpan()
span?.setAttribute(key: "OTTag2", value: "OTValue2")
span?.end()
```

The test target needs to link explicitly with `opentelemetry-swift`.

## Using Info.plist for configuration

Alternatively to setting environment variables, all configuration values can be provided by adding them to the `Info.plist` file of the Test bundle (not the App bundle). If the same setting is set both in an environment variable and in the `Info.plist` file, the environment variable takes precedence.
Expand Down
4 changes: 0 additions & 4 deletions Sources/DatadogSDKTesting/DDInstrumentationControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,4 @@ public class DDInstrumentationControl: NSObject {
@objc public static func stopStderrCapture() {
DDTestMonitor.instance?.stopStderrCapture()
}

public static var openTelemetryTracer: AnyObject? {
return DDTestMonitor.instance?.tracer.tracerSdk
}
}
Loading