Skip to content

Commit

Permalink
Initial collection rule options, validation, and unit tests. (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
jander-msft authored Aug 9, 2021
1 parent d1e450d commit e39cc95
Show file tree
Hide file tree
Showing 58 changed files with 2,976 additions and 95 deletions.
250 changes: 192 additions & 58 deletions documentation/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
}
]
},
"CollectionRules": {
"type": [
"null",
"object"
],
"default": {},
"additionalProperties": {
"$ref": "#/definitions/CollectionRuleOptions"
}
},
"CorsConfiguration": {
"default": {},
"oneOf": [
Expand Down Expand Up @@ -105,6 +115,188 @@
}
}
},
"CollectionRuleOptions": {
"type": "object",
"additionalProperties": false,
"required": [
"Trigger"
],
"properties": {
"Filters": {
"type": [
"array",
"null"
],
"description": "Process filters used to determine to which process(es) the collection rule is applied. All filters must match. If no filters are specified, the rule is applied to all discovered processes.",
"items": {
"$ref": "#/definitions/ProcessFilterDescriptor"
}
},
"Trigger": {
"description": "The trigger to use to monitor for a condition in the target process.",
"oneOf": [
{
"$ref": "#/definitions/CollectionRuleTriggerOptions"
}
]
},
"Actions": {
"type": [
"array",
"null"
],
"description": "The list of actions to be executed when the trigger raises its notification.",
"items": {
"$ref": "#/definitions/CollectionRuleActionOptions"
}
},
"Limits": {
"description": "The set of limits to constrain the execution of the rule and its components.",
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/definitions/CollectionRuleLimitsOptions"
}
]
}
}
},
"ProcessFilterDescriptor": {
"type": "object",
"additionalProperties": false,
"required": [
"Key",
"Value"
],
"properties": {
"Key": {
"description": "The criteria used to compare against the target process.",
"oneOf": [
{
"$ref": "#/definitions/ProcessFilterKey"
}
]
},
"Value": {
"type": "string",
"description": "The value of the criteria used to compare against the target process.",
"minLength": 1
},
"MatchType": {
"description": "Type of match to use against the process criteria.",
"default": "Exact",
"oneOf": [
{
"$ref": "#/definitions/ProcessFilterType"
}
]
}
}
},
"ProcessFilterKey": {
"type": "string",
"description": "",
"x-enumNames": [
"ProcessId",
"ProcessName",
"CommandLine"
],
"enum": [
"ProcessId",
"ProcessName",
"CommandLine"
]
},
"ProcessFilterType": {
"type": "string",
"description": "",
"x-enumNames": [
"Exact",
"Contains"
],
"enum": [
"Exact",
"Contains"
]
},
"CollectionRuleTriggerOptions": {
"type": "object",
"additionalProperties": false,
"required": [
"Type"
],
"properties": {
"Type": {
"type": "string",
"description": "The type of trigger used to monitor for a condition in the target process.",
"minLength": 1
},
"Settings": {
"description": "The settings to pass to the trigger when it is executed. Settings may be optional if the trigger doesn't require settings or its settings are all optional.",
"oneOf": [
{},
{
"type": "null"
}
]
}
}
},
"CollectionRuleActionOptions": {
"type": "object",
"additionalProperties": false,
"required": [
"Type"
],
"properties": {
"Type": {
"type": "string",
"description": "The type of action to execute.",
"minLength": 1
},
"Settings": {
"description": "The settings to pass to the action when it is executed. Settings may be optional if the action doesn't require settings or its settings are all optional.",
"oneOf": [
{},
{
"type": "null"
}
]
}
}
},
"CollectionRuleLimitsOptions": {
"type": "object",
"additionalProperties": false,
"properties": {
"ActionCount": {
"type": [
"integer",
"null"
],
"description": "The number of times the action list may be executed before being throttled.",
"format": "int32"
},
"ActionCountSlidingWindowDuration": {
"type": [
"null",
"string"
],
"description": "The sliding window of time to consider whether the action list should be throttled based on the number of times the action list was executed. Executions that fall outside the window will not count toward the limit specified in the ActionCount setting.",
"format": "time-span"
},
"RuleDuration": {
"type": [
"null",
"string"
],
"description": "The amount of time before the rule will stop monitoring a process after it has been applied to a process. If not specified, the rule will monitor the process with the trigger indefinitely.",
"format": "time-span"
}
}
},
"CorsConfiguration": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -405,64 +597,6 @@
}
}
}
},
"ProcessFilterDescriptor": {
"type": "object",
"additionalProperties": false,
"required": [
"Key",
"Value"
],
"properties": {
"Key": {
"description": "The criteria used to compare against the target process.",
"oneOf": [
{
"$ref": "#/definitions/ProcessFilterKey"
}
]
},
"Value": {
"type": "string",
"description": "The value of the criteria used to compare against the target process.",
"minLength": 1
},
"MatchType": {
"description": "Type of match to use against the process criteria.",
"default": "Exact",
"oneOf": [
{
"$ref": "#/definitions/ProcessFilterType"
}
]
}
}
},
"ProcessFilterKey": {
"type": "string",
"description": "",
"x-enumNames": [
"ProcessId",
"ProcessName",
"CommandLine"
],
"enum": [
"ProcessId",
"ProcessName",
"CommandLine"
]
},
"ProcessFilterType": {
"type": "string",
"description": "",
"x-enumNames": [
"Exact",
"Contains"
],
"enum": [
"Exact",
"Contains"
]
}
}
}
9 changes: 8 additions & 1 deletion dotnet-monitor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monit
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests", "src\Tests\Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests\Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests.csproj", "{886D1FD5-125F-435B-934C-30DF2938E7F6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Diagnostics.Monitoring.ConfigurationSchema", "src\Tests\Microsoft.Diagnostics.Monitoring.ConfigurationSchema\Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj", "{422ABBF6-6236-4042-AACA-09531DBDFBAA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.ConfigurationSchema", "src\Tests\Microsoft.Diagnostics.Monitoring.ConfigurationSchema\Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj", "{422ABBF6-6236-4042-AACA-09531DBDFBAA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.WebApi.UnitTests", "src\Tests\Microsoft.Diagnostics.Monitoring.WebApi.UnitTests\Microsoft.Diagnostics.Monitoring.WebApi.UnitTests.csproj", "{3AD0A40B-C569-4712-9764-7A788B9CD811}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.Tool.UnitTests", "src\Tests\Microsoft.Diagnostics.Monitoring.Tool.UnitTests\Microsoft.Diagnostics.Monitoring.Tool.UnitTests.csproj", "{0DBE362D-82F1-4740-AE6A-40C1A82EDCDB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -80,6 +82,10 @@ Global
{3AD0A40B-C569-4712-9764-7A788B9CD811}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AD0A40B-C569-4712-9764-7A788B9CD811}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AD0A40B-C569-4712-9764-7A788B9CD811}.Release|Any CPU.Build.0 = Release|Any CPU
{0DBE362D-82F1-4740-AE6A-40C1A82EDCDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DBE362D-82F1-4740-AE6A-40C1A82EDCDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DBE362D-82F1-4740-AE6A-40C1A82EDCDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DBE362D-82F1-4740-AE6A-40C1A82EDCDB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -98,6 +104,7 @@ Global
{886D1FD5-125F-435B-934C-30DF2938E7F6} = {C7568468-1C79-4944-8136-18812A7F9EA7}
{422ABBF6-6236-4042-AACA-09531DBDFBAA} = {C7568468-1C79-4944-8136-18812A7F9EA7}
{3AD0A40B-C569-4712-9764-7A788B9CD811} = {C7568468-1C79-4944-8136-18812A7F9EA7}
{0DBE362D-82F1-4740-AE6A-40C1A82EDCDB} = {C7568468-1C79-4944-8136-18812A7F9EA7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {46465737-C938-44FC-BE1A-4CE139EBB5E0}
Expand Down
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<MicrosoftAspNetCoreMvcVersion>2.1.3</MicrosoftAspNetCoreMvcVersion>
<MicrosoftAspNetCoreServerKestrelCoreVersion>2.1.7</MicrosoftAspNetCoreServerKestrelCoreVersion>
<MicrosoftBclHashCodeVersion>1.1.0</MicrosoftBclHashCodeVersion>
<MicrosoftExtensionsConfigurationAbstractionsVersion>5.0.0</MicrosoftExtensionsConfigurationAbstractionsVersion>
<MicrosoftExtensionsConfigurationKeyPerFileVersion>5.0.2</MicrosoftExtensionsConfigurationKeyPerFileVersion>
<MicrosoftExtensionsLoggingConsoleVersion>5.0.0</MicrosoftExtensionsLoggingConsoleVersion>
<MicrosoftExtensionsLoggingEventSourceVersion>5.0.1</MicrosoftExtensionsLoggingEventSourceVersion>
Expand Down
6 changes: 4 additions & 2 deletions src/Microsoft.Diagnostics.Monitoring.WebApi/IEgressService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ namespace Microsoft.Diagnostics.Monitoring.WebApi
{
internal interface IEgressService
{
bool CheckProvider(string providerName);

Task<EgressResult> EgressAsync(
string endpointName,
string providerName,
Func<CancellationToken, Task<Stream>> action,
string fileName,
string contentType,
IEndpointInfo source,
CancellationToken token);

Task<EgressResult> EgressAsync(
string endpointName,
string providerName,
Func<Stream, CancellationToken, Task> action,
string fileName,
string contentType,
Expand Down
Loading

0 comments on commit e39cc95

Please sign in to comment.