]> git.saurik.com Git - apple/security.git/blob - keychain/SigninMetrics/OctagonSignPosts.h
Security-59754.41.1.tar.gz
[apple/security.git] / keychain / SigninMetrics / OctagonSignPosts.h
1 /*
2 * Copyright (c) 2019 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef OctagonSignPosts_h
25 #define OctagonSignPosts_h
26
27 #import <Foundation/Foundation.h>
28 #import <os/activity.h>
29 #import <os/log.h>
30 #import <os/signpost.h>
31 #import <os/signpost_private.h>
32
33 NS_ASSUME_NONNULL_BEGIN
34
35 typedef struct octagon_signpost_s {
36 const os_signpost_id_t identifier;
37 const uint64_t timestamp;
38 } OctagonSignpost;
39
40 #define OctagonSignpostNamePerformEscrowRecovery "OctagonSignpostNamePerformEscrowRecovery"
41 #define OctagonSignpostNamePerformSilentEscrowRecovery "OctagonSignpostNamePerformSilentEscrowRecovery"
42 #define OctagonSignpostNamePerformRecoveryFromSBD "OctagonSignpostNamePerformRecoveryFromSBD"
43
44 #define OctagonSignpostNameRecoverWithCDPContext "OctagonSignpostNameRecoverWithCDPContext"
45 #define OctagonSignpostNameRecoverSilentWithCDPContext "OctagonSignpostNameRecoverSilentWithCDPContext"
46 #define OctagonSignpostNamePerformOctagonJoinForSilent "OctagonSignpostNamePerformOctagonJoinForSilent"
47 #define OctagonSignpostNamePerformOctagonJoinForNonSilent "OctagonSignpostNamePerformOctagonJoinForNonSilent"
48
49
50 #define OctagonSignpostNamePerformOctagonJoin "OctagonSignpostNamePerformOctagonJoin"
51 #define OctagonSignpostNamePerformResetAndEstablishAfterFailedBottle "OctagonSignpostNamePerformResetAndEstablishAfterFailedBottle"
52 #define OctagonSignpostNameFetchEgoPeer "OctagonSignpostNameFetchEgoPeer"
53 #define OctagonSignpostNameEstablish "OctagonSignpostNameEstablish"
54 #define OctagonSignpostNameResetAndEstablish "OctagonSignpostNameResetAndEstablish"
55 #define OctagonSignpostNameMakeNewFriends "OctagonSignpostNameMakeNewFriends"
56 #define OctagonSignpostNameFetchCliqueStatus "OctagonSignpostNameFetchCliqueStatus"
57 #define OctagonSignpostNameRemoveFriendsInClique "OctagonSignpostNameRemoveFriendsInClique"
58 #define OctagonSignpostNameLeaveClique "OctagonSignpostNameLeaveClique"
59 #define OctagonSignpostNamePeerDeviceNamesByPeerID "OctagonSignpostNamePeerDeviceNamesByPeerID"
60 #define OctagonSignpostNameJoinAfterRestore "OctagonSignpostNameJoinAfterRestore"
61 #define OctagonSignpostNameSafariPasswordSyncingEnabled "OctagonSignpostNameSafariPasswordSyncingEnabled"
62 #define OctagonSignpostNameWaitForInitialSync "OctagonSignpostNameWaitForInitialSync"
63 #define OctagonSignpostNameCopyViewUnawarePeerInfo "OctagonSignpostNameCopyViewUnawarePeerInfo"
64 #define OctagonSignpostNameViewSet "OctagonSignpostNameViewSet"
65 #define OctagonSignpostNameSetUserCredentialsAndDSID "OctagonSignpostNameSetUserCredentialsAndDSID"
66 #define OctagonSignpostNameTryUserCredentialsAndDSID "OctagonSignpostNameTryUserCredentialsAndDSID"
67 #define OctagonSignpostNameCopyPeerPeerInfo "OctagonSignpostNameCopyPeerPeerInfo"
68 #define OctagonSignpostNamePeersHaveViewsEnabled "OctagonSignpostNamePeersHaveViewsEnabled"
69 #define OctagonSignpostNameRequestToJoinCircle "OctagonSignpostNameRequestToJoinCircle"
70 #define OctagonSignpostNameAccountUserKeyAvailable "OctagonSignpostNameAccountUserKeyAvailable"
71 #define OctagonSignpostNameFindOptimalBottleIDsWithContextData "OctagonSignpostNameFindOptimalBottleIDsWithContextData"
72 #define OctagonSignpostNameFetchEscrowRecords "OctagonSignpostNameFetchEscrowRecords"
73 #define OctagonSignpostNameFetchEscrowContents "OctagonSignpostNameFetchEscrowContents"
74 #define OctagonSignpostNameSetNewRecoveryKeyWithData "OctagonSignpostNameSetNewRecoveryKeyWithData"
75 #define OctagonSignpostNameRecoverOctagonUsingData "OctagonSignpostNameRecoverOctagonUsingData"
76 #define OctagonSignpostNamePerformedCDPStateMachineRun "OctagonSignpostNamePerformedCDPStateMachineRun"
77 #define OctagonSignpostNameWaitForOctagonUpgrade "OctagonSignpostNameWaitForOctagonUpgrade"
78 #define OctagonSignpostNameGetAccountInfo "OctagonSignpostNameGetAccountInfo"
79
80 #define SOSSignpostNameAssertUserCredentialsAndOptionalDSID "SOSSignpostNameAssertUserCredentialsAndOptionalDSID"
81 #define SOSSignpostNameSOSCCTryUserCredentials "SOSSignpostNameSOSCCTryUserCredentials"
82 #define SOSSignpostNameSOSCCCanAuthenticate "SOSSignpostNameSOSCCCanAuthenticate"
83 #define SOSSignpostNameSOSCCRequestToJoinCircle "SOSSignpostNameSOSCCRequestToJoinCircle"
84 #define SOSSignpostNameSOSCCRequestToJoinCircleAfterRestore "SOSSignpostNameSOSCCRequestToJoinCircleAfterRestore"
85 #define SOSSignpostNameSOSCCResetToOffering "SOSSignpostNameSOSCCResetToOffering"
86 #define SOSSignpostNameSOSCCResetToEmpty "SOSSignpostNameSOSCCResetToEmpty"
87 #define SOSSignpostNameSOSCCRemoveThisDeviceFromCircle "SOSSignpostNameSOSCCRemoveThisDeviceFromCircle"
88 #define SOSSignpostNameSOSCCRemovePeersFromCircle "SOSSignpostNameSOSCCRemovePeersFromCircle"
89 #define SOSSignpostNameSOSCCLoggedOutOfAccount "SOSSignpostNameSOSCCLoggedOutOfAccount"
90 #define SOSSignpostNameSOSCCCopyApplicantPeerInfo "SOSSignpostNameSOSCCCopyApplicantPeerInfo"
91 #define SOSSignpostNameFlush "SOSSignpostNameFlush"
92 #define SOSSignpostNameSyncKVSAndWait "SOSSignpostNameSyncKVSAndWait"
93 #define SOSSignpostNameSyncTheLastDataToKVS "SOSSignpostNameSyncTheLastDataToKVS"
94 #define SOSSignpostNameSOSCCViewSet "SOSSignpostNameSOSCCViewSet"
95 #define SOSSignpostNameSOSCCCopyValidPeerPeerInfo "SOSSignpostNameSOSCCCopyValidPeerPeerInfo"
96 #define SOSSignpostNameSOSCCValidateUserPublic "SOSSignpostNameSOSCCValidateUserPublic"
97 #define SOSSignpostNameSOSCCCopyViewUnawarePeerInfo "SOSSignpostNameSOSCCCopyViewUnawarePeerInfo"
98 #define SOSSignpostNameSOSCCWaitForInitialSync "SOSSignpostNameSOSCCWaitForInitialSync"
99 #define SOSSignpostNameSOSCCAcceptApplicants "SOSSignpostNameSOSCCAcceptApplicants"
100 #define SOSSignpostNameSOSCCRejectApplicants "SOSSignpostNameSOSCCRejectApplicants"
101 #define SOSSignpostNameSOSCCCopyConcurringPeerPeerInfo "SOSSignpostNameSOSCCCopyConcurringPeerPeerInfo"
102 #define SOSSignpostNameSOSCCCopyMyPeerInfo "SOSSignpostNameSOSCCCopyMyPeerInfo"
103 #define SOSSignpostNameSOSCCSetNewPublicBackupKey "SOSSignpostNameSOSCCSetNewPublicBackupKey"
104 #define SOSSignpostNameSOSCCRegisterSingleRecoverySecret "SOSSignpostNameSOSCCRegisterSingleRecoverySecret"
105 #define SOSSignpostNameSOSCCProcessEnsurePeerRegistration "SOSSignpostNameSOSCCProcessEnsurePeerRegistration"
106 #define SOSSignpostNameSOSCCProcessSyncWithPeers "SOSSignpostNameSOSCCProcessSyncWithPeers"
107 #define SOSSignpostNameSOSCCProcessSyncWithAllPeers "SOSSignpostNameSOSCCProcessSyncWithAllPeers"
108 #define SOSSignpostNameSOSCCRequestSyncWithPeersList "SOSSignpostNameSOSCCRequestSyncWithPeersList"
109 #define SOSSignpostNameSOSCCRequestSyncWithBackupPeerList "SOSSignpostNameSOSCCRequestSyncWithBackupPeerList"
110 #define SOSSignpostNameSOSCCEnsurePeerRegistration "SOSSignpostNameSOSCCEnsurePeerRegistration"
111 #define SOSSignpostNameSOSCCHandleUpdateMessage "SOSSignpostNameSOSCCHandleUpdateMessage"
112 #define SOSSignpostNameSOSCCCopyApplication "SOSSignpostNameSOSCCCopyApplication"
113 #define SOSSignpostNameSOSCCCopyCircleJoiningBlob "SOSSignpostNameSOSCCCopyCircleJoiningBlob"
114 #define SOSSignpostNameSOSCCCopyInitialSyncData "SOSSignpostNameSOSCCCopyInitialSyncData"
115 #define SOSSignpostNameSOSCCJoinWithCircleJoiningBlob "SOSSignpostNameSOSCCJoinWithCircleJoiningBlob"
116 #define SOSSignpostNameSOSCCPeersHaveViewsEnabled "SOSSignpostNameSOSCCPeersHaveViewsEnabled"
117 #define SOSSignpostNameSOSCCRegisterRecoveryPublicKey "SOSSignpostNameSOSCCRegisterRecoveryPublicKey"
118 #define SOSSignpostNameSOSCCCopyRecoveryPublicKey "SOSSignpostNameSOSCCCopyRecoveryPublicKey"
119 #define SOSSignpostNameSOSCCMessageFromPeerIsPending "SOSSignpostNameSOSCCMessageFromPeerIsPending"
120 #define SOSSignpostNameSOSCCSendToPeerIsPending "SOSSignpostNameSOSCCSendToPeerIsPending"
121
122 #define OctagonSignpostString1(label) " "#label"=%{public,signpost.telemetry:string1,name="#label"}@ "
123 #define OctagonSignpostString2(label) " "#label"=%{public,signpost.telemetry:string2,name="#label"}@ "
124 #define OctagonSignpostNumber1(label) " "#label"=%{public,signpost.telemetry:number1,name="#label"}d "
125 #define OctagonSignpostNumber2(label) " "#label"=%{public,signpost.telemetry:number2,name="#label"}d "
126
127 // Used to begin tracking a timed event.
128 #define OctagonSignpostBegin(name) _OctagonSignpostBegin(_OctagonSignpostLogSystem(), name, OS_SIGNPOST_ENABLE_TELEMETRY)
129
130 // For marking a significant event.
131 #define OctagonSignpostEvent(signpost, name, ...) _OctagonSignpostEvent(_OctagonSignpostLogSystem(), signpost, name, __VA_ARGS__)
132
133 // For completing a timed event associated with the given signpost.
134 #define OctagonSignpostEnd(signpost, name, ...) _OctagonSignpostEnd(_OctagonSignpostLogSystem(), signpost, name, __VA_ARGS__)
135
136 extern os_log_t _OctagonSignpostLogSystem(void);
137
138 extern OctagonSignpost _OctagonSignpostCreate(os_log_t subsystem);
139 extern uint64_t _OctagonSignpostGetNanoseconds(OctagonSignpost signpost);
140
141 #define _OctagonSignpostBegin(subsystem, name, ...) __extension__({ \
142 OctagonSignpost internalSignpost = _OctagonSignpostCreate(subsystem); \
143 os_signpost_interval_begin(subsystem, internalSignpost.identifier, name, __VA_ARGS__); \
144 os_log(subsystem, "BEGIN [%lld]: " name " " _OctagonSwizzle1(internalSignpost.identifier, __VA_ARGS__)); \
145 internalSignpost; \
146 })
147
148 #define _OctagonSignpostEvent(subsystem, signpost, name, ...) __extension__({ \
149 double interval = ((double)_OctagonSignpostGetNanoseconds(_signpost) / NSEC_PER_SEC); \
150 os_signpost_event_emit(subsystem, signpost.identifier, name, __VA_ARGS__); \
151 os_log(subsystem, "EVENT [%lld] %fs: " name " " _OctagonSwizzle2(signpost.identifier, interval, __VA_ARGS__)); \
152 })
153
154 #define _OctagonSignpostEnd(subsystem, signpost, name, ...) __extension__({ \
155 double interval = ((double)_OctagonSignpostGetNanoseconds(signpost) / NSEC_PER_SEC); \
156 os_signpost_interval_end(subsystem, signpost.identifier, name, __VA_ARGS__); \
157 os_log(subsystem, "END [%lld] %fs: " name " " _OctagonSwizzle2(signpost.identifier, interval, __VA_ARGS__)); \
158 })
159
160 #define _OctagonSwizzle1(x, a, ...) a, x, ##__VA_ARGS__
161 #define _OctagonSwizzle2(x, y, a, ...) a, x, y, ##__VA_ARGS__
162
163 NS_ASSUME_NONNULL_END
164
165 #endif /* OctagonSignPosts_h */