Skip to content

Commit 52c5778

Browse files
committed
tracing and ids alignment
1 parent 467a0a7 commit 52c5778

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/DatatypeChannels.ASB/Consumer.fs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ let mkNew (options:ServiceBusReceiverOptions)
3737
match ctxRef.Value with
3838
| Some ((receiver,_,_) as ctx) when not receiver.IsClosed -> Task.FromResult ctx
3939
| _ -> fun (name:Task<_>) -> backgroundTask {
40+
use activity = activitySource |> Diagnostics.startActivity "new" ActivityKind.Consumer
4041
let! name = name
42+
activity.AddTag("binding", $"{name}/{options.SubQueue}") |> ignore
4143
let startActivity _ = activitySource |> Diagnostics.startActivity name ActivityKind.Consumer
4244
let receiver = withClient (fun client -> client.CreateReceiver(name, options))
4345
ctxRef.Value <- Some (receiver, startActivity, ConcurrentDictionary())
@@ -71,9 +73,9 @@ let mkNew (options:ServiceBusReceiverOptions)
7173
return msg |> Option.map (fun msg ->
7274
let msgCtx = MessageContext.From received activity receiver
7375
if receiver.ReceiveMode = ServiceBusReceiveMode.PeekLock then
74-
if msgCtxs.TryAdd(received.LockToken, msgCtx) then startRenewal msgCtx |> ignore
76+
if msgCtxs.TryAdd(received.MessageId, msgCtx) then startRenewal msgCtx |> ignore
7577
else failwith "Unable to add the message"
76-
{ Msg = msg; Id = received.LockToken })
78+
{ Msg = msg; Id = received.MessageId })
7779
}
7880

7981
member __.Ack receivedId =

tests/DatatypeChannels.ASB.Tests/Tests.fs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,15 @@ let tests =
153153
let! dlc = DeadLetter "renews-queue" |> channels.GetConsumer PlainText.ofReceived
154154
let publisher = channels.GetPublisher (PlainText.toSend testId) topic
155155
do! Task.Delay 5_000 // majic number - this is how long it takes the backend to start routing messages to this subscription!
156-
let n = 20
156+
let n = 200
157157
for i in 1..n do
158158
do! publisher |> Publisher.publish $"test-payload-{i}"
159-
let xs = ResizeArray()
160-
for i in 1..n do
161-
let! received = TimeSpan.FromSeconds 1. |> consumer.Get
162-
received |> Option.iter xs.Add
159+
let! xs = // also test parallel consumption
160+
seq {for _ in 1..2 -> seq { for _ in 1..n/2 -> TimeSpan.FromSeconds 1. |> consumer.Get}}
161+
|> Seq.map Task.WhenAll
162+
|> Task.WhenAll
163+
|> Task.map (Array.collect id)
164+
|> Task.map (Array.choose id)
163165
xs |> Seq.distinct |> Seq.length =! n
164166
do! Task.Delay (TimeSpan.FromMinutes 7.)
165167
for received in xs do

0 commit comments

Comments
 (0)