Merge pull request #385 from microsoft/sid-dahiya/AddPDLFieldsAndNewLogEvent
Add/Update Privacy markups for events
This commit is contained in:
Коммит
75cf9b3f26
|
@ -1,13 +1,13 @@
|
|||
|
||||
# **1. Using privacy tags on UTC mode **
|
||||
# Using Privacy Tags
|
||||
|
||||
In order to set privacy tags to an event on UTC mode, the C++ SDK exposes the functionality on it's API.
|
||||
In order to set privacy tags, the C++ SDK exposes the functionality on it's API.
|
||||
|
||||
To be able to send an event on UTC mode you need to set CFG_INT_SDK_MODE flag on the LogManager configuration:
|
||||
|
||||
```cpp
|
||||
config[CFG_INT_SDK_MODE] = SdkModeTypes::SdkModeTypes_UTCCommonSchema;
|
||||
```
|
||||
> ***NOTE***: To be able to send an event on UTC mode you need to set CFG_INT_SDK_MODE flag on the LogManager configuration:
|
||||
>
|
||||
>```cpp
|
||||
>config[CFG_INT_SDK_MODE] = SdkModeTypes::SdkModeTypes_UTCCommonSchema;
|
||||
>```
|
||||
|
||||
To set a tag in code you can use the following syntax using the SetProperty method:
|
||||
|
||||
|
@ -51,14 +51,21 @@ PDT_ProductAndServiceUsage 0x0000000002000000u
|
|||
PDT_SoftwareSetupAndInventory 0x0000000080000000u
|
||||
```
|
||||
|
||||
The tag set on your event will show it the field ext.metadata.privTags. You can validate that using Telemetry Real Time Tool **[TRTT](https://osgwiki.com/wiki/Telemetry_Real-Time_Tool_(TRTT)**
|
||||
The tag set on your event will show it the field `EventInfo.PrivTags`. You can validate that using [Telemetry Real Time Tool (TRTT)](https://osgwiki.com/wiki/Telemetry_Real-Time_Tool_(TRTT))
|
||||
|
||||
![UTC Privacy Tags example](/docs/images/14154-utc.png)
|
||||
|
||||
|
||||
# **2. Diagnostic level filtering**
|
||||
# Diagnostic Level
|
||||
|
||||
The C++ SDK has an API feature to filter events using the diagnostic level associated with it.
|
||||
The C++ SDK has an API feature to filter events using the diagnostic level associated with it. The current list of supported Diagnostic level are:
|
||||
```cpp
|
||||
DIAG_LEVEL_REQUIRED 1
|
||||
DIAG_LEVEL_OPTIONAL 2
|
||||
DIAG_LEVEL_REQUIREDSERVICEDATA 110
|
||||
DIAG_LEVEL_REQUIREDSERVICEDATAFORESSENTIALSERVICES 120
|
||||
```
|
||||
The level set on your event will show up in the field `EventInfo.Level`.
|
||||
|
||||
There are different ways you can make your diagnostic levels filtering work:
|
||||
|
||||
|
@ -81,22 +88,18 @@ auto logger0 = LogManager::Initialize(TENANT_TOKEN, config);
|
|||
// Inherit diagnostic level from parent (LogManager level)
|
||||
auto logger1 = LogManager::GetLogger();
|
||||
|
||||
// Set diagnostic level to ENHANCED for logger2
|
||||
auto logger2 = LogManager::GetLogger(TEST_TOKEN, "my_enhanced_source");
|
||||
logger2->SetLevel(DIAG_LEVEL_ENHANCED);
|
||||
|
||||
// Set diagnostic level to FULL
|
||||
auto logger3 = LogManager::GetLogger("my_full_source");
|
||||
logger3->SetLevel(DIAG_LEVEL_FULL);
|
||||
// Set diagnostic level to OPTIONAL
|
||||
auto logger2 = LogManager::GetLogger("my_optional_source");
|
||||
logger3->SetLevel(DIAG_LEVEL_OPTIONAL);
|
||||
|
||||
// A set that specifies that nothing passes through level filter
|
||||
std::set<uint8_t> logNone = { DIAG_LEVEL_NONE };
|
||||
// Everything goes through
|
||||
std::set<uint8_t> logAll = { };
|
||||
// Only allow BASIC level filtering
|
||||
std::set<uint8_t> logBasic = { DIAG_LEVEL_BASIC };
|
||||
std::set<uint8_t> logRequired = { DIAG_LEVEL_REQUIRED };
|
||||
|
||||
auto filters = { logNone, logAll, logBasic };
|
||||
auto filters = { logNone, logAll, logRequired };
|
||||
|
||||
// Example of how level filtering works
|
||||
size_t i = 0;
|
||||
|
@ -113,17 +116,17 @@ for (auto filter : filters)
|
|||
// Behavior is inherited from the current logger
|
||||
logger->LogEvent(defLevelEvent);
|
||||
|
||||
// Create an event and set level to BASIC
|
||||
// Create an event and set level to REQUIRED
|
||||
// This overrides the logger level for filtering
|
||||
EventProperties basicEvent("My.BasicEvent");
|
||||
basicEvent.SetLevel(DIAG_LEVEL_BASIC);
|
||||
logger->LogEvent(basicEvent);
|
||||
EventProperties requiredEvent("My.RequiredEvent");
|
||||
requiredEvent.SetLevel(DIAG_LEVEL_REQUIRED);
|
||||
logger->LogEvent(requiredEvent);
|
||||
|
||||
// Create an event and set level to FULL
|
||||
// Create an event and set level to OPTIONAL
|
||||
// This overrides the logger level for filtering
|
||||
EventProperties fullEvent("My.FullEvent");
|
||||
fullEvent.SetLevel(DIAG_LEVEL_FULL);
|
||||
logger->LogEvent(fullEvent);
|
||||
EventProperties optionalEvent("My.OptionalEvent");
|
||||
optionalEvent.SetLevel(DIAG_LEVEL_OPTIONAL);
|
||||
logger->LogEvent(optionalEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
// Add privacy tags to avoid the event being dropped at UTC layer
|
||||
evt.SetProperty(COMMONFIELDS_EVENT_PRIVTAGS, PDT_ProductAndServicePerformance);
|
||||
evt.SetProperty(COMMONFIELDS_EVENT_LEVEL, DIAG_LEVEL_OPTIONAL);
|
||||
}
|
||||
|
||||
if (std::string("My.Detailed.Event.PiiMark") == eventName)
|
||||
|
|
|
@ -362,7 +362,8 @@ int main()
|
|||
event.SetProperty("random", rand());
|
||||
event.SetProperty("secret", 5.6872);
|
||||
event.SetProperty("seq", (uint64_t)i);
|
||||
event.SetProperty(COMMONFIELDS_EVENT_PRIVTAGS, (int64_t)(i+1) );
|
||||
event.SetProperty(COMMONFIELDS_EVENT_PRIVTAGS, static_cast<int64_t>(i + 1));
|
||||
event.SetProperty(COMMONFIELDS_EVENT_LEVEL, static_cast<uint8_t>(i + 1));
|
||||
event.SetLatency(latency);
|
||||
logger->LogEvent(event);
|
||||
|
||||
|
@ -372,7 +373,8 @@ int main()
|
|||
{ "random", rand() },
|
||||
{ "secret", 5.6872 },
|
||||
{ "seq", (uint64_t)i },
|
||||
{ COMMONFIELDS_EVENT_PRIVTAGS, (int64_t)(i + 1) }
|
||||
{COMMONFIELDS_EVENT_PRIVTAGS, static_cast<int64_t>(i + 1)},
|
||||
{COMMONFIELDS_EVENT_LEVEL, static_cast<uint8_t>(i + 1)}
|
||||
});
|
||||
logger->LogEvent(event2);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ void twoModules_LogManagerTest()
|
|||
event2.SetProperty("secret", (double)5.6872);
|
||||
event2.SetProperty("seq", (uint64_t)4);
|
||||
event2.SetProperty(COMMONFIELDS_EVENT_PRIVTAGS, PDT_ProductAndServicePerformance);
|
||||
event2.SetProperty(COMMONFIELDS_EVENT_LEVEL, DIAG_LEVEL_REQUIRED);
|
||||
|
||||
loggerB->LogEvent(event2);
|
||||
}
|
||||
|
@ -106,6 +107,7 @@ void provider_LogManagerTest()
|
|||
l2a1p.SetProperty("secret", (double)1.21872);
|
||||
l2a1p.SetProperty("seq", (uint64_t)4);
|
||||
l2a1p.SetProperty(COMMONFIELDS_EVENT_PRIVTAGS, PDT_ProductAndServicePerformance);
|
||||
l2a1p.SetProperty(COMMONFIELDS_EVENT_LEVEL, DIAG_LEVEL_OPTIONAL);
|
||||
l2a->LogEvent(l2a1p);
|
||||
|
||||
printf("Logging event through direct logger, source 1 ...\n");
|
||||
|
|
|
@ -74,6 +74,14 @@
|
|||
#define CONTEXT_SCOPE_ALL "*" /* Inherit all parent context props */
|
||||
#define CONTEXT_SCOPE_NONE "-" /* Do not inherit parent context props */
|
||||
|
||||
// Privacy Tags
|
||||
#define PDT_BrowsingHistory 0x0000000000000002u
|
||||
#define PDT_DeviceConnectivityAndConfiguration 0x0000000000000800u
|
||||
#define PDT_InkingTypingAndSpeechUtterance 0x0000000000020000u
|
||||
#define PDT_ProductAndServicePerformance 0x0000000001000000u
|
||||
#define PDT_ProductAndServiceUsage 0x0000000002000000u
|
||||
#define PDT_SoftwareSetupAndInventory 0x0000000080000000u
|
||||
|
||||
/* Default set of diagnostic level constants. Customers may define their own set. */
|
||||
#define DIAG_LEVEL_NOTSET 255
|
||||
#define DIAG_LEVEL_DEFAULT DIAG_LEVEL_NOTSET /* Default level is inherited from parent */
|
||||
|
@ -84,9 +92,11 @@
|
|||
#define DIAG_LEVEL_ENHANCED 2 /* Additional performance data */
|
||||
#define DIAG_LEVEL_FULL 3 /* Extra activity and enhanced reporting */
|
||||
|
||||
/* Microsoft Office diagnostic level classification */
|
||||
#define DIAG_LEVEL_REQUIRED 1 /* Data that we need to collect in order to keep the product secure, up to date, and performing as expected */
|
||||
#define DIAG_LEVEL_OPTIONAL 2 /* Additional optional data */
|
||||
/* Microsoft NGP diagnostic level classification */
|
||||
#define DIAG_LEVEL_REQUIRED 1 /* Data that we need to collect in order to keep the product secure, up to date, and performing as expected */
|
||||
#define DIAG_LEVEL_OPTIONAL 2 /* Additional optional data */
|
||||
#define DIAG_LEVEL_RSD 110 /* Data required for services to be able to function properly */
|
||||
#define DIAG_LEVEL_RSDES 120 /* Data required for operation of essential services such as licensing, etc. */
|
||||
|
||||
/* Custom SDK configuration allows to override DIAG_LEVEL_DEFAULT_MIN and DIAG_LEVEL_DEFAULT_MAX */
|
||||
#ifndef DIAG_LEVEL_DEFAULT_MIN
|
||||
|
|
|
@ -61,14 +61,6 @@ Refer to https://osgwiki.com/wiki/Common_Schema_Event_Overrides for details on t
|
|||
#define MICROSOFT_EVENTTAG_HASH_PII 0x04000000
|
||||
#define MICROSOFT_EVENTTAG_MARK_PII 0x08000000
|
||||
|
||||
// Privacy Tags
|
||||
#define PDT_BrowsingHistory 0x0000000000000002u
|
||||
#define PDT_DeviceConnectivityAndConfiguration 0x0000000000000800u
|
||||
#define PDT_InkingTypingAndSpeechUtterance 0x0000000000020000u
|
||||
#define PDT_ProductAndServicePerformance 0x0000000001000000u
|
||||
#define PDT_ProductAndServiceUsage 0x0000000002000000u
|
||||
#define PDT_SoftwareSetupAndInventory 0x0000000080000000u
|
||||
|
||||
/// <summary>
|
||||
/// The PageActionData structure represents the data of a page action event.
|
||||
/// </summary>
|
||||
|
|
|
@ -38,6 +38,34 @@ typedef NS_ENUM(NSInteger, ODWPiiKind)
|
|||
ODWPiiKindIPV4AddressLegacy = 13 /**< Legacy IPv4 Internet address. */
|
||||
};
|
||||
|
||||
/*!
|
||||
@enum ODWPrivacyDataType
|
||||
@brief The <b>ODWPrivacytDataType</b> enumeration contains a set of values that indicate various Privacy Data Types that data may be used for an event's privacy classification.
|
||||
@remark Explicitly specified as <b>uint64_t</b> as it needs to be able to hold 64-bit values.
|
||||
*/
|
||||
typedef NS_ENUM(uint64_t, ODWPrivacyDataType)
|
||||
{
|
||||
ODWPDTBrowsingHistory = 0x0000000000000002u,
|
||||
ODWPDTDeviceConnectivityAndConfiguration = 0x0000000000000800u ,
|
||||
ODWPDTInkingTypingAndSpeechUtterance = 0x0000000000020000u,
|
||||
ODWPDTProductAndServicePerformance = 0x0000000001000000u,
|
||||
ODWPDTProductAndServiceUsage = 0x0000000002000000u,
|
||||
ODWPDTSoftwareSetupAndInventory = 0x0000000080000000u
|
||||
};
|
||||
|
||||
/*!
|
||||
@enum ODWDiagLevel
|
||||
@brief The <b>ODWDiagLevel</b> enumeration contains a set of values that indicate the Diagnostic Level that an event may be classified as.
|
||||
@remarks By default, in the absence of explicit markup, an event is considered ODWDiagLevelOptionalDiagnosticData.
|
||||
*/
|
||||
typedef NS_ENUM(uint8_t, ODWDiagLevel)
|
||||
{
|
||||
ODWDiagLevelRequiredDiagnosticData = 1,
|
||||
ODWDiagLevelOptionalDiagnosticData = 2,
|
||||
ODWDiagLevelRequiredServiceData = 110,
|
||||
ODWDiagLevelRequiredServiceDataForEssentialServices = 120
|
||||
};
|
||||
|
||||
/*!
|
||||
The <b>ODWEventProperties</b> class represents an event's properties.
|
||||
*/
|
||||
|
@ -137,6 +165,38 @@ typedef NS_ENUM(NSInteger, ODWPiiKind)
|
|||
*/
|
||||
-(void)setProperty:(NSString*)name withInt64Value:(int64_t)value withPiiKind:(ODWPiiKind)piiKind;
|
||||
|
||||
/*!
|
||||
@brief Sets an integer property for an event.
|
||||
@param name A string that contains the name of the property.
|
||||
@param value An integer that contains the property value.
|
||||
*/
|
||||
-(void)setProperty:(NSString*)name withUInt8Value:(uint8_t)value;
|
||||
|
||||
/*!
|
||||
@brief Sets an integer property for an event.
|
||||
@param name A string that contains the name of the property.
|
||||
@param value An integer that contains the property value.
|
||||
@param piiKind The kind of Personal Identifiable Information (PII), as one of the ::ODWPiiKind enumeration values.
|
||||
*/
|
||||
-(void)setProperty:(NSString*)name withUInt8Value:(uint8_t)value withPiiKind:(ODWPiiKind)piiKind;
|
||||
|
||||
|
||||
/*!
|
||||
@brief Sets an integer property for an event.
|
||||
@param name A string that contains the name of the property.
|
||||
@param value An integer that contains the property value.
|
||||
*/
|
||||
-(void)setProperty:(NSString*)name withUInt64Value:(uint64_t)value;
|
||||
|
||||
/*!
|
||||
@brief Sets an integer property for an event.
|
||||
@param name A string that contains the name of the property.
|
||||
@param value An integer that contains the property value.
|
||||
@param piiKind The kind of Personal Identifiable Information (PII), as one of the ::ODWPiiKind enumeration values.
|
||||
*/
|
||||
-(void)setProperty:(NSString*)name withUInt64Value:(uint64_t)value withPiiKind:(ODWPiiKind)piiKind;
|
||||
|
||||
|
||||
/*!
|
||||
@brief Sets a BOOL property for an event.
|
||||
@param name A string that contains the name of the property.
|
||||
|
@ -174,6 +234,13 @@ typedef NS_ENUM(NSInteger, ODWPiiKind)
|
|||
*/
|
||||
-(void)setProperty:(NSString*)name withDateValue:(NSDate*)value;
|
||||
|
||||
/*!
|
||||
@brief Sets the privacy Metadata for an event.
|
||||
@param privTags Privacy Data Type of the event.
|
||||
@param privLevel Privacy Diagnostic Level of the event.
|
||||
*/
|
||||
-(void)setPrivacyMetadata:(ODWPrivacyDataType)privTags withODWDiagLevel:(ODWDiagLevel)privLevel;
|
||||
|
||||
/*!
|
||||
@brief Sets a date property for an event.
|
||||
@param name A string that contains the name of the property.
|
||||
|
|
|
@ -84,6 +84,28 @@ NSMutableDictionary<NSString*, NSNumber*> * _piiTags;
|
|||
[self setPiiTag:name withPiiKind:piiKind];
|
||||
}
|
||||
|
||||
-(void)setProperty:(NSString*)name withUInt8Value:(uint8_t)value
|
||||
{
|
||||
[_properties setValue:@(value) forKey:name];
|
||||
}
|
||||
|
||||
-(void)setProperty:(NSString*)name withUInt8Value:(uint8_t)value withPiiKind:(ODWPiiKind)piiKind
|
||||
{
|
||||
[self setProperty:name withUInt8Value:value];
|
||||
[self setPiiTag:name withPiiKind:piiKind];
|
||||
}
|
||||
|
||||
-(void)setProperty:(NSString*)name withUInt64Value:(uint64_t)value
|
||||
{
|
||||
[_properties setValue:@(value) forKey:name];
|
||||
}
|
||||
|
||||
-(void)setProperty:(NSString*)name withUInt64Value:(uint64_t)value withPiiKind:(ODWPiiKind)piiKind
|
||||
{
|
||||
[self setProperty:name withUInt64Value:value];
|
||||
[self setPiiTag:name withPiiKind:piiKind];
|
||||
}
|
||||
|
||||
-(void)setProperty:(NSString*)name withBoolValue:(BOOL)value
|
||||
{
|
||||
[_properties setValue:@(value) forKey:name];
|
||||
|
@ -117,4 +139,10 @@ NSMutableDictionary<NSString*, NSNumber*> * _piiTags;
|
|||
[self setPiiTag:name withPiiKind:piiKind];
|
||||
}
|
||||
|
||||
-(void)setPrivacyMetadata:(ODWPrivacyDataType)privTags withODWDiagLevel:(ODWDiagLevel)privLevel
|
||||
{
|
||||
[self setProperty:@"EventInfo.PrivTags" withUInt64Value:privTags];
|
||||
[self setProperty:@"EventInfo.Level" withUInt8Value:privLevel];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Загрузка…
Ссылка в новой задаче