Skip to content

Commit 12537ed

Browse files
committed
more tracing
1 parent b48f427 commit 12537ed

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

getstream/video/rtc/connection_manager.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ async def _on_ice_trickle(self, event):
139139
async def _on_subscriber_offer(self, event: events_pb2.SubscriberOffer):
140140
logger.info("Subscriber offer received")
141141

142-
with telemetry.start_as_current_span("rtx.on_subscriber_offer") as span:
142+
with telemetry.start_as_current_span("rtc.on_subscriber_offer") as span:
143143
await self.subscriber_negotiation_lock.acquire()
144144

145145
try:
@@ -163,20 +163,20 @@ async def _on_subscriber_offer(self, event: events_pb2.SubscriberOffer):
163163
span.set_attribute("remote_description.sdp", fixed_sdp)
164164

165165
with telemetry.start_as_current_span(
166-
"rtx.on_subscriber_offer.set_remote_description"
166+
"rtc.on_subscriber_offer.set_remote_description"
167167
):
168168
await self.subscriber_pc.setRemoteDescription(remote_description)
169169

170170
# Create the answer based on the remote offer (which includes our candidates)
171171
with telemetry.start_as_current_span(
172-
"rtx.on_subscriber_offer.create_answer"
172+
"rtc.on_subscriber_offer.create_answer"
173173
) as span:
174174
answer = await self.subscriber_pc.createAnswer()
175175
span.set_attribute("answer.sdp", answer.sdp)
176176

177177
# Set the local description. aiortc will manage the SDP content.
178178
with telemetry.start_as_current_span(
179-
"rtx.on_subscriber_offer.set_local_description"
179+
"rtc.on_subscriber_offer.set_local_description"
180180
):
181181
await self.subscriber_pc.setLocalDescription(answer)
182182

@@ -391,7 +391,8 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
391391

392392
async def add_tracks(self, audio=None, video=None):
393393
"""Add multiple audio and video tracks in a single negotiation."""
394-
await self._peer_manager.add_tracks(audio, video)
394+
with telemetry.start_as_current_span("rtc.add_tracks"):
395+
await self._peer_manager.add_tracks(audio, video)
395396

396397
async def start_recording(
397398
self, recording_types, user_ids=None, output_dir="recordings"

getstream/video/rtc/peer_connection.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import aiortc
1010
from aiortc.contrib.media import MediaRelay
1111

12+
from getstream.common import telemetry
1213
from getstream.video.rtc.connection_utils import (
1314
create_audio_track_info,
1415
prepare_video_track_info,
@@ -75,8 +76,6 @@ async def add_tracks(
7576

7677
relayed_audio = None
7778
relayed_video = None
78-
audio_relay = None
79-
video_relay = None
8079
audio_info = None
8180
video_info = None
8281
track_infos = []
@@ -103,8 +102,14 @@ async def add_tracks(
103102
if video:
104103
self.publisher_pc.addTrack(relayed_video)
105104
logger.info(f"Added relayed video track {relayed_video.id}")
106-
offer = await self.publisher_pc.createOffer()
107-
await self.publisher_pc.setLocalDescription(offer)
105+
106+
with telemetry.start_as_current_span("rtc.publisher_pc.create_offer"):
107+
offer = await self.publisher_pc.createOffer()
108+
109+
with telemetry.start_as_current_span(
110+
"rtc.publisher_pc.set_local_description"
111+
):
112+
await self.publisher_pc.setLocalDescription(offer)
108113

109114
try:
110115
patched_sdp = patch_sdp_offer(self.publisher_pc.localDescription.sdp)
@@ -142,7 +147,10 @@ async def add_tracks(
142147
)
143148
)
144149
await self.publisher_pc.handle_answer(response)
145-
await self.publisher_pc.wait_for_connected()
150+
with telemetry.start_as_current_span(
151+
"rtc.publisher_pc.wait_for_connected"
152+
):
153+
await self.publisher_pc.wait_for_connected()
146154
except SfuRpcError as e:
147155
logger.error(f"Failed to set publisher: {e}")
148156
raise

0 commit comments

Comments
 (0)