Chromium Code Reviews| Index: webrtc/pc/rtcstatscollector.cc |
| diff --git a/webrtc/pc/rtcstatscollector.cc b/webrtc/pc/rtcstatscollector.cc |
| index f5b8c8a936c1b569826ff20d98741e62ddb5e550..c0a9f442b295e81bae406ca569c167fe792efc58 100644 |
| --- a/webrtc/pc/rtcstatscollector.cc |
| +++ b/webrtc/pc/rtcstatscollector.cc |
| @@ -24,12 +24,26 @@ |
| #include "webrtc/pc/peerconnection.h" |
| #include "webrtc/pc/webrtcsession.h" |
| #include "webrtc/rtc_base/checks.h" |
| +#include "webrtc/rtc_base/stringutils.h" |
| #include "webrtc/rtc_base/timeutils.h" |
| +#include "webrtc/rtc_base/trace_event.h" |
| namespace webrtc { |
| namespace { |
| +const int kStatTypeMemberNameAndIdMaxLen = 120; |
|
ehmaldonado_webrtc
2017/07/13 09:40:42
Henrik, do you think 120 chars will be enough?
hbos
2017/07/18 08:55:08
Yes. In the very unlikely case that it won't be in
hbos
2017/07/18 10:09:48
Oh sorry, I forgot about the length of the ID, and
hbos
2017/07/18 10:11:58
Or rather "certificate.fingerprintAlgorithm.RTCCer
|
| + |
| +std::string GetStatTypeMemberNameAndId(const RTCStats& stats, |
| + const RTCStatsMemberInterface* member) { |
| + RTC_DCHECK(strlen(stats.type()) + strlen(member->name()) |
| + + stats.id().size() + 3 < kStatTypeMemberNameAndIdMaxLen); |
| + char buffer[kStatTypeMemberNameAndIdMaxLen]; |
| + rtc::sprintfn(&buffer[0], sizeof(buffer), "%s.%s.%s", stats.type(), |
| + member->name(), stats.id().c_str()); |
| + return buffer; |
| +} |
| + |
| std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) { |
| return "RTCCertificate_" + fingerprint; |
| } |
| @@ -751,6 +765,19 @@ void RTCStatsCollector::AddPartialResults_s( |
| channel_name_pairs_.reset(); |
| track_media_info_map_.reset(); |
| track_to_id_.clear(); |
| + // Trace WebRTC Stats when getStats is called on Javascript. |
| + // This allows access to WebRTC stats from trace logs. To enable them, |
| + // select the "webrtc_stats" category when recording traces. |
| + for (const RTCStats& stats : *cached_report_) { |
| + for (const RTCStatsMemberInterface* member : stats.Members()) { |
| + if (member->is_defined()) { |
| + TRACE_EVENT_INSTANT2("webrtc_stats", "webrtc_stats", |
| + "value", member->ValueToString(), |
| + "type+name+id", GetStatTypeMemberNameAndId( |
|
hbos
2017/07/18 08:55:08
nit: How about "type.name.id" to match the format
|
| + stats, member)); |
| + } |
| + } |
| + } |
| DeliverCachedReport(); |
| } |
| } |