diff --git a/Examples/ConcurrencyContext/main.swift b/Examples/ConcurrencyContext/main.swift index b23a82e1..12fa824a 100644 --- a/Examples/ConcurrencyContext/main.swift +++ b/Examples/ConcurrencyContext/main.swift @@ -14,7 +14,7 @@ let sampleValue = "sampleValue" // On Apple platforms, the default is the activity based context manager. We want to opt-in to the structured concurrency based context manager instead. OpenTelemetry.registerDefaultConcurrencyContextManager() -let stdout = StdoutExporter() +let stdout = StdoutSpanExporter() OpenTelemetry.registerTracerProvider( tracerProvider: TracerProviderBuilder().add( spanProcessor: SimpleSpanProcessor(spanExporter: stdout) @@ -30,7 +30,7 @@ extension Task where Failure == Never, Success == Never { } func simpleSpan() async throws { - let span = tracer.spanBuilder(spanName: "SimpleSpan").setSpanKind(spanKind: .client).startSpan() + let span = await tracer.spanBuilder(spanName: "SimpleSpan").setSpanKind(spanKind: .client).startSpan() span.setAttribute(key: sampleKey, value: sampleValue) try await Task.sleep(seconds: 0.5) span.end() @@ -42,7 +42,7 @@ func childSpan() async throws { span.setAttribute(key: sampleKey, value: sampleValue) await Task.detached { // A detached task doesn't inherit the task local context, so this span won't have a parent. - let notAChildSpan = tracer.spanBuilder(spanName: "notAChild").setSpanKind(spanKind: .client).startSpan() + let notAChildSpan = await tracer.spanBuilder(spanName: "notAChild").setSpanKind(spanKind: .client).startSpan() notAChildSpan.setAttribute(key: sampleKey, value: sampleValue) notAChildSpan.end() }.value @@ -50,7 +50,7 @@ func childSpan() async throws { try await Task { // Normal tasks should still inherit the context. try await Task.sleep(seconds: 0.2) - let childSpan = tracer.spanBuilder(spanName: "childSpan").setSpanKind(spanKind: .client).startSpan() + let childSpan = await tracer.spanBuilder(spanName: "childSpan").setSpanKind(spanKind: .client).startSpan() childSpan.setAttribute(key: sampleKey, value: sampleValue) try await Task.sleep(seconds: 0.5) childSpan.end() diff --git a/Examples/Logs Sample/main.swift b/Examples/Logs Sample/main.swift index 3995c820..326f3e25 100644 --- a/Examples/Logs Sample/main.swift +++ b/Examples/Logs Sample/main.swift @@ -17,9 +17,6 @@ func configure() { target: .hostAndPort("localhost", 4317), eventLoopGroup: MultiThreadedEventLoopGroup(numberOfThreads: 1)) - - OtlpLogExporter(channel: ClientConnection(configuration: configuration)) - OpenTelemetry.registerLoggerProvider(loggerProvider: LoggerProviderBuilder().with(processors: [ BatchLogRecordProcessor(logRecordExporter:OtlpLogExporter(channel: ClientConnection(configuration: configuration)))]).build()) diff --git a/Examples/OTLP Exporter/main.swift b/Examples/OTLP Exporter/main.swift index 1eb3ad3d..b904100b 100644 --- a/Examples/OTLP Exporter/main.swift +++ b/Examples/OTLP Exporter/main.swift @@ -32,7 +32,7 @@ let configuration = ClientConnection.Configuration.default( let client = ClientConnection(configuration: configuration) let otlpTraceExporter = OtlpTraceExporter(channel: client) -let stdoutExporter = StdoutExporter() +let stdoutExporter = StdoutSpanExporter() let spanExporter = MultiSpanExporter(spanExporters: [otlpTraceExporter, stdoutExporter]) let spanProcessor = SimpleSpanProcessor(spanExporter: spanExporter) diff --git a/Examples/OTLP HTTP Exporter/main.swift b/Examples/OTLP HTTP Exporter/main.swift index 2c818b2d..4639d165 100644 --- a/Examples/OTLP HTTP Exporter/main.swift +++ b/Examples/OTLP HTTP Exporter/main.swift @@ -23,7 +23,7 @@ let instrumentationScopeName = "OTLPHTTPExporter" let instrumentationScopeVersion = "semver:0.1.0" let otlpHttpTraceExporter = OtlpHttpTraceExporter() -let stdoutExporter = StdoutExporter() +let stdoutExporter = StdoutSpanExporter() let spanExporter = MultiSpanExporter(spanExporters: [otlpHttpTraceExporter, stdoutExporter]) let spanProcessor = SimpleSpanProcessor(spanExporter: spanExporter) diff --git a/Examples/Simple Exporter/main.swift b/Examples/Simple Exporter/main.swift index 005b41f1..6ad98822 100644 --- a/Examples/Simple Exporter/main.swift +++ b/Examples/Simple Exporter/main.swift @@ -23,7 +23,7 @@ let instrumentationScopeVersion = "semver:0.1.0" var tracer: TracerSdk let jaegerCollectorAddress = "localhost" let jaegerExporter = JaegerSpanExporter(serviceName: "SimpleExporter", collectorAddress: jaegerCollectorAddress) -let stdoutExporter = StdoutExporter() +let stdoutExporter = StdoutSpanExporter() // let zipkinExporterOptions = ZipkinTraceExporterOptions() // let zipkinExporter = ZipkinTraceExporter(options: zipkinExporterOptions) diff --git a/Sources/Instrumentation/URLSession/URLSessionLogger.swift b/Sources/Instrumentation/URLSession/URLSessionLogger.swift index 3c4e291e..bda5788d 100644 --- a/Sources/Instrumentation/URLSession/URLSessionLogger.swift +++ b/Sources/Instrumentation/URLSession/URLSessionLogger.swift @@ -158,7 +158,7 @@ class URLSessionLogger { } instrumentation.configuration.injectCustomHeaders?(&request, span) var instrumentedRequest = request - objc_setAssociatedObject(instrumentedRequest, &URLSessionInstrumentation.instrumentedKey, true, .OBJC_ASSOCIATION_COPY_NONATOMIC) + objc_setAssociatedObject(instrumentedRequest, URLSessionInstrumentation.instrumentedKey, true, .OBJC_ASSOCIATION_COPY_NONATOMIC) let propagators = OpenTelemetry.instance.propagators var traceHeaders = tracePropagationHTTPHeaders(span: span, textMapPropagator: propagators.textMapPropagator, textMapBaggagePropagator: propagators.textMapBaggagePropagator) if let originalHeaders = request.allHTTPHeaderFields { diff --git a/Sources/OpenTelemetrySdk/Metrics/Stable/CallbackRegistration.swift b/Sources/OpenTelemetrySdk/Metrics/Stable/CallbackRegistration.swift index 522e3715..096fa7d3 100644 --- a/Sources/OpenTelemetrySdk/Metrics/Stable/CallbackRegistration.swift +++ b/Sources/OpenTelemetrySdk/Metrics/Stable/CallbackRegistration.swift @@ -27,11 +27,11 @@ public class CallbackRegistration { if !hasStorages { return } - for var measurement in observableMeasurements { + for measurement in observableMeasurements { measurement.setActiveReader(reader: reader, startEpochNanos: startEpochNanos, epochNanos: epochNanos) } callback() - for var measurement in observableMeasurements { + for measurement in observableMeasurements { measurement.clearActiveReader() } } diff --git a/Sources/OpenTelemetrySdk/Metrics/Stable/State/AsynchronousMetricStorage.swift b/Sources/OpenTelemetrySdk/Metrics/Stable/State/AsynchronousMetricStorage.swift index 535786cb..b7116168 100644 --- a/Sources/OpenTelemetrySdk/Metrics/Stable/State/AsynchronousMetricStorage.swift +++ b/Sources/OpenTelemetrySdk/Metrics/Stable/State/AsynchronousMetricStorage.swift @@ -42,7 +42,7 @@ public class AsynchronousMetricStorage: MetricStorage { let newMeasurement = measurement.hasDoubleValue ? Measurement.doubleMeasurement(startEpochNano: start, endEpochNano: measurement.epochNano, value: measurement.doubleValue, attributes: processedAttributes) : Measurement.longMeasurement(startEpochNano: start, endEpochNano: measurement.epochNano, value: measurement.longValue, attributes: processedAttributes) do { try recordPoint(point: aggregator.toPoint(measurement: newMeasurement)) - } catch let HistogramAggregatorError.unsupportedOperation(error) { + } catch HistogramAggregatorError.unsupportedOperation(_) { // TODO: log error } catch { // TODO: log default error @@ -65,7 +65,7 @@ public class AsynchronousMetricStorage: MetricStorage { public func collect(resource: Resource, scope: InstrumentationScopeInfo, startEpochNanos: UInt64, epochNanos: UInt64) -> StableMetricData { var result: [[String: AttributeValue]: PointData] if aggregationTemporality == .delta { - var points = self.points + let points = self.points var lastPoints = self.lastPoints lastPoints = lastPoints.filter { element in points[element.key] == nil // remove if points does not contain key diff --git a/Tests/ExportersTests/DatadogExporter/Spans/SpansExporterTests.swift b/Tests/ExportersTests/DatadogExporter/Spans/SpansExporterTests.swift index b0db28c5..6c2527f0 100644 --- a/Tests/ExportersTests/DatadogExporter/Spans/SpansExporterTests.swift +++ b/Tests/ExportersTests/DatadogExporter/Spans/SpansExporterTests.swift @@ -18,9 +18,6 @@ class SpansExporterTests: XCTestCase { } func testWhenExportSpanIsCalled_thenTraceIsUploaded() throws { -#if os(watchOS) - throw XCTSkip("Test is flaky on watchOS") -#endif throw XCTSkip("Skipped flaky test.") var tracesSent = false let expec = expectation(description: "traces received") diff --git a/Tests/ExportersTests/OpenTelemetryProtocol/OtlpTraceExporterTests.swift b/Tests/ExportersTests/OpenTelemetryProtocol/OtlpTraceExporterTests.swift index e8531e99..e5f8e34d 100644 --- a/Tests/ExportersTests/OpenTelemetryProtocol/OtlpTraceExporterTests.swift +++ b/Tests/ExportersTests/OpenTelemetryProtocol/OtlpTraceExporterTests.swift @@ -13,7 +13,7 @@ import OpenTelemetryProtocolExporterCommon @testable import OpenTelemetrySdk import XCTest -extension String: LocalizedError { +extension Swift.String: LocalizedError { public var errorDescription: String? { return self } } diff --git a/Tests/OpenTelemetrySdkTests/Logs/BatchLogRecordProcessorTests.swift b/Tests/OpenTelemetrySdkTests/Logs/BatchLogRecordProcessorTests.swift index 0ad796d1..44413f2f 100644 --- a/Tests/OpenTelemetrySdkTests/Logs/BatchLogRecordProcessorTests.swift +++ b/Tests/OpenTelemetrySdkTests/Logs/BatchLogRecordProcessorTests.swift @@ -56,7 +56,7 @@ class BatchLogRecordProcessorTests : XCTestCase { for _ in 0 ..< 100 { logger.logRecordBuilder().emit() } - _ = processor.forceFlush() + processor.forceFlush() let exported = waitingExporter.waitForExport() XCTAssertEqual(exported?.count, 100) XCTAssertEqual(waitingExporter.exporter.exportCalledTimes, 1)