Skip to content
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
13 changes: 8 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ let dependencies: [Package.Dependency] = [
),
.package(
url: "https://github.com/grpc/grpc-swift-protobuf.git",
exact: "1.0.0-alpha.1"
branch: "main"
),
.package(
url: "https://github.com/apple/swift-protobuf.git",
from: "1.28.1"
),
.package(
url: "https://github.com/apple/swift-distributed-tracing.git",
from: "1.0.0"
from: "1.1.2"
),
]

Expand All @@ -73,7 +73,8 @@ let targets: [Target] = [
dependencies: [
.target(name: "GRPCHealthService"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
]
],
swiftSettings: defaultSwiftSettings
),

// Common interceptors for gRPC.
Expand All @@ -91,7 +92,8 @@ let targets: [Target] = [
.target(name: "GRPCInterceptors"),
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "Tracing", package: "swift-distributed-tracing")
]
],
swiftSettings: defaultSwiftSettings
),

// gRPC interop test implementation.
Expand All @@ -110,7 +112,8 @@ let targets: [Target] = [
.target(name: "GRPCInteropTests"),
.product(name: "GRPCCore", package: "grpc-swift"),
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
]
],
swiftSettings: defaultSwiftSettings
)
]

Expand Down
5 changes: 4 additions & 1 deletion Sources/GRPCInterceptors/ServerTracingInterceptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public struct ServerTracingInterceptor: ServerInterceptor {
using: self.extractor
)

return try await ServiceContext.withValue(serviceContext) {
// FIXME: use 'ServiceContext.withValue(serviceContext)'
//
// This is blocked on: https://github.com/apple/swift-service-context/pull/46
return try await ServiceContext.$current.withValue(serviceContext) {
try await tracer.withSpan(
context.descriptor.fullyQualifiedMethod,
context: serviceContext,
Expand Down
10 changes: 8 additions & 2 deletions Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ final class TracingInterceptorTests: XCTestCase {
let (stream, continuation) = AsyncStream<String>.makeStream()
serviceContext.traceID = traceIDString

try await ServiceContext.withValue(serviceContext) {
// FIXME: use 'ServiceContext.withValue(serviceContext)'
//
// This is blocked on: https://github.com/apple/swift-service-context/pull/46
try await ServiceContext.$current.withValue(serviceContext) {
let methodDescriptor = MethodDescriptor(
service: "TracingInterceptorTests",
method: "testClientInterceptor"
Expand Down Expand Up @@ -101,7 +104,10 @@ final class TracingInterceptorTests: XCTestCase {
let (stream, continuation) = AsyncStream<String>.makeStream()
serviceContext.traceID = traceIDString

try await ServiceContext.withValue(serviceContext) {
// FIXME: use 'ServiceContext.withValue(serviceContext)'
//
// This is blocked on: https://github.com/apple/swift-service-context/pull/46
try await ServiceContext.$current.withValue(serviceContext) {
let response = try await interceptor.intercept(
request: .init(producer: { writer in
try await writer.write(contentsOf: ["request1"])
Expand Down
Loading