Skip to content

Commit b7ce62f

Browse files
committed
Formatting
1 parent b697ad5 commit b7ce62f

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

Sources/GRPCInterceptors/Tracing/ServerOTelTracingInterceptor.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public struct ServerOTelTracingInterceptor: ServerInterceptor {
6868
request: StreamingServerRequest<Input>,
6969
context: ServerContext,
7070
next: @Sendable (StreamingServerRequest<Input>, ServerContext) async throws ->
71-
StreamingServerResponse<Output>
71+
StreamingServerResponse<Output>
7272
) async throws -> StreamingServerResponse<Output> where Input: Sendable, Output: Sendable {
7373
try await self.intercept(
7474
tracer: InstrumentationSystem.tracer,
@@ -116,7 +116,8 @@ public struct ServerOTelTracingInterceptor: ServerInterceptor {
116116
wrapping: request.messages.map { element in
117117
var event = SpanEvent(name: "rpc.message")
118118
event.attributes[GRPCTracingKeys.rpcMessageType] = "RECEIVED"
119-
event.attributes[GRPCTracingKeys.rpcMessageID] = messageReceivedCounter
119+
event.attributes[GRPCTracingKeys.rpcMessageID] =
120+
messageReceivedCounter
120121
.wrappingAdd(1, ordering: .sequentiallyConsistent)
121122
.oldValue
122123
span.addEvent(event)
@@ -139,7 +140,8 @@ public struct ServerOTelTracingInterceptor: ServerInterceptor {
139140
afterEachWrite: {
140141
var event = SpanEvent(name: "rpc.message")
141142
event.attributes[GRPCTracingKeys.rpcMessageType] = "SENT"
142-
event.attributes[GRPCTracingKeys.rpcMessageID] = messageSentCounter
143+
event.attributes[GRPCTracingKeys.rpcMessageID] =
144+
messageSentCounter
143145
.wrappingAdd(1, ordering: .sequentiallyConsistent)
144146
.oldValue
145147
span.addEvent(event)

Tests/GRPCInterceptorsTests/OTelTracingInterceptorTests.swift

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import GRPCCore
1818
import GRPCInterceptors
1919
import Testing
2020
import Tracing
21+
2122
import struct Foundation.UUID
2223

2324
@Suite("OTel Tracing Client Interceptor Tests")
@@ -605,8 +606,8 @@ struct OTelTracingServerInterceptorTests {
605606
await assertStreamContentsEqual(["response1", "response2"], responseStream)
606607

607608
assertTestSpanComponents(forMethod: methodDescriptor, tracer: self.tracer) { events in
608-
#expect(events ==
609-
[
609+
#expect(
610+
events == [
610611
// Recorded when request is received
611612
TestSpanEvent("rpc.message", ["rpc.message.type": "RECEIVED", "rpc.message.id": 1]),
612613
// Recorded when `response1` is sent
@@ -708,20 +709,22 @@ struct OTelTracingServerInterceptorTests {
708709
assertTestSpanComponents(forMethod: methodDescriptor, tracer: self.tracer) { events in
709710
#expect(events.isEmpty)
710711
} assertAttributes: { attributes in
711-
#expect(attributes == [
712-
"rpc.system": "grpc",
713-
"rpc.method": .string(methodDescriptor.method),
714-
"rpc.service": .string(methodDescriptor.service.fullyQualifiedService),
715-
"rpc.grpc.status_code": 14, // this is unavailable's raw code
716-
"server.address": "someserver.com",
717-
"server.port": 123,
718-
"network.peer.address": "10.1.2.90",
719-
"network.peer.port": 123,
720-
"network.transport": "tcp",
721-
"network.type": "ipv4",
722-
"client.address": "10.1.2.80",
723-
"client.port": 567,
724-
])
712+
#expect(
713+
attributes == [
714+
"rpc.system": "grpc",
715+
"rpc.method": .string(methodDescriptor.method),
716+
"rpc.service": .string(methodDescriptor.service.fullyQualifiedService),
717+
"rpc.grpc.status_code": 14, // this is unavailable's raw code
718+
"server.address": "someserver.com",
719+
"server.port": 123,
720+
"network.peer.address": "10.1.2.90",
721+
"network.peer.port": 123,
722+
"network.transport": "tcp",
723+
"network.type": "ipv4",
724+
"client.address": "10.1.2.80",
725+
"client.port": 567,
726+
]
727+
)
725728
} assertStatus: { status in
726729
#expect(status == .some(.init(code: .error)))
727730
} assertErrors: { errors in
@@ -792,11 +795,14 @@ struct OTelTracingServerInterceptorTests {
792795

793796
// - MARK: Utilities
794797

795-
fileprivate func getTestSpanForMethod(tracer: TestTracer, methodDescriptor: MethodDescriptor) -> TestSpan {
798+
private func getTestSpanForMethod(
799+
tracer: TestTracer,
800+
methodDescriptor: MethodDescriptor
801+
) -> TestSpan {
796802
tracer.getSpan(ofOperation: methodDescriptor.fullyQualifiedMethod)!
797803
}
798804

799-
fileprivate func assertTestSpanComponents(
805+
private func assertTestSpanComponents(
800806
forMethod method: MethodDescriptor,
801807
tracer: TestTracer,
802808
assertEvents: ([TestSpanEvent]) -> Void,
@@ -811,7 +817,7 @@ fileprivate func assertTestSpanComponents(
811817
assertErrors(span.errors)
812818
}
813819

814-
fileprivate func assertStreamContentsEqual<T: Equatable>(
820+
private func assertStreamContentsEqual<T: Equatable>(
815821
_ array: [T],
816822
_ stream: any AsyncSequence<T, any Error>
817823
) async throws {
@@ -822,7 +828,7 @@ fileprivate func assertStreamContentsEqual<T: Equatable>(
822828
#expect(streamElements == array)
823829
}
824830

825-
fileprivate func assertStreamContentsEqual<T: Equatable>(
831+
private func assertStreamContentsEqual<T: Equatable>(
826832
_ array: [T],
827833
_ stream: any AsyncSequence<T, Never>
828834
) async {

0 commit comments

Comments
 (0)