Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enabled library evolution for API package #541

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .github/workflows/BuildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ jobs:
macOS:
runs-on: macos-14
steps:
- uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
with:
xcode-version: latest-stable
- uses: actions/checkout@v2
- name: Build and Test for macOS
run: swift test --enable-code-coverage
Expand Down
3 changes: 2 additions & 1 deletion [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ let package = Package(
],
targets: [
.target(name: "OpenTelemetryApi",
dependencies: []),
dependencies: [],
swiftSettings: [.unsafeFlags(["-enable-library-evolution"])]),
.target(name: "OpenTelemetrySdk",
dependencies: ["OpenTelemetryApi"]),
.target(name: "ResourceExtension",
Expand Down
120 changes: 60 additions & 60 deletions Tests/ExportersTests/DatadogExporter/DatadogExporterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,64 +98,64 @@ class DatadogExporterTests: XCTestCase {
span.end()
}

func testWhenExportMetricIsCalled_thenMetricsAreUploaded() throws {
#if os(watchOS)
throw XCTSkip("Test is flaky on watchOS")
#endif

var metricsSent = false
let expecMetrics = expectation(description: "metrics received")
expecMetrics.assertForOverFulfill = false

let server = HttpTestServer(url: URL(string: "http://localhost:33333"),
config: HttpTestServerConfig(metricsReceivedCallback: {
metricsSent = true
expecMetrics.fulfill()
}))

let sem = DispatchSemaphore(value: 0)
DispatchQueue.global(qos: .default).async {
do {
try server.start(semaphore: sem)
} catch {
XCTFail()
return
}
}
sem.wait()

let exporterConfiguration = ExporterConfiguration(serviceName: "serviceName",
resource: "resource",
applicationName: "applicationName",
applicationVersion: "applicationVersion",
environment: "environment",
apiKey: "apikey",
endpoint: Endpoint.custom(
tracesURL: URL(string: "http://localhost:33333/traces")!,
logsURL: URL(string: "http://localhost:33333/logs")!,
metricsURL: URL(string: "http://localhost:33333/metrics")!),
uploadCondition: { true })

let datadogExporter = try! DatadogExporter(config: exporterConfiguration)

let provider = MeterProviderSdk(metricProcessor: MetricProcessorSdk(),
metricExporter: datadogExporter,
metricPushInterval: 0.1)

let meter = provider.get(instrumentationName: "MyMeter")

let testCounter = meter.createIntCounter(name: "MyCounter")

testCounter.add(value: 100, labelset: LabelSet.empty)

let result = XCTWaiter().wait(for: [expecMetrics], timeout: 20)

if result == .completed {
XCTAssertTrue(metricsSent)
} else {
XCTFail()
}

server.stop()
}
// func testWhenExportMetricIsCalled_thenMetricsAreUploaded() throws {
//#if os(watchOS)
// throw XCTSkip("Test is flaky on watchOS")
//#endif
//
// var metricsSent = false
// let expecMetrics = expectation(description: "metrics received")
// expecMetrics.assertForOverFulfill = false
//
// let server = HttpTestServer(url: URL(string: "http://localhost:33333"),
// config: HttpTestServerConfig(metricsReceivedCallback: {
// metricsSent = true
// expecMetrics.fulfill()
// }))
//
// let sem = DispatchSemaphore(value: 0)
// DispatchQueue.global(qos: .default).async {
// do {
// try server.start(semaphore: sem)
// } catch {
// XCTFail()
// return
// }
// }
// sem.wait()
//
// let exporterConfiguration = ExporterConfiguration(serviceName: "serviceName",
// resource: "resource",
// applicationName: "applicationName",
// applicationVersion: "applicationVersion",
// environment: "environment",
// apiKey: "apikey",
// endpoint: Endpoint.custom(
// tracesURL: URL(string: "http://localhost:33333/traces")!,
// logsURL: URL(string: "http://localhost:33333/logs")!,
// metricsURL: URL(string: "http://localhost:33333/metrics")!),
// uploadCondition: { true })
//
// let datadogExporter = try! DatadogExporter(config: exporterConfiguration)
//
// let provider = MeterProviderSdk(metricProcessor: MetricProcessorSdk(),
// metricExporter: datadogExporter,
// metricPushInterval: 0.1)
//
// let meter = provider.get(instrumentationName: "MyMeter")
//
// let testCounter = meter.createIntCounter(name: "MyCounter")
//
// testCounter.add(value: 100, labelset: LabelSet.empty)
//
// let result = XCTWaiter().wait(for: [expecMetrics], timeout: 20)
//
// if result == .completed {
// XCTAssertTrue(metricsSent)
// } else {
// XCTFail()
// }
//
// server.stop()
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class DataExportWorkerTests: XCTestCase {
// When
let fileReader = FileReaderMock()
let mockDataExporter = DataExporterMock(exportStatus: .mockWith(needsRetry: false))

let worker = DataExportWorker(
fileReader: fileReader,
dataExporter: mockDataExporter,
Expand Down
Loading