Skip to content

Commit

Permalink
Merge branch 'main' into json-decode-foundation
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler authored Jan 7, 2025
2 parents d70de8c + 5b33101 commit f91aba9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-metrics.git", from: "2.5.0"),
.package(url: "https://github.com/apple/swift-distributed-tracing.git", from: "1.0.1"),
.package(url: "https://github.com/apple/swift-distributed-tracing.git", from: "1.1.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.63.0"),
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.20.0"),
.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.34.1"),
Expand Down
19 changes: 1 addition & 18 deletions Sources/Hummingbird/Middleware/TracingMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public struct TracingMiddleware<Context: RequestContext>: RouterMiddleware {
// span name is updated after route has run
let operationName = "HTTP \(request.method.rawValue) route not found"

let span = InstrumentationSystem.tracer.startSpan(operationName, context: serviceContext, ofKind: .server)
let span = startSpan(operationName, context: serviceContext, ofKind: .server)
span.updateAttributes { attributes in
if let staticAttributes = self.attributes {
attributes.merge(staticAttributes)
Expand Down Expand Up @@ -176,20 +176,3 @@ private struct HTTPHeadersExtractor: Extractor {
return headers[headerName]
}
}

extension Span {
/// Update Span attributes in a block instead of individually
///
/// Updating a span attribute will involve some type of thread synchronisation
/// primitive to avoid multiple threads updating the attributes at the same
/// time. If you update each attributes individually this could cause slowdown.
/// This function updates the attributes in one call to avoid hitting the
/// thread synchronisation code multiple times
///
/// - Parameter update: closure used to update span attributes
func updateAttributes(_ update: (inout SpanAttributes) -> Void) {
var attributes = self.attributes
update(&attributes)
self.attributes = attributes
}
}
2 changes: 1 addition & 1 deletion Sources/Hummingbird/Utils/DateCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ final class DateCache: Service {
var formatted = day
formatted.reserveCapacity(30)
formatted += ", "
formatted += timeStruct.tm_mday.description
formatted += self.numberNames[numericCast(timeStruct.tm_mday)]
formatted += " "
formatted += month
formatted += " "
Expand Down
2 changes: 1 addition & 1 deletion Tests/HummingbirdTests/DateCacheTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class DateTests: XCTestCase {
func testRFC1123Renderer() {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.dateFormat = "EEE, d MMM yyy HH:mm:ss z"
formatter.dateFormat = "EEE, dd MMM yyy HH:mm:ss z"
formatter.timeZone = TimeZone(secondsFromGMT: 0)

for _ in 0..<1000 {
Expand Down

0 comments on commit f91aba9

Please sign in to comment.