Path: redb-route/tests/redb.Route.Tests.Grpc/GrpcTelemetrySmokeTests.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.Grpc/GrpcTelemetrySmokeTests.cs ---- using System.Diagnostics; using System.Net; using System.Net.Sockets; using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Grpc; using redb.Route.Telemetry; using redb.Route.Tests.Shared; namespace redb.Route.Tests.Grpc; /// Smoke test for the P1 transport span opened by . public sealed class GrpcTelemetrySmokeTests : IAsyncLifetime { private GrpcConsumer? _consumer; private GrpcProducer? _producer; private int _port; public Task InitializeAsync() { _port = GetFreePort(); return Task.CompletedTask; } public async Task DisposeAsync() { if (_producer is not null) await _producer.Stop(); if (_consumer is not null) await _consumer.Stop(); } [Fact] public async Task GrpcProducer_EmitsTransportSpanWithRpcTags() { var component = new GrpcComponent(); // Server var serverPars = new Dictionary { ["host"] = "127.0.0.1", ["port"] = _port.ToString(), ["inOut"] = "true" }; var serverUri = new EndpointUri("grpc", $"/127.0.0.1:{_port}", $"grpc:127.0.0.1:{_port}", serverPars); var serverEndpoint = (GrpcEndpoint)component.CreateEndpoint(serverUri); var processor = Substitute.For(); processor.Process(Arg.Any(), Arg.Any()) .Returns(ci => { ci.Arg().Out = new Message("ack"); return Task.CompletedTask; }); _consumer = new GrpcConsumer(serverEndpoint, processor, serverEndpoint.EndpointOptions); await _consumer.Start(); // Client var clientPars = new Dictionary { ["plaintext"] = "true" }; var clientUri = new EndpointUri("grpc", $"/127.0.0.1:{_port}", $"grpc:127.0.0.1:{_port}", clientPars); var clientEndpoint = (GrpcEndpoint)component.CreateEndpoint(clientUri); _producer = new GrpcProducer(clientEndpoint, clientEndpoint.EndpointOptions); using var capture = new SpanCapture(); // this test's spans only await _producer.Start(); await _producer.Process(new Exchange(new Message("hello"))); var activities = capture.Spans; activities.Should().NotBeEmpty(); // Both sides emit a span in this test's trace (the consumer opens "grpc receive" as a Server span, // mirroring the As2 and Soap consumers), so select the producer's span by name and kind. var activity = activities.First(a => a.Kind == ActivityKind.Client && a.OperationName == "grpc.invoke"); activity.Source.Name.Should().Be(RouteActivitySource.SourceName); activity.GetTagItem("rpc.system").Should().Be("grpc"); activity.GetTagItem("redb.route.endpoint").Should().NotBeNull(); } private static int GetFreePort() => global::redb.Route.Tests.Shared.TestPorts.Next(); }