Skip to content

SDK profiler#412

Open
ShiCheng-Lu wants to merge 7 commits intomasterfrom
shicheng/sdk-profiler
Open

SDK profiler#412
ShiCheng-Lu wants to merge 7 commits intomasterfrom
shicheng/sdk-profiler

Conversation

@ShiCheng-Lu
Copy link
Contributor

@ShiCheng-Lu ShiCheng-Lu commented Nov 13, 2024

Switching over to using OpenTelemetry trace structure:
#470

Introduce a RadarProfiler. keeps track of what time each operation started/ended, and produce a formatted string of the performance.

RadarProfiler has two timing methods start(operation) and end(operation) which tracks the time elapsed for a specific operation. In this PR it's being used for trackVerified.

the formatted method returns a formatted string of all the operations that were tracked. e.g. getLocation: 0.003, trackAPI: 1.518, total: 3.448, getAttestToken: 1.477, getConfig: 0.450

then it's sent to logs. (currently debug level, but maybe this should be info) which then will be parsed and processed by the server (in the future)


The test in swift does run in CI, but the log doesn't show up. It does show up it if fails, it'll sayRadarSDKTestsSwift.test_profiler() failed. But no output for success for some reason (for now).

This test is written with the Swift Testing framework, which requires xcode 16. (updated github workflow to public pre-release for this).

@ShiCheng-Lu ShiCheng-Lu changed the title Shicheng/sdk profiler SDK profiler Nov 13, 2024
@ShiCheng-Lu ShiCheng-Lu force-pushed the shicheng/sdk-profiler branch from b528ef8 to 66f7a9a Compare November 13, 2024 22:22
@ShiCheng-Lu ShiCheng-Lu marked this pull request as ready for review November 18, 2024 16:38
Copilot AI review requested due to automatic review settings August 12, 2025 18:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

}

@objc func formatted() -> String {
return endTimes.map { (tag, end) in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might want to include the tags that have starts and no ends as like a "unfinished" or a -1 or something, just so they don't fail silently

}

@objc func formatted() -> String {
return endTimes.map { (tag, end) in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will iterating over the map keep the original order of the tags? might be helpful for log readability

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to switch this over to using open telemetry specs.

import Testing

@Suite("SDK Tests")
struct RadarSDKTestsSwift {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could add a test for starting a tag and not ending it, and a test for trying to end a tag that wasn't started


import Foundation

@objc(RadarTelemetry) class RadarTelemetry: NSObject {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if this class isn't actually going to end up sending the logs to the server, you might want to rename it RadarTimer or RadarStopwatch or something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants