diff --git a/documentation/schema.json b/documentation/schema.json index 607ba0d97c7..d1e52ab36bb 100644 --- a/documentation/schema.json +++ b/documentation/schema.json @@ -5,6 +5,17 @@ "type": "object", "additionalProperties": {}, "properties": { + "Logging": { + "default": {}, + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/LoggingOptions" + } + ] + }, "ApiAuthentication": { "default": {}, "oneOf": [ @@ -94,6 +105,246 @@ } }, "definitions": { + "LoggingOptions": { + "type": "object", + "additionalProperties": false, + "properties": { + "LogLevel": { + "type": [ + "null", + "object" + ], + "description": "A mapping of logger categories to log levels describing the threshold level at which messages are logged for each category; applies to no specific provider.", + "default": {}, + "additionalProperties": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/LogLevel" + } + ] + } + }, + "Console": { + "description": "Logging options for the Console provider.", + "default": {}, + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/ConsoleLoggerOptions" + } + ] + }, + "EventLog": { + "description": "Logging options for the EventLog provider.", + "default": {}, + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/LogLevelOptions" + } + ] + }, + "Debug": { + "description": "Logging options for the Debug provider.", + "default": {}, + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/LogLevelOptions" + } + ] + }, + "EventSource": { + "description": "Logging options for the EventSource provider.", + "default": {}, + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/LogLevelOptions" + } + ] + }, + "CaptureScopes": { + "type": "boolean", + "description": "Gets or sets whether logging scopes are being captured. Defaults to true.", + "default": true + } + } + }, + "LogLevel": { + "type": "string", + "description": "", + "x-enumNames": [ + "Trace", + "Debug", + "Information", + "Warning", + "Error", + "Critical", + "None" + ], + "enum": [ + "Trace", + "Debug", + "Information", + "Warning", + "Error", + "Critical", + "None" + ] + }, + "ConsoleLoggerOptions": { + "type": "object", + "additionalProperties": false, + "properties": { + "FormatterName": { + "description": "Name of the log message formatter to use. Defaults to 'Simple'.", + "default": "Simple", + "oneOf": [ + { + "$ref": "#/definitions/ConsoleLoggerFormat" + } + ] + }, + "LogToStandardErrorThreshold": { + "description": "The minimum level of messages that are written to Console.Error.", + "oneOf": [ + { + "$ref": "#/definitions/LogLevel" + } + ] + }, + "FormatterOptions": { + "description": "Formatter options for the built-in console log formatter.", + "default": {}, + "oneOf": [ + {}, + { + "type": "null" + } + ] + }, + "LogLevel": { + "type": [ + "null", + "object" + ], + "description": "A mapping of logger categories to log levels describing the threshold level at which messages are logged for each category; applies solely to ConsoleLoggerOptions.", + "default": {}, + "additionalProperties": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/LogLevel" + } + ] + } + } + }, + "oneOf": [ + { + "required": [ + "FormatterName" + ], + "properties": { + "FormatterName": { + "const": "Json" + }, + "FormatterOptions": { + "$ref": "#/definitions/JsonConsoleFormatterOptions" + } + } + }, + { + "required": [ + "FormatterName" + ], + "properties": { + "FormatterName": { + "const": "Simple" + }, + "FormatterOptions": { + "$ref": "#/definitions/SimpleConsoleFormatterOptions" + } + } + }, + { + "required": [ + "FormatterName" + ], + "properties": { + "FormatterName": { + "const": "Systemd" + }, + "FormatterOptions": { + "$ref": "#/definitions/ConsoleFormatterOptions" + } + } + }, + { + "properties": { + "FormatterName": { + "type": "null", + "default": "Simple" + }, + "FormatterOptions": { + "$ref": "#/definitions/SimpleConsoleFormatterOptions" + } + } + } + ] + }, + "ConsoleLoggerFormat": { + "type": "string", + "description": "", + "x-enumNames": [ + "Json", + "Simple", + "Systemd" + ], + "enum": [ + "Json", + "Simple", + "Systemd" + ] + }, + "LogLevelOptions": { + "type": "object", + "additionalProperties": false, + "properties": { + "LogLevel": { + "type": [ + "null", + "object" + ], + "description": "A mapping of logger categories to log levels describing the threshold level at which messages are logged for each category; applies to the specified provider.", + "default": {}, + "additionalProperties": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/LogLevel" + } + ] + } + } + } + }, "ApiAuthenticationOptions": { "type": "object", "additionalProperties": false, @@ -597,6 +848,152 @@ } } } + }, + "JsonConsoleFormatterOptions": { + "title": "JsonConsoleFormatterOptions", + "type": "object", + "additionalProperties": false, + "properties": { + "JsonWriterOptions": { + "description": "Gets or sets JsonWriterOptions.", + "oneOf": [ + { + "$ref": "#/definitions/JsonConsoleFormatterOptions/definitions/JsonWriterOptions" + } + ] + }, + "IncludeScopes": { + "type": "boolean", + "description": "Gets or sets whether scopes should be included or not." + }, + "TimestampFormat": { + "type": [ + "null", + "string" + ], + "description": "Gets or sets the format string used to format the timestamp in logging messages. Defaults to null." + }, + "UseUtcTimestamp": { + "type": "boolean", + "description": "Gets or sets whether or not UTC timezone should be used for timestamps in logging messages. Defaults to false.", + "default": false + } + }, + "definitions": { + "JsonWriterOptions": { + "type": "object", + "additionalProperties": false, + "properties": { + "Encoder": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/JsonConsoleFormatterOptions/definitions/JavaScriptEncoder" + } + ] + }, + "Indented": { + "type": "boolean" + }, + "SkipValidation": { + "type": "boolean" + } + } + }, + "JavaScriptEncoder": { + "allOf": [ + { + "$ref": "#/definitions/JsonConsoleFormatterOptions/definitions/TextEncoder" + }, + { + "type": "object", + "x-abstract": true, + "additionalProperties": false + } + ] + }, + "TextEncoder": { + "type": "object", + "x-abstract": true, + "additionalProperties": false + } + } + }, + "SimpleConsoleFormatterOptions": { + "title": "SimpleConsoleFormatterOptions", + "type": "object", + "additionalProperties": false, + "properties": { + "ColorBehavior": { + "description": "Determines when to use color when logging messages.", + "oneOf": [ + { + "$ref": "#/definitions/SimpleConsoleFormatterOptions/definitions/LoggerColorBehavior" + } + ] + }, + "SingleLine": { + "type": "boolean", + "description": "When false, the entire message gets logged in a single line." + }, + "IncludeScopes": { + "type": "boolean", + "description": "Gets or sets whether scopes should be included or not." + }, + "TimestampFormat": { + "type": [ + "null", + "string" + ], + "description": "Gets or sets the format string used to format the timestamp in logging messages. Defaults to null." + }, + "UseUtcTimestamp": { + "type": "boolean", + "description": "Gets or sets whether or not UTC timezone should be used for timestamps in logging messages. Defaults to false.", + "default": false + } + }, + "definitions": { + "LoggerColorBehavior": { + "type": "string", + "description": "", + "x-enumNames": [ + "Default", + "Enabled", + "Disabled" + ], + "enum": [ + "Default", + "Enabled", + "Disabled" + ] + } + } + }, + "ConsoleFormatterOptions": { + "title": "ConsoleFormatterOptions", + "type": "object", + "additionalProperties": false, + "properties": { + "IncludeScopes": { + "type": "boolean", + "description": "Gets or sets whether scopes should be included or not." + }, + "TimestampFormat": { + "type": [ + "null", + "string" + ], + "description": "Gets or sets the format string used to format the timestamp in logging messages. Defaults to null." + }, + "UseUtcTimestamp": { + "type": "boolean", + "description": "Gets or sets whether or not UTC timezone should be used for timestamps in logging messages. Defaults to false.", + "default": false + } + } } } } \ No newline at end of file diff --git a/dotnet-monitor.sln b/dotnet-monitor.sln index 644cc47df1d..0ad570d658c 100644 --- a/dotnet-monitor.sln +++ b/dotnet-monitor.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29019.234 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31605.382 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{19FAB78C-3351-4911-8F0C-8C6056401740}" EndProject @@ -34,6 +34,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monit 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.Options", "src\Microsoft.Diagnostics.Monitoring.Options\Microsoft.Diagnostics.Monitoring.Options.csproj", "{173F959B-231B-45D1-8328-9460D4C5BC71}" +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 @@ -82,6 +84,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 + {173F959B-231B-45D1-8328-9460D4C5BC71}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {173F959B-231B-45D1-8328-9460D4C5BC71}.Debug|Any CPU.Build.0 = Debug|Any CPU + {173F959B-231B-45D1-8328-9460D4C5BC71}.Release|Any CPU.ActiveCfg = Release|Any CPU + {173F959B-231B-45D1-8328-9460D4C5BC71}.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 @@ -104,6 +110,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} + {173F959B-231B-45D1-8328-9460D4C5BC71} = {19FAB78C-3351-4911-8F0C-8C6056401740} {0DBE362D-82F1-4740-AE6A-40C1A82EDCDB} = {C7568468-1C79-4944-8136-18812A7F9EA7} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index b4776a3883c..32c7a8a9ece 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -4,35 +4,35 @@ https://github.com/dotnet/command-line-api 166610c56ff732093f0145a2911d4f6c40b786da - + https://github.com/dotnet/diagnostics - 6771e250058b81654a6d4fd8356a009436ab5061 + 3f15cc67105068c47743e8719c0e131dac9abb83 - + https://github.com/dotnet/diagnostics - 6771e250058b81654a6d4fd8356a009436ab5061 + 3f15cc67105068c47743e8719c0e131dac9abb83 - + https://github.com/dotnet/arcade - 62a8aafffd4c68ef887680f6837abdff906a662c + 382667fff0b58c362855a42c3529ba294fd0514c - + https://github.com/dotnet/arcade - 62a8aafffd4c68ef887680f6837abdff906a662c + 382667fff0b58c362855a42c3529ba294fd0514c - + https://github.com/dotnet/symstore - 3ed87724fe4e98c7ecc77617720591783ee2e676 + a2ecfd399a548818cd6e596fa401aae42d01c77e - + https://github.com/dotnet/aspnetcore - 85180121312ec21d6f33d99acb2723868586a3a2 + 9b6afb49f6981de4e242e4781a88caf3804e83e9 - + https://github.com/dotnet/runtime - d90f6b6c86be7001dc839e147ab229dfd1c7d20d + 58efa4b79751a2dad08d9bf7ca67930f8160afe3 diff --git a/eng/Versions.props b/eng/Versions.props index 7bc5cb8ca4e..09941950fb0 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -27,16 +27,16 @@ --> - 6.0.0-beta.21379.2 + 6.0.0-beta.21406.6 - 6.0.0-rc.1.21381.3 + 6.0.0-rc.1.21408.1 - 5.0.0-preview.21380.1 - 5.0.0-preview.21380.1 + 5.0.0-preview.21406.1 + 5.0.0-preview.21406.1 - 6.0.0-rc.1.21401.3 + 6.0.0-rc.1.21406.5 - 1.0.215101 + 1.0.240201 3.1.15 @@ -55,10 +55,12 @@ 1.1.0 5.0.0 5.0.2 + 5.0.0 5.0.0 5.0.1 1.2.3 2.0.0-beta1.20468.1 + 5.0.0 4.5.1 5.0.0 4.7.2 diff --git a/eng/common/cross/arm/sources.list.trusty b/eng/common/cross/arm/sources.list.trusty deleted file mode 100644 index 07d8f88d82e..00000000000 --- a/eng/common/cross/arm/sources.list.trusty +++ /dev/null @@ -1,11 +0,0 @@ -deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe -deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe - -deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted universe -deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted universe - -deb http://ports.ubuntu.com/ubuntu-ports/ trusty-backports main restricted -deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-backports main restricted - -deb http://ports.ubuntu.com/ubuntu-ports/ trusty-security main restricted universe multiverse -deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-security main restricted universe multiverse \ No newline at end of file diff --git a/eng/common/cross/arm/trusty-lttng-2.4.patch b/eng/common/cross/arm/trusty-lttng-2.4.patch deleted file mode 100644 index 8e4dd7ae719..00000000000 --- a/eng/common/cross/arm/trusty-lttng-2.4.patch +++ /dev/null @@ -1,71 +0,0 @@ -From e72c9d7ead60e3317bd6d1fade995c07021c947b Mon Sep 17 00:00:00 2001 -From: Mathieu Desnoyers -Date: Thu, 7 May 2015 13:25:04 -0400 -Subject: [PATCH] Fix: building probe providers with C++ compiler - -Robert Daniels wrote: -> > I'm attempting to use lttng userspace tracing with a C++ application -> > on an ARM platform. I'm using GCC 4.8.4 on Linux 3.14 with the 2.6 -> > release of lttng. I've compiled lttng-modules, lttng-ust, and -> > lttng-tools and have been able to get a simple test working with C -> > code. When I attempt to run the hello.cxx test on my target it will -> > segfault. -> -> -> I spent a little time digging into this issue and finally discovered the -> cause of my segfault with ARM C++ tracepoints. -> -> There is a struct called 'lttng_event' in ust-events.h which contains an -> empty union 'u'. This was the cause of my issue. Under C, this empty union -> compiles to a zero byte member while under C++ it compiles to a one byte -> member, and in my case was four-byte aligned which caused my C++ code to -> have the 'cds_list_head node' offset incorrectly by four bytes. This lead -> to an incorrect linked list structure which caused my issue. -> -> Since this union is empty, I simply removed it from the struct and everything -> worked correctly. -> -> I don't know the history or purpose behind this empty union so I'd like to -> know if this is a safe fix. If it is I can submit a patch with the union -> removed. - -That's a very nice catch! - -We do not support building tracepoint probe provider with -g++ yet, as stated in lttng-ust(3): - -"- Note for C++ support: although an application instrumented with - tracepoints can be compiled with g++, tracepoint probes should be - compiled with gcc (only tested with gcc so far)." - -However, if it works fine with this fix, then I'm tempted to take it, -especially because removing the empty union does not appear to affect -the layout of struct lttng_event as seen from liblttng-ust, which must -be compiled with a C compiler, and from probe providers compiled with -a C compiler. So all we are changing is the layout of a probe provider -compiled with a C++ compiler, which is anyway buggy at the moment, -because it is not compatible with the layout expected by liblttng-ust -compiled with a C compiler. - -Reported-by: Robert Daniels -Signed-off-by: Mathieu Desnoyers ---- - include/lttng/ust-events.h | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/usr/include/lttng/ust-events.h b/usr/include/lttng/ust-events.h -index 328a875..3d7a274 100644 ---- a/usr/include/lttng/ust-events.h -+++ b/usr/include/lttng/ust-events.h -@@ -407,8 +407,6 @@ struct lttng_event { - void *_deprecated1; - struct lttng_ctx *ctx; - enum lttng_ust_instrumentation instrumentation; -- union { -- } u; - struct cds_list_head node; /* Event list in session */ - struct cds_list_head _deprecated2; - void *_deprecated3; --- -2.7.4 - diff --git a/eng/common/cross/arm/trusty.patch b/eng/common/cross/arm/trusty.patch deleted file mode 100644 index 2f2972f8eb5..00000000000 --- a/eng/common/cross/arm/trusty.patch +++ /dev/null @@ -1,97 +0,0 @@ -diff -u -r a/usr/include/urcu/uatomic/generic.h b/usr/include/urcu/uatomic/generic.h ---- a/usr/include/urcu/uatomic/generic.h 2014-03-28 06:04:42.000000000 +0900 -+++ b/usr/include/urcu/uatomic/generic.h 2017-02-13 10:35:21.189927116 +0900 -@@ -65,17 +65,17 @@ - switch (len) { - #ifdef UATOMIC_HAS_ATOMIC_BYTE - case 1: -- return __sync_val_compare_and_swap_1(addr, old, _new); -+ return __sync_val_compare_and_swap_1((uint8_t *) addr, old, _new); - #endif - #ifdef UATOMIC_HAS_ATOMIC_SHORT - case 2: -- return __sync_val_compare_and_swap_2(addr, old, _new); -+ return __sync_val_compare_and_swap_2((uint16_t *) addr, old, _new); - #endif - case 4: -- return __sync_val_compare_and_swap_4(addr, old, _new); -+ return __sync_val_compare_and_swap_4((uint32_t *) addr, old, _new); - #if (CAA_BITS_PER_LONG == 64) - case 8: -- return __sync_val_compare_and_swap_8(addr, old, _new); -+ return __sync_val_compare_and_swap_8((uint64_t *) addr, old, _new); - #endif - } - _uatomic_link_error(); -@@ -100,20 +100,20 @@ - switch (len) { - #ifdef UATOMIC_HAS_ATOMIC_BYTE - case 1: -- __sync_and_and_fetch_1(addr, val); -+ __sync_and_and_fetch_1((uint8_t *) addr, val); - return; - #endif - #ifdef UATOMIC_HAS_ATOMIC_SHORT - case 2: -- __sync_and_and_fetch_2(addr, val); -+ __sync_and_and_fetch_2((uint16_t *) addr, val); - return; - #endif - case 4: -- __sync_and_and_fetch_4(addr, val); -+ __sync_and_and_fetch_4((uint32_t *) addr, val); - return; - #if (CAA_BITS_PER_LONG == 64) - case 8: -- __sync_and_and_fetch_8(addr, val); -+ __sync_and_and_fetch_8((uint64_t *) addr, val); - return; - #endif - } -@@ -139,20 +139,20 @@ - switch (len) { - #ifdef UATOMIC_HAS_ATOMIC_BYTE - case 1: -- __sync_or_and_fetch_1(addr, val); -+ __sync_or_and_fetch_1((uint8_t *) addr, val); - return; - #endif - #ifdef UATOMIC_HAS_ATOMIC_SHORT - case 2: -- __sync_or_and_fetch_2(addr, val); -+ __sync_or_and_fetch_2((uint16_t *) addr, val); - return; - #endif - case 4: -- __sync_or_and_fetch_4(addr, val); -+ __sync_or_and_fetch_4((uint32_t *) addr, val); - return; - #if (CAA_BITS_PER_LONG == 64) - case 8: -- __sync_or_and_fetch_8(addr, val); -+ __sync_or_and_fetch_8((uint64_t *) addr, val); - return; - #endif - } -@@ -180,17 +180,17 @@ - switch (len) { - #ifdef UATOMIC_HAS_ATOMIC_BYTE - case 1: -- return __sync_add_and_fetch_1(addr, val); -+ return __sync_add_and_fetch_1((uint8_t *) addr, val); - #endif - #ifdef UATOMIC_HAS_ATOMIC_SHORT - case 2: -- return __sync_add_and_fetch_2(addr, val); -+ return __sync_add_and_fetch_2((uint16_t *) addr, val); - #endif - case 4: -- return __sync_add_and_fetch_4(addr, val); -+ return __sync_add_and_fetch_4((uint32_t *) addr, val); - #if (CAA_BITS_PER_LONG == 64) - case 8: -- return __sync_add_and_fetch_8(addr, val); -+ return __sync_add_and_fetch_8((uint64_t *) addr, val); - #endif - } - _uatomic_link_error(); diff --git a/eng/common/cross/arm64/sources.list.trusty b/eng/common/cross/arm64/sources.list.trusty deleted file mode 100644 index 07d8f88d82e..00000000000 --- a/eng/common/cross/arm64/sources.list.trusty +++ /dev/null @@ -1,11 +0,0 @@ -deb http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe -deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty main restricted universe - -deb http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted universe -deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-updates main restricted universe - -deb http://ports.ubuntu.com/ubuntu-ports/ trusty-backports main restricted -deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-backports main restricted - -deb http://ports.ubuntu.com/ubuntu-ports/ trusty-security main restricted universe multiverse -deb-src http://ports.ubuntu.com/ubuntu-ports/ trusty-security main restricted universe multiverse \ No newline at end of file diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh index 735a4c82838..5c05b39f101 100644 --- a/eng/common/cross/build-rootfs.sh +++ b/eng/common/cross/build-rootfs.sh @@ -6,10 +6,10 @@ usage() { echo "Usage: $0 [BuildArch] [CodeName] [lldbx.y] [--skipunmount] --rootfsdir ]" echo "BuildArch can be: arm(default), armel, arm64, x86" - echo "CodeName - optional, Code name for Linux, can be: trusty, xenial(default), zesty, bionic, alpine, alpine3.9 or alpine3.13. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen." - echo " for FreeBSD can be: freebsd11 or freebsd12." + echo "CodeName - optional, Code name for Linux, can be: xenial(default), zesty, bionic, alpine, alpine3.9 or alpine3.13. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen." + echo " for FreeBSD can be: freebsd11, freebsd12, freebsd13" echo " for illumos can be: illumos." - echo "lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FReeBSD" + echo "lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FreeBSD" echo "--skipunmount - optional, will skip the unmount of rootfs folder." echo "--use-mirror - optional, use mirror URL to fetch resources, when available." exit 1 @@ -60,13 +60,15 @@ __AlpinePackages+=" krb5-dev" __AlpinePackages+=" openssl-dev" __AlpinePackages+=" zlib-dev" -__FreeBSDBase="12.1-RELEASE" +__FreeBSDBase="12.2-RELEASE" __FreeBSDPkg="1.12.0" +__FreeBSDABI="12" __FreeBSDPackages="libunwind" __FreeBSDPackages+=" icu" __FreeBSDPackages+=" libinotify" __FreeBSDPackages+=" lttng-ust" __FreeBSDPackages+=" krb5" +__FreeBSDPackages+=" terminfo-db" __IllumosPackages="icu-64.2nb2" __IllumosPackages+=" mit-krb5-1.16.2nb4" @@ -144,11 +146,6 @@ while :; do no-lldb) unset __LLDB_Package ;; - trusty) # Ubuntu 14.04 - if [ "$__CodeName" != "jessie" ]; then - __CodeName=trusty - fi - ;; xenial) # Ubuntu 16.04 if [ "$__CodeName" != "jessie" ]; then __CodeName=xenial @@ -208,12 +205,20 @@ while :; do ;; freebsd11) __FreeBSDBase="11.3-RELEASE" + __FreeBSDABI="11" ;& freebsd12) __CodeName=freebsd __BuildArch=x64 __SkipUnmount=1 ;; + freebsd13) + __CodeName=freebsd + __FreeBSDBase="13.0-RELEASE" + __FreeBSDABI="13" + __BuildArch=x64 + __SkipUnmount=1 + ;; illumos) __CodeName=illumos __BuildArch=x64 @@ -291,9 +296,9 @@ if [[ "$__CodeName" == "alpine" ]]; then rm -r $__ApkToolsDir elif [[ "$__CodeName" == "freebsd" ]]; then mkdir -p $__RootfsDir/usr/local/etc + JOBS="$(getconf _NPROCESSORS_ONLN)" wget -O - https://download.freebsd.org/ftp/releases/amd64/${__FreeBSDBase}/base.txz | tar -C $__RootfsDir -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version - # For now, ask for 11 ABI even on 12. This can be revisited later. - echo "ABI = \"FreeBSD:11:amd64\"; FINGERPRINTS = \"${__RootfsDir}/usr/share/keys\"; REPOS_DIR = [\"${__RootfsDir}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > ${__RootfsDir}/usr/local/etc/pkg.conf + echo "ABI = \"FreeBSD:${__FreeBSDABI}:amd64\"; FINGERPRINTS = \"${__RootfsDir}/usr/share/keys\"; REPOS_DIR = [\"${__RootfsDir}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > ${__RootfsDir}/usr/local/etc/pkg.conf echo "FreeBSD: { url: "pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly", mirror_type: \"srv\", signature_type: \"fingerprints\", fingerprints: \"${__RootfsDir}/usr/share/keys/pkg\", enabled: yes }" > ${__RootfsDir}/etc/pkg/FreeBSD.conf mkdir -p $__RootfsDir/tmp # get and build package manager @@ -301,7 +306,7 @@ elif [[ "$__CodeName" == "freebsd" ]]; then cd $__RootfsDir/tmp/pkg-${__FreeBSDPkg} # needed for install to succeed mkdir -p $__RootfsDir/host/etc - ./autogen.sh && ./configure --prefix=$__RootfsDir/host && make && make install + ./autogen.sh && ./configure --prefix=$__RootfsDir/host && make -j "$JOBS" && make install rm -rf $__RootfsDir/tmp/pkg-${__FreeBSDPkg} # install packages we need. INSTALL_AS_USER=$(whoami) $__RootfsDir/host/sbin/pkg -r $__RootfsDir -C $__RootfsDir/usr/local/etc/pkg.conf update @@ -364,13 +369,6 @@ elif [[ -n $__CodeName ]]; then umount $__RootfsDir/* || true fi - if [[ "$__BuildArch" == "arm" && "$__CodeName" == "trusty" ]]; then - pushd $__RootfsDir - patch -p1 < $__CrossDir/$__BuildArch/trusty.patch - patch -p1 < $__CrossDir/$__BuildArch/trusty-lttng-2.4.patch - popd - fi - if [[ "$__BuildArch" == "armel" && "$__CodeName" == "jessie" ]]; then pushd $__RootfsDir patch -p1 < $__CrossDir/$__BuildArch/armel.jessie.patch diff --git a/eng/common/cross/x86/sources.list.trusty b/eng/common/cross/x86/sources.list.trusty deleted file mode 100644 index 9b3085436e9..00000000000 --- a/eng/common/cross/x86/sources.list.trusty +++ /dev/null @@ -1,11 +0,0 @@ -deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe -deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe - -deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe -deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe - -deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted -deb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted - -deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse -deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse diff --git a/eng/common/internal/Tools.csproj b/eng/common/internal/Tools.csproj index 2067b8df8d9..beb9c4648ea 100644 --- a/eng/common/internal/Tools.csproj +++ b/eng/common/internal/Tools.csproj @@ -1,5 +1,4 @@ - net472 diff --git a/eng/common/templates/job/publish-build-assets.yml b/eng/common/templates/job/publish-build-assets.yml index 3b9e2524ff3..fe9dfdf720c 100644 --- a/eng/common/templates/job/publish-build-assets.yml +++ b/eng/common/templates/job/publish-build-assets.yml @@ -94,7 +94,31 @@ jobs: PathtoPublish: '$(Build.StagingDirectory)/ReleaseConfigs.txt' PublishLocation: Container ArtifactName: ReleaseConfigs - + + - task: powershell@2 + displayName: Check if SymbolPublishingExclusionsFile.txt exists + inputs: + targetType: inline + script: | + $symbolExclusionfile = "$(Build.SourcesDirectory)/eng/SymbolPublishingExclusionsFile.txt" + if(Test-Path -Path $symbolExclusionfile) + { + Write-Host "SymbolExclusionFile exists" + Write-Host "##vso[task.setvariable variable=SymbolExclusionFile]true" + } + else{ + Write-Host "Symbols Exclusion file does not exists" + Write-Host "##vso[task.setvariable variable=SymbolExclusionFile]false" + } + + - task: PublishBuildArtifacts@1 + displayName: Publish SymbolPublishingExclusionsFile Artifact + condition: eq(variables['SymbolExclusionFile'], 'true') + inputs: + PathtoPublish: '$(Build.SourcesDirectory)/eng/SymbolPublishingExclusionsFile.txt' + PublishLocation: Container + ArtifactName: ReleaseConfigs + - ${{ if eq(parameters.enablePublishBuildArtifacts, 'true') }}: - template: /eng/common/templates/steps/publish-logs.yml parameters: diff --git a/eng/common/templates/phases/base.yml b/eng/common/templates/phases/base.yml deleted file mode 100644 index 0123cf43b16..00000000000 --- a/eng/common/templates/phases/base.yml +++ /dev/null @@ -1,130 +0,0 @@ -parameters: - # Optional: Clean sources before building - clean: true - - # Optional: Git fetch depth - fetchDepth: '' - - # Optional: name of the phase (not specifying phase name may cause name collisions) - name: '' - # Optional: display name of the phase - displayName: '' - - # Optional: condition for the job to run - condition: '' - - # Optional: dependencies of the phase - dependsOn: '' - - # Required: A defined YAML queue - queue: {} - - # Required: build steps - steps: [] - - # Optional: variables - variables: {} - - # Optional: should run as a public build even in the internal project - # if 'true', the build won't run any of the internal only steps, even if it is running in non-public projects. - runAsPublic: false - - ## Telemetry variables - - # Optional: enable sending telemetry - # if 'true', these "variables" must be specified in the variables object or as part of the queue matrix - # _HelixBuildConfig - differentiate between Debug, Release, other - # _HelixSource - Example: build/product - # _HelixType - Example: official/dotnet/arcade/$(Build.SourceBranch) - enableTelemetry: false - - # Optional: Enable installing Microbuild plugin - # if 'true', these "variables" must be specified in the variables object or as part of the queue matrix - # _TeamName - the name of your team - # _SignType - 'test' or 'real' - enableMicrobuild: false - -# Internal resources (telemetry, microbuild) can only be accessed from non-public projects, -# and some (Microbuild) should only be applied to non-PR cases for internal builds. - -phases: -- phase: ${{ parameters.name }} - - ${{ if ne(parameters.displayName, '') }}: - displayName: ${{ parameters.displayName }} - - ${{ if ne(parameters.condition, '') }}: - condition: ${{ parameters.condition }} - - ${{ if ne(parameters.dependsOn, '') }}: - dependsOn: ${{ parameters.dependsOn }} - - queue: ${{ parameters.queue }} - - ${{ if ne(parameters.variables, '') }}: - variables: - ${{ insert }}: ${{ parameters.variables }} - - steps: - - checkout: self - clean: ${{ parameters.clean }} - ${{ if ne(parameters.fetchDepth, '') }}: - fetchDepth: ${{ parameters.fetchDepth }} - - - ${{ if eq(parameters.enableTelemetry, 'true') }}: - - template: /eng/common/templates/steps/telemetry-start.yml - parameters: - buildConfig: $(_HelixBuildConfig) - helixSource: $(_HelixSource) - helixType: $(_HelixType) - runAsPublic: ${{ parameters.runAsPublic }} - - - ${{ if eq(parameters.enableMicrobuild, 'true') }}: - # Internal only resource, and Microbuild signing shouldn't be applied to PRs. - - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - task: MicroBuildSigningPlugin@2 - displayName: Install MicroBuild plugin - inputs: - signType: $(_SignType) - zipSources: false - feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json - - env: - TeamName: $(_TeamName) - continueOnError: false - condition: and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT')) - - # Run provided build steps - - ${{ parameters.steps }} - - - ${{ if eq(parameters.enableMicrobuild, 'true') }}: - # Internal only resources - - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - task: MicroBuildCleanup@1 - displayName: Execute Microbuild cleanup tasks - condition: and(always(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT')) - env: - TeamName: $(_TeamName) - - - ${{ if eq(parameters.enableTelemetry, 'true') }}: - - template: /eng/common/templates/steps/telemetry-end.yml - parameters: - helixSource: $(_HelixSource) - helixType: $(_HelixType) - - - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - task: CopyFiles@2 - displayName: Gather Asset Manifests - inputs: - SourceFolder: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/AssetManifest' - TargetFolder: '$(Build.StagingDirectory)/AssetManifests' - continueOnError: false - condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) - - task: PublishBuildArtifacts@1 - displayName: Push Asset Manifests - inputs: - PathtoPublish: '$(Build.StagingDirectory)/AssetManifests' - PublishLocation: Container - ArtifactName: AssetManifests - continueOnError: false - condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) diff --git a/eng/common/templates/phases/publish-build-assets.yml b/eng/common/templates/phases/publish-build-assets.yml deleted file mode 100644 index 4e51e472e2b..00000000000 --- a/eng/common/templates/phases/publish-build-assets.yml +++ /dev/null @@ -1,52 +0,0 @@ -parameters: - dependsOn: '' - queue: {} - configuration: 'Debug' - condition: succeeded() - continueOnError: false - runAsPublic: false - publishUsingPipelines: false -phases: - - phase: Asset_Registry_Publish - displayName: Publish to Build Asset Registry - dependsOn: ${{ parameters.dependsOn }} - queue: ${{ parameters.queue }} - variables: - _BuildConfig: ${{ parameters.configuration }} - steps: - - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - task: DownloadBuildArtifacts@0 - displayName: Download artifact - inputs: - artifactName: AssetManifests - downloadPath: '$(Build.StagingDirectory)/Download' - checkDownloadedFiles: true - condition: ${{ parameters.condition }} - continueOnError: ${{ parameters.continueOnError }} - - task: AzureKeyVault@1 - inputs: - azureSubscription: 'DotNet-Engineering-Services_KeyVault' - KeyVaultName: EngKeyVault - SecretsFilter: 'MaestroAccessToken' - condition: ${{ parameters.condition }} - continueOnError: ${{ parameters.continueOnError }} - - task: PowerShell@2 - displayName: Publish Build Assets - inputs: - filePath: eng\common\sdk-task.ps1 - arguments: -task PublishBuildAssets -restore -msbuildEngine dotnet - /p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests' - /p:BuildAssetRegistryToken=$(MaestroAccessToken) - /p:MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com - /p:PublishUsingPipelines=${{ parameters.publishUsingPipelines }} - /p:Configuration=$(_BuildConfig) - condition: ${{ parameters.condition }} - continueOnError: ${{ parameters.continueOnError }} - - task: PublishBuildArtifacts@1 - displayName: Publish Logs to VSTS - inputs: - PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)' - PublishLocation: Container - ArtifactName: $(Agent.Os)_Asset_Registry_Publish - continueOnError: true - condition: always() diff --git a/eng/common/templates/steps/source-build.yml b/eng/common/templates/steps/source-build.yml index 705b7a1c847..ba40dc82f14 100644 --- a/eng/common/templates/steps/source-build.yml +++ b/eng/common/templates/steps/source-build.yml @@ -18,6 +18,35 @@ steps: set -x df -h + # If building on the internal project, the artifact feeds variable may be available (usually only if needed) + # In that case, call the feed setup script to add internal feeds corresponding to public ones. + # In addition, add an msbuild argument to copy the WIP from the repo to the target build location. + # This is because SetupNuGetSources.sh will alter the current NuGet.config file, and we need to preserve those + # changes. + $internalRestoreArgs= + if [ '$(dn-bot-dnceng-artifact-feeds-rw)' != '$''(dn-bot-dnceng-artifact-feeds-rw)' ]; then + # Temporarily work around https://github.com/dotnet/arcade/issues/7709 + chmod +x $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh + $(Build.SourcesDirectory)/eng/common/SetupNugetSources.sh $(Build.SourcesDirectory)/NuGet.config $(dn-bot-dnceng-artifact-feeds-rw) + internalRestoreArgs='/p:CopyWipIntoInnerSourceBuildRepo=true' + + # The 'Copy WIP' feature of source build uses git stash to apply changes from the original repo. + # This only works if there is a username/email configured, which won't be the case in most CI runs. + git config --get user.email + if [ $? -ne 0 ]; then + git config user.email dn-bot@microsoft.com + git config user.name dn-bot + fi + fi + + # If building on the internal project, the internal storage variable may be available (usually only if needed) + # In that case, add variables to allow the download of internal runtimes if the specified versions are not found + # in the default public locations. + internalRuntimeDownloadArgs= + if [ '$(dotnetclimsrc-read-sas-token-base64)' != '$''(dotnetclimsrc-read-sas-token-base64)' ]; then + internalRuntimeDownloadArgs='/p:DotNetRuntimeSourceFeed=https://dotnetclimsrc.blob.core.windows.net/dotnet /p:DotNetRuntimeSourceFeedKey=$(dotnetclimsrc-read-sas-token-base64) --runtimesourcefeed https://dotnetclimsrc.blob.core.windows.net/dotnet --runtimesourcefeedkey $(dotnetclimsrc-read-sas-token-base64)' + fi + buildConfig=Release # Check if AzDO substitutes in a build config from a variable, and use it if so. if [ '$(_BuildConfig)' != '$''(_BuildConfig)' ]; then @@ -29,11 +58,6 @@ steps: officialBuildArgs='/p:DotNetPublishUsingPipelines=true /p:OfficialBuildId=$(BUILD.BUILDNUMBER)' fi - internalRuntimeDownloadArgs= - if [ '$(dotnetclimsrc-read-sas-token-base64)' != '$''(dotnetclimsrc-read-sas-token-base64)' ]; then - internalRuntimeDownloadArgs='--runtimesourcefeed https://dotnetclimsrc.blob.core.windows.net/dotnet --runtimesourcefeedkey $(dotnetclimsrc-read-sas-token-base64)' - fi - targetRidArgs= if [ '${{ parameters.platform.targetRID }}' != '' ]; then targetRidArgs='/p:TargetRid=${{ parameters.platform.targetRID }}' @@ -49,6 +73,7 @@ steps: --restore --build --pack $publishArgs -bl \ $officialBuildArgs \ $internalRuntimeDownloadArgs \ + $internalRestoreArgs \ $targetRidArgs \ /p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \ /p:ArcadeBuildFromSource=true diff --git a/global.json b/global.json index 18ce89c52f1..38355eab28a 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "6.0.100-preview.6.21355.2", + "dotnet": "6.0.100-rc.1.21379.2", "runtimes": { "aspnetcore": [ "$(MicrosoftAspNetCoreApp31Version)", @@ -16,6 +16,6 @@ }, "msbuild-sdks": { "Microsoft.Build.NoTargets": "2.0.1", - "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21379.2" + "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21406.6" } } diff --git a/src/Tools/dotnet-monitor/Auth/ApiAuthenticationOptions.cs b/src/Microsoft.Diagnostics.Monitoring.Options/ApiAuthenticationOptions.cs similarity index 92% rename from src/Tools/dotnet-monitor/Auth/ApiAuthenticationOptions.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/ApiAuthenticationOptions.cs index 9fc44ae3f59..a0bdc3cddfd 100644 --- a/src/Tools/dotnet-monitor/Auth/ApiAuthenticationOptions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/ApiAuthenticationOptions.cs @@ -5,11 +5,7 @@ using Microsoft.Diagnostics.Monitoring.WebApi; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor -#endif { internal sealed class ApiAuthenticationOptions { diff --git a/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProviderOptions.Validate.cs b/src/Microsoft.Diagnostics.Monitoring.Options/AzureBlobEgressProviderOptions.Validate.cs similarity index 91% rename from src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProviderOptions.Validate.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/AzureBlobEgressProviderOptions.Validate.cs index 5217effeab3..ce7da1d8bc8 100644 --- a/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProviderOptions.Validate.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/AzureBlobEgressProviderOptions.Validate.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Diagnostics.Monitoring.WebApi; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -24,7 +25,7 @@ IEnumerable IValidatableObject.Validate(ValidationContext vali results.Add( new ValidationResult( string.Format( - Strings.ErrorMessage_TwoFieldsMissing, + OptionsDisplayStrings.ErrorMessage_TwoFieldsMissing, nameof(AccountKey), nameof(SharedAccessSignature)))); } diff --git a/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProviderOptions.cs b/src/Microsoft.Diagnostics.Monitoring.Options/AzureBlobEgressProviderOptions.cs similarity index 96% rename from src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProviderOptions.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/AzureBlobEgressProviderOptions.cs index 069f9507ac2..142af1b4eff 100644 --- a/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProviderOptions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/AzureBlobEgressProviderOptions.cs @@ -6,11 +6,7 @@ using System; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.Egress.AzureBlob -#endif { /// /// Egress provider options for Azure blob storage. diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/CorsConfiguration.cs b/src/Microsoft.Diagnostics.Monitoring.Options/CorsConfiguration.cs similarity index 83% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/CorsConfiguration.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/CorsConfiguration.cs index 79caf2d14c1..2d551dac340 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/CorsConfiguration.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/CorsConfiguration.cs @@ -4,13 +4,7 @@ using System.ComponentModel.DataAnnotations; -#if UNITTEST -using Microsoft.Diagnostics.Monitoring.WebApi; - -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { public class CorsConfiguration { diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/DiagnosticPortConnectionMode.cs b/src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortConnectionMode.cs similarity index 66% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/DiagnosticPortConnectionMode.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortConnectionMode.cs index 8f9e90af291..4979b215df9 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/DiagnosticPortConnectionMode.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortConnectionMode.cs @@ -2,15 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Text.Json.Serialization; - -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { - [JsonConverter(typeof(JsonStringEnumConverter))] public enum DiagnosticPortConnectionMode { Connect, diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/DiagnosticPortOptions.cs b/src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortOptions.cs similarity index 90% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/DiagnosticPortOptions.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortOptions.cs index e056170c6c3..757fd59129c 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/DiagnosticPortOptions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortOptions.cs @@ -5,13 +5,7 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -#if UNITTEST -using Microsoft.Diagnostics.Monitoring.WebApi; - -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { public class DiagnosticPortOptions { diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/DiagnosticPortOptionsDefaults.cs b/src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortOptionsDefaults.cs similarity index 75% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/DiagnosticPortOptionsDefaults.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortOptionsDefaults.cs index 43103d5cd2b..3ffc43e4c61 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/DiagnosticPortOptionsDefaults.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/DiagnosticPortOptionsDefaults.cs @@ -2,13 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if UNITTEST -using Microsoft.Diagnostics.Monitoring.WebApi; - -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { internal class DiagnosticPortOptionsDefaults { diff --git a/src/Tools/dotnet-monitor/EgressOptions.cs b/src/Microsoft.Diagnostics.Monitoring.Options/EgressOptions.cs similarity index 92% rename from src/Tools/dotnet-monitor/EgressOptions.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/EgressOptions.cs index 4b6089e73bf..f6011427b63 100644 --- a/src/Tools/dotnet-monitor/EgressOptions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/EgressOptions.cs @@ -3,18 +3,12 @@ // See the LICENSE file in the project root for more information. using Microsoft.Diagnostics.Monitoring.WebApi; -#if !UNITTEST using Microsoft.Diagnostics.Tools.Monitor.Egress.AzureBlob; using Microsoft.Diagnostics.Tools.Monitor.Egress.FileSystem; -#endif using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor -#endif { internal sealed class EgressOptions { diff --git a/src/Tools/dotnet-monitor/Egress/FileSystem/FileSystemEgressProviderOptions.cs b/src/Microsoft.Diagnostics.Monitoring.Options/FileSystemEgressProviderOptions.cs similarity index 94% rename from src/Tools/dotnet-monitor/Egress/FileSystem/FileSystemEgressProviderOptions.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/FileSystemEgressProviderOptions.cs index b7d4d72687b..1b22389c665 100644 --- a/src/Tools/dotnet-monitor/Egress/FileSystem/FileSystemEgressProviderOptions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/FileSystemEgressProviderOptions.cs @@ -5,11 +5,7 @@ using Microsoft.Diagnostics.Monitoring.WebApi; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.Egress.FileSystem -#endif { /// /// Egress provider options for file system egress. diff --git a/src/Tools/dotnet-monitor/Egress/IEgressProviderCommonOptions.cs b/src/Microsoft.Diagnostics.Monitoring.Options/IEgressProviderCommonOptions.cs similarity index 88% rename from src/Tools/dotnet-monitor/Egress/IEgressProviderCommonOptions.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/IEgressProviderCommonOptions.cs index 06945ba4d03..a9a3424ae34 100644 --- a/src/Tools/dotnet-monitor/Egress/IEgressProviderCommonOptions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/IEgressProviderCommonOptions.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.Egress -#endif { /// /// Egress provider options common to all egress providers. diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/MetricsOptions.cs b/src/Microsoft.Diagnostics.Monitoring.Options/MetricsOptions.cs similarity index 95% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/MetricsOptions.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/MetricsOptions.cs index 4df13acad14..f55e59544f7 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/MetricsOptions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/MetricsOptions.cs @@ -6,13 +6,7 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; -#if UNITTEST -using Microsoft.Diagnostics.Monitoring.WebApi; - -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { /// /// Configuration for prometheus metric collection and retrieval. diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/MetricsOptionsDefaults.cs b/src/Microsoft.Diagnostics.Monitoring.Options/MetricsOptionsDefaults.cs similarity index 85% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/MetricsOptionsDefaults.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/MetricsOptionsDefaults.cs index d68cf55ec73..2d3ddc10e94 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/MetricsOptionsDefaults.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/MetricsOptionsDefaults.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { internal class MetricsOptionsDefaults { diff --git a/src/Microsoft.Diagnostics.Monitoring.Options/Microsoft.Diagnostics.Monitoring.Options.csproj b/src/Microsoft.Diagnostics.Monitoring.Options/Microsoft.Diagnostics.Monitoring.Options.csproj new file mode 100644 index 00000000000..d649bd0b337 --- /dev/null +++ b/src/Microsoft.Diagnostics.Monitoring.Options/Microsoft.Diagnostics.Monitoring.Options.csproj @@ -0,0 +1,38 @@ + + + + netstandard2.0 + true + Library + + + + + + + + + + + + + + + + + + + OptionsDisplayStrings.resx + True + True + + + + + + Microsoft.Diagnostics.Monitoring.WebApi + OptionsDisplayStrings.Designer.cs + PublicResXFileCodeGenerator + + + \ No newline at end of file diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/OptionsDisplayStrings.Designer.cs b/src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.Designer.cs similarity index 73% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/OptionsDisplayStrings.Designer.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.Designer.cs index e1110f60912..6b7f6b0c7fc 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/OptionsDisplayStrings.Designer.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.Designer.cs @@ -39,7 +39,7 @@ internal OptionsDisplayStrings() { public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Diagnostics.Monitoring.WebApi.OptionsDisplayStrings", typeof(OptionsDisplayStrings).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Diagnostics.Monitoring.Options.OptionsDisplayStrings", typeof(OptionsDisplayStrings).Assembly); resourceMan = temp; } return resourceMan; @@ -251,6 +251,96 @@ public static string DisplayAttributeDescription_CommonEgressProviderOptions_Cop } } + /// + /// Looks up a localized string similar to Gets or sets whether scopes should be included or not.. + /// + public static string DisplayAttributeDescription_ConsoleFormatterOptions_IncludeScopes { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleFormatterOptions_IncludeScopes", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gets or sets the format string used to format the timestamp in logging messages. Defaults to null.. + /// + public static string DisplayAttributeDescription_ConsoleFormatterOptions_TimestampFormat { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleFormatterOptions_TimestampFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gets or sets whether or not UTC timezone should be used for timestamps in logging messages. Defaults to false.. + /// + public static string DisplayAttributeDescription_ConsoleFormatterOptions_UseUtcTimestamp { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleFormatterOptions_UseUtcTimestamp", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reserved name for Json console formatter.. + /// + public static string DisplayAttributeDescription_ConsoleLoggerFormat_Json { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleLoggerFormat_Json", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reserved name for simple console formatter.. + /// + public static string DisplayAttributeDescription_ConsoleLoggerFormat_Simple { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleLoggerFormat_Simple", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Reserved name for systemd console formatter.. + /// + public static string DisplayAttributeDescription_ConsoleLoggerFormat_Systemd { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleLoggerFormat_Systemd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Name of the log message formatter to use. Defaults to 'Simple'.. + /// + public static string DisplayAttributeDescription_ConsoleLoggerOptions_FormatterName { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleLoggerOptions_FormatterName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Formatter options for the built-in console log formatter.. + /// + public static string DisplayAttributeDescription_ConsoleLoggerOptions_FormatterOptions { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleLoggerOptions_FormatterOptions", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A mapping of logger categories to log levels describing the threshold level at which messages are logged for each category; applies solely to ConsoleLoggerOptions.. + /// + public static string DisplayAttributeDescription_ConsoleLoggerOptions_LogLevel { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleLoggerOptions_LogLevel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The minimum level of messages that are written to Console.Error.. + /// + public static string DisplayAttributeDescription_ConsoleLoggerOptions_LogToStandardErrorThreshold { + get { + return ResourceManager.GetString("DisplayAttributeDescription_ConsoleLoggerOptions_LogToStandardErrorThreshold", resourceCulture); + } + } + /// /// Looks up a localized string similar to List of allowed CORS origins, separated by semicolons.. /// @@ -333,6 +423,78 @@ public static string DisplayAttributeDescription_FileSystemEgressProviderOptions } } + /// + /// Looks up a localized string similar to Gets or sets JsonWriterOptions.. + /// + public static string DisplayAttributeDescription_JsonConsoleFormatterOptions_WriterOptions { + get { + return ResourceManager.GetString("DisplayAttributeDescription_JsonConsoleFormatterOptions_WriterOptions", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gets or sets whether logging scopes are being captured. Defaults to true.. + /// + public static string DisplayAttributeDescription_LoggingOptions_CaptureScopes { + get { + return ResourceManager.GetString("DisplayAttributeDescription_LoggingOptions_CaptureScopes", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Logging options for the Console provider.. + /// + public static string DisplayAttributeDescription_LoggingOptions_Console { + get { + return ResourceManager.GetString("DisplayAttributeDescription_LoggingOptions_Console", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Logging options for the Debug provider.. + /// + public static string DisplayAttributeDescription_LoggingOptions_Debug { + get { + return ResourceManager.GetString("DisplayAttributeDescription_LoggingOptions_Debug", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Logging options for the EventLog provider.. + /// + public static string DisplayAttributeDescription_LoggingOptions_EventLog { + get { + return ResourceManager.GetString("DisplayAttributeDescription_LoggingOptions_EventLog", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Logging options for the EventSource provider.. + /// + public static string DisplayAttributeDescription_LoggingOptions_EventSource { + get { + return ResourceManager.GetString("DisplayAttributeDescription_LoggingOptions_EventSource", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A mapping of logger categories to log levels describing the threshold level at which messages are logged for each category; applies to no specific provider.. + /// + public static string DisplayAttributeDescription_LoggingOptions_LogLevel { + get { + return ResourceManager.GetString("DisplayAttributeDescription_LoggingOptions_LogLevel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A mapping of logger categories to log levels describing the threshold level at which messages are logged for each category; applies to the specified provider.. + /// + public static string DisplayAttributeDescription_LogLevelOptions_LogLevel { + get { + return ResourceManager.GetString("DisplayAttributeDescription_LogLevelOptions_LogLevel", resourceCulture); + } + } + /// /// Looks up a localized string similar to Name of custom metrics counters.. /// @@ -486,6 +648,24 @@ public static string DisplayAttributeDescription_ProcessFilterType_Exact { } } + /// + /// Looks up a localized string similar to Determines when to use color when logging messages.. + /// + public static string DisplayAttributeDescription_SimpleConsoleFormatterOptions_ColorBehavior { + get { + return ResourceManager.GetString("DisplayAttributeDescription_SimpleConsoleFormatterOptions_ColorBehavior", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to When false, the entire message gets logged in a single line.. + /// + public static string DisplayAttributeDescription_SimpleConsoleFormatterOptions_SingleLine { + get { + return ResourceManager.GetString("DisplayAttributeDescription_SimpleConsoleFormatterOptions_SingleLine", resourceCulture); + } + } + /// /// Looks up a localized string similar to The location for temporary dump files. Defaults to the temp folder.. /// @@ -494,5 +674,14 @@ public static string DisplayAttributeDescription_StorageOptions_DumpTempFolder { return ResourceManager.GetString("DisplayAttributeDescription_StorageOptions_DumpTempFolder", resourceCulture); } } + + /// + /// Looks up a localized string similar to The {0} field or the {1} field is required.. + /// + public static string ErrorMessage_TwoFieldsMissing { + get { + return ResourceManager.GetString("ErrorMessage_TwoFieldsMissing", resourceCulture); + } + } } } diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/OptionsDisplayStrings.resx b/src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx similarity index 76% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/OptionsDisplayStrings.resx rename to src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx index aa6c3a630d4..31b5c1f23f7 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/OptionsDisplayStrings.resx +++ b/src/Microsoft.Diagnostics.Monitoring.Options/OptionsDisplayStrings.resx @@ -201,6 +201,46 @@ Buffer size used when copying data from an egress callback returning a stream to the egress callback that is provided a stream to which data is written. The description provided for the CopyBufferSize parameter on all egress provider options. + + Gets or sets whether scopes should be included or not. + The description provider for the IncludesScopes parameter on FormatterOptions. + + + Gets or sets the format string used to format the timestamp in logging messages. Defaults to null. + The description provider for the TimestampFormat parameter on ConsoleFormatterOptions. + + + Gets or sets whether or not UTC timezone should be used for timestamps in logging messages. Defaults to false. + The description provider for the UseUtcTimestamp parameter on ConsoleFormatterOptions. + + + Reserved name for Json console formatter. + The description provider for the Json parameter on ConsoleLoggerFormat. + + + Reserved name for simple console formatter. + The description provider for the Simple parameter on ConsoleLoggerFormat. + + + Reserved name for systemd console formatter. + The description provider for the Systemd parameter on ConsoleLoggerFormat. + + + Name of the log message formatter to use. Defaults to 'Simple'. + The description provided for the FormatterName parameter on ConsoleLoggerOptions. + + + Formatter options for the built-in console log formatter. + The description provider for the FormatterOptions parameter on ConsoleLoggerOptions. + + + A mapping of logger categories to log levels describing the threshold level at which messages are logged for each category; applies solely to ConsoleLoggerOptions. + The description provided for the LogLevel parameter on ConsoleLoggerOptions. + + + The minimum level of messages that are written to Console.Error. + The description provided for the LogToStandardErrorThreshold parameter on ConsoleLoggerOptions. + List of allowed CORS origins, separated by semicolons. The description provided for the AllowedOrigins parameter on CorsConfiguration. @@ -237,6 +277,38 @@ The directory path to which the stream data will initially be written, if specified; the file will then be moved/renamed to the directory specified in DirectoryPath. The description provided for the IntermediateDirectoryPath parameter on FileSystemEgressProviderOptions. + + Gets or sets JsonWriterOptions. + The description provided for the JsonWriterOptions parameter on JsonConsoleFormatterOptions. + + + Gets or sets whether logging scopes are being captured. Defaults to true. + The description provider for the CaptureScopes parameter on LoggingOptions. + + + Logging options for the Console provider. + The description provided for the Console parameter on LoggingOptions. + + + Logging options for the Debug provider. + The description provided for the Debug parameter on LoggingOptions. + + + Logging options for the EventLog provider. + The description provided for the EventLog parameter on LoggingOptions + + + Logging options for the EventSource provider. + The description provided for the EventSource parameter on LoggingOptions + + + A mapping of logger categories to log levels describing the threshold level at which messages are logged for each category; applies to no specific provider. + The description provided for the LogLevel parameter on LoggingOptions. + + + A mapping of logger categories to log levels describing the threshold level at which messages are logged for each category; applies to the specified provider. + The description provided for the LogLevel parameter on LogLevelOptions. + Name of custom metrics counters. The description provided for the CounterNames parameter on MetricProvider. @@ -305,8 +377,23 @@ Performs a case-insensitive string comparison. The description provided for enum ProcessFilterType's Exact value. + + Determines when to use color when logging messages. + The description provided for the ColorBehavior parameter on SimpleConsoleFormatterOptions. + + + When false, the entire message gets logged in a single line. + The description provided for the SingleLine parameter on SimpleConsoleFormatterOptions. + The location for temporary dump files. Defaults to the temp folder. The description provided for the DumpTempFolder parameter on StorageOptions. + + The {0} field or the {1} field is required. + Gets the format string for rejecting validation due to 2 missing fields where at least one is required. +2 Format Parameters: +0. fieldNameOne: The name of the first field that is missing +1. fieldNameTwo: The name of the second field that is missing + \ No newline at end of file diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/ProcessFilterOptions.cs b/src/Microsoft.Diagnostics.Monitoring.Options/ProcessFilterOptions.cs similarity index 90% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/ProcessFilterOptions.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/ProcessFilterOptions.cs index 932a45fc1f6..ec95398e6ce 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/ProcessFilterOptions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/ProcessFilterOptions.cs @@ -5,17 +5,9 @@ using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; -using System.Text.Json.Serialization; -#if UNITTEST -using Microsoft.Diagnostics.Monitoring.WebApi; - -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { - [JsonConverter(typeof(JsonStringEnumConverter))] public enum ProcessFilterKey { [Display( @@ -32,7 +24,6 @@ public enum ProcessFilterKey CommandLine, } - [JsonConverter(typeof(JsonStringEnumConverter))] public enum ProcessFilterType { [Display( diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/StorageOptions.cs b/src/Microsoft.Diagnostics.Monitoring.Options/StorageOptions.cs similarity index 81% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/StorageOptions.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/StorageOptions.cs index 93c4afec3a2..99fbf0478d5 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/StorageOptions.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/StorageOptions.cs @@ -4,13 +4,7 @@ using System.ComponentModel.DataAnnotations; -#if UNITTEST -using Microsoft.Diagnostics.Monitoring.WebApi; - -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Monitoring.WebApi -#endif { internal class StorageOptions { diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/StorageOptionsDefaults.cs b/src/Microsoft.Diagnostics.Monitoring.Options/StorageOptionsDefaults.cs similarity index 81% rename from src/Microsoft.Diagnostics.Monitoring.WebApi/StorageOptionsDefaults.cs rename to src/Microsoft.Diagnostics.Monitoring.Options/StorageOptionsDefaults.cs index 12464611e77..d154cb8bafa 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/StorageOptionsDefaults.cs +++ b/src/Microsoft.Diagnostics.Monitoring.Options/StorageOptionsDefaults.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Threading.Tasks; namespace Microsoft.Diagnostics.Monitoring.WebApi { diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/Microsoft.Diagnostics.Monitoring.WebApi.csproj b/src/Microsoft.Diagnostics.Monitoring.WebApi/Microsoft.Diagnostics.Monitoring.WebApi.csproj index 843a02a6f6a..d370f21f973 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/Microsoft.Diagnostics.Monitoring.WebApi.csproj +++ b/src/Microsoft.Diagnostics.Monitoring.WebApi/Microsoft.Diagnostics.Monitoring.WebApi.csproj @@ -46,21 +46,15 @@ - - True - True - OptionsDisplayStrings.resx - + + + + True True Strings.resx - - PublicResXFileCodeGenerator - OptionsDisplayStrings.Designer.cs - Microsoft.Diagnostics.Monitoring.WebApi - ResXFileCodeGenerator Strings.Designer.cs diff --git a/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/DotnetMonitorInfo.cs b/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/DotnetMonitorInfo.cs index 17b78359381..cb881a252cb 100644 --- a/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/DotnetMonitorInfo.cs +++ b/src/Microsoft.Diagnostics.Monitoring.WebApi/Models/DotnetMonitorInfo.cs @@ -5,7 +5,7 @@ using System.Text.Json.Serialization; #if UNITTEST -using Microsoft.Diagnostics.Monitoring.TestCommon.Options; +using Microsoft.Diagnostics.Monitoring.WebApi; namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.Models #else diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests.csproj b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests.csproj index dbf0280b427..bcf636e1fa1 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests.csproj +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.UnitTests.csproj @@ -1,6 +1,6 @@ - net50 + net5.0 Library diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj index bb497d5b441..d40e219e50f 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Microsoft.Diagnostics.Monitoring.ConfigurationSchema.csproj @@ -1,16 +1,27 @@  - - Exe - net50 - + + Exe + net5.0 + - - - + + + + + + + + - - - + + + + + + + + + diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleFormatterOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleFormatterOptions.cs new file mode 100644 index 00000000000..2c8d329b936 --- /dev/null +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleFormatterOptions.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Diagnostics.Monitoring.WebApi; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel; + +namespace Microsoft.Diagnostics.Monitoring.Options +{ + internal sealed class ConsoleFormatterOptions + { + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_IncludeScopes))] + public bool IncludeScopes { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_TimestampFormat))] + [DefaultValue(null)] + public string TimestampFormat { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_UseUtcTimestamp))] + [DefaultValue(false)] + public bool UseUtcTimestamp { get; set; } + } +} diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerFormat.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerFormat.cs new file mode 100644 index 00000000000..3782d2543a7 --- /dev/null +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerFormat.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Microsoft.Diagnostics.Monitoring.Options +{ + internal enum ConsoleLoggerFormat + { + Json, + Simple, + Systemd + } +} diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerOptions.cs new file mode 100644 index 00000000000..da961a7c4d0 --- /dev/null +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/ConsoleLoggerOptions.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Diagnostics.Monitoring.WebApi; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel; +using Microsoft.Extensions.Logging; +using System.Collections.Generic; + +namespace Microsoft.Diagnostics.Monitoring.Options +{ + internal sealed class ConsoleLoggerOptions + { + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleLoggerOptions_FormatterName))] + [DefaultValue(ConsoleLoggerFormat.Simple)] + public ConsoleLoggerFormat FormatterName { get; set; } = ConsoleLoggerFormat.Simple; + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleLoggerOptions_LogToStandardErrorThreshold))] + public LogLevel LogToStandardErrorThreshold { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleLoggerOptions_FormatterOptions))] + public object FormatterOptions { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleLoggerOptions_LogLevel))] + public IDictionary LogLevel { get; set; } + } +} diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/JsonConsoleFormatterOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/JsonConsoleFormatterOptions.cs new file mode 100644 index 00000000000..4cd87c92008 --- /dev/null +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/JsonConsoleFormatterOptions.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Diagnostics.Monitoring.WebApi; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Text.Json; + +namespace Microsoft.Diagnostics.Monitoring.Options +{ + internal sealed class JsonConsoleFormatterOptions + { + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_JsonConsoleFormatterOptions_WriterOptions))] + public JsonWriterOptions JsonWriterOptions { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_IncludeScopes))] + public bool IncludeScopes { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_TimestampFormat))] + [DefaultValue(null)] + public string TimestampFormat { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_UseUtcTimestamp))] + [DefaultValue(false)] + public bool UseUtcTimestamp { get; set; } + } +} diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LogLevelOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LogLevelOptions.cs new file mode 100644 index 00000000000..b1524e62ff1 --- /dev/null +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LogLevelOptions.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Diagnostics.Monitoring.WebApi; +using Microsoft.Extensions.Logging; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Microsoft.Diagnostics.Monitoring.Options +{ + internal sealed class LogLevelOptions + { + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LogLevelOptions_LogLevel))] + public IDictionary LogLevel { get; set; } + } +} diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LoggingOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LoggingOptions.cs new file mode 100644 index 00000000000..4289447a7f7 --- /dev/null +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/LoggingOptions.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Diagnostics.Monitoring.WebApi; +using Microsoft.Extensions.Logging; +using System.Collections.Generic; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace Microsoft.Diagnostics.Monitoring.Options +{ + internal sealed class LoggingOptions + { + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_LogLevel))] + public IDictionary LogLevel { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_Console))] + public ConsoleLoggerOptions Console { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_EventLog))] + public LogLevelOptions EventLog { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_Debug))] + public LogLevelOptions Debug { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_EventSource))] + public LogLevelOptions EventSource { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_LoggingOptions_CaptureScopes))] + [DefaultValue(true)] + public bool CaptureScopes { get; set; } + } +} diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/RootOptions.Logging.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/RootOptions.Logging.cs new file mode 100644 index 00000000000..2cd30f41b84 --- /dev/null +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/RootOptions.Logging.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Diagnostics.Monitoring.Options; + +namespace Microsoft.Diagnostics.Tools.Monitor +{ + partial class RootOptions + { + public LoggingOptions Logging { get; set; } + } +} diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/SimpleConsoleFormatterOptions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/SimpleConsoleFormatterOptions.cs new file mode 100644 index 00000000000..582bbf101c5 --- /dev/null +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Options/SimpleConsoleFormatterOptions.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Diagnostics.Monitoring.WebApi; +using Microsoft.Extensions.Logging.Console; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; + +namespace Microsoft.Diagnostics.Monitoring.Options +{ + internal sealed class SimpleConsoleFormatterOptions + { +#if NET5_0_OR_GREATER + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_SimpleConsoleFormatterOptions_ColorBehavior))] + [JsonConverter(typeof(JsonStringEnumConverter))] + public LoggerColorBehavior ColorBehavior { get; set; } +#endif + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_SimpleConsoleFormatterOptions_SingleLine))] + public bool SingleLine { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_IncludeScopes))] + public bool IncludeScopes { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_TimestampFormat))] + [DefaultValue(null)] + public string TimestampFormat { get; set; } + + [Display( + ResourceType = typeof(OptionsDisplayStrings), + Description = nameof(OptionsDisplayStrings.DisplayAttributeDescription_ConsoleFormatterOptions_UseUtcTimestamp))] + [DefaultValue(false)] + public bool UseUtcTimestamp { get; set; } + } +} diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Program.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Program.cs index c2caa8abb2a..51f21dd5b2c 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Program.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/Program.cs @@ -1,6 +1,9 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; using System.IO; -using System.Text; namespace Microsoft.Diagnostics.Monitoring.ConfigurationSchema { diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/SchemaGenerator.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/SchemaGenerator.cs index 844d3cc4563..387654a6e15 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/SchemaGenerator.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.ConfigurationSchema/SchemaGenerator.cs @@ -1,4 +1,11 @@ -using Microsoft.Diagnostics.Monitoring.TestCommon.Options; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Diagnostics.Monitoring.Options; +using Microsoft.Diagnostics.Tools.Monitor; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using NJsonSchema; using NJsonSchema.Generation; using System; @@ -11,10 +18,23 @@ internal sealed class SchemaGenerator public string GenerateSchema() { var settings = new JsonSchemaGeneratorSettings(); + + settings.SerializerSettings = new JsonSerializerSettings(); + settings.SerializerSettings.Converters.Add(new StringEnumConverter()); + JsonSchema schema = JsonSchema.FromType(settings); schema.Id = @"https://www.github.com/dotnet/dotnet-monitor"; schema.Title = "DotnetMonitorConfiguration"; + JsonSchema jsonConsoleFormatterOptions = JsonSchema.FromType(); + schema.Definitions.Add(nameof(JsonConsoleFormatterOptions), jsonConsoleFormatterOptions); + + JsonSchema simpleConsoleFormatterOptions = JsonSchema.FromType(); + schema.Definitions.Add(nameof(SimpleConsoleFormatterOptions), simpleConsoleFormatterOptions); + + JsonSchema systemdConsoleFormatterOptions = JsonSchema.FromType(); + schema.Definitions.Add(nameof(ConsoleFormatterOptions), systemdConsoleFormatterOptions); + //Allow other properties in the schema. schema.AdditionalPropertiesSchema = JsonSchema.CreateAnySchema(); @@ -22,18 +42,79 @@ public string GenerateSchema() schema.Definitions[nameof(EgressOptions)].Properties[nameof(EgressOptions.AzureBlobStorage)].Default = JsonSchema.CreateAnySchema(); schema.Definitions[nameof(EgressOptions)].Properties[nameof(EgressOptions.FileSystem)].Default = JsonSchema.CreateAnySchema(); schema.Definitions[nameof(EgressOptions)].Properties[nameof(EgressOptions.Properties)].Default = JsonSchema.CreateAnySchema(); + schema.Definitions[nameof(LoggingOptions)].Properties[nameof(LoggingOptions.LogLevel)].Default = JsonSchema.CreateAnySchema(); + schema.Definitions[nameof(LoggingOptions)].Properties[nameof(LoggingOptions.Console)].Default = JsonSchema.CreateAnySchema(); + schema.Definitions[nameof(LoggingOptions)].Properties[nameof(LoggingOptions.EventLog)].Default = JsonSchema.CreateAnySchema(); + schema.Definitions[nameof(LoggingOptions)].Properties[nameof(LoggingOptions.Debug)].Default = JsonSchema.CreateAnySchema(); + schema.Definitions[nameof(LoggingOptions)].Properties[nameof(LoggingOptions.EventSource)].Default = JsonSchema.CreateAnySchema(); + schema.Definitions[nameof(LogLevelOptions)].Properties[nameof(LogLevelOptions.LogLevel)].Default = JsonSchema.CreateAnySchema(); + schema.Definitions[nameof(ConsoleLoggerOptions)].Properties[nameof(ConsoleLoggerOptions.FormatterOptions)].Default = JsonSchema.CreateAnySchema(); + schema.Definitions[nameof(ConsoleLoggerOptions)].Properties[nameof(ConsoleLoggerOptions.LogLevel)].Default = JsonSchema.CreateAnySchema(); - //Make the default for each property and empty object. + //Make the default for each property an empty object. foreach (KeyValuePair kvp in schema.Properties) { kvp.Value.Default = JsonSchema.CreateAnySchema(); } + JsonSchema jsonConsoleLoggerOptionsSchema = GenerateConsoleLoggerOptionsSchema(jsonConsoleFormatterOptions, ConsoleLoggerFormat.Json); + JsonSchema simpleConsoleLoggerOptionsSchema = GenerateConsoleLoggerOptionsSchema(simpleConsoleFormatterOptions, ConsoleLoggerFormat.Simple); + JsonSchema systemdConsoleLoggerOptionsSchema = GenerateConsoleLoggerOptionsSchema(systemdConsoleFormatterOptions, ConsoleLoggerFormat.Systemd); + JsonSchema defaultConsoleLoggerOptionsSchema = GenerateDefaultConsoleLoggerOptionsSchema(simpleConsoleFormatterOptions); + + schema.Definitions[nameof(ConsoleLoggerOptions)].OneOf.Add(jsonConsoleLoggerOptionsSchema); + schema.Definitions[nameof(ConsoleLoggerOptions)].OneOf.Add(simpleConsoleLoggerOptionsSchema); + schema.Definitions[nameof(ConsoleLoggerOptions)].OneOf.Add(systemdConsoleLoggerOptionsSchema); + schema.Definitions[nameof(ConsoleLoggerOptions)].OneOf.Add(defaultConsoleLoggerOptionsSchema); + string schemaPayload = schema.ToJson(); //Normalize newlines embedded into json schemaPayload = schemaPayload.Replace(@"\r\n", @"\n", StringComparison.Ordinal); return schemaPayload; } + + public static JsonSchema GenerateConsoleLoggerOptionsSchema(JsonSchema consoleFormatterOptions, ConsoleLoggerFormat consoleLoggerFormat) + { + JsonSchema consoleLoggerOptionsSchema = new JsonSchema(); + + JsonSchemaProperty formatterNameProperty = new JsonSchemaProperty(); + JsonSchemaProperty formatterOptionsProperty = new JsonSchemaProperty(); + + JsonSchema formatterOptionsSchema = new JsonSchema(); + formatterOptionsSchema.Reference = consoleFormatterOptions; + + formatterOptionsProperty.Reference = formatterOptionsSchema; + + formatterNameProperty.ExtensionData = new Dictionary(); + formatterNameProperty.ExtensionData.Add("const", consoleLoggerFormat.ToString()); + + consoleLoggerOptionsSchema.Properties.Add(nameof(ConsoleLoggerOptions.FormatterName), formatterNameProperty); + consoleLoggerOptionsSchema.Properties.Add(nameof(ConsoleLoggerOptions.FormatterOptions), formatterOptionsProperty); + consoleLoggerOptionsSchema.RequiredProperties.Add(nameof(ConsoleLoggerOptions.FormatterName)); + + return consoleLoggerOptionsSchema; + } + + public static JsonSchema GenerateDefaultConsoleLoggerOptionsSchema(JsonSchema consoleFormatterOptions) + { + JsonSchema consoleLoggerOptionsSchema = new JsonSchema(); + + JsonSchemaProperty formatterNameProperty = new JsonSchemaProperty(); + JsonSchemaProperty formatterOptionsProperty = new JsonSchemaProperty(); + + JsonSchema formatterOptionsSchema = new JsonSchema(); + formatterOptionsSchema.Reference = consoleFormatterOptions; + + formatterOptionsProperty.Reference = formatterOptionsSchema; + + formatterNameProperty.Type = JsonObjectType.Null; + formatterNameProperty.Default = "Simple"; + + consoleLoggerOptionsSchema.Properties.Add(nameof(ConsoleLoggerOptions.FormatterName), formatterNameProperty); + consoleLoggerOptionsSchema.Properties.Add(nameof(ConsoleLoggerOptions.FormatterOptions), formatterOptionsProperty); + + return consoleLoggerOptionsSchema; + } } -} +} \ No newline at end of file diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/DiagnosticPortHelper.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/DiagnosticPortHelper.cs index 46333661f54..f23482697fb 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/DiagnosticPortHelper.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/DiagnosticPortHelper.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Monitoring.TestCommon.Options; +using Microsoft.Diagnostics.Monitoring.WebApi; using System; using System.IO; using System.Runtime.InteropServices; diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Microsoft.Diagnostics.Monitoring.TestCommon.csproj b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Microsoft.Diagnostics.Monitoring.TestCommon.csproj index 2f51b2ad737..de52c842696 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Microsoft.Diagnostics.Monitoring.TestCommon.csproj +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Microsoft.Diagnostics.Monitoring.TestCommon.csproj @@ -5,16 +5,16 @@ $(DefineConstants);UNITTEST - - - - + + + + \ No newline at end of file diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Runners/AppRunner.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Runners/AppRunner.cs index 2b08e3b9ef6..49dcd2a8c14 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Runners/AppRunner.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.TestCommon/Runners/AppRunner.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.Diagnostics.Monitoring.TestCommon.Options; +using Microsoft.Diagnostics.Monitoring.WebApi; using System; using System.Collections.Generic; using System.IO; diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/AuthenticationTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/AuthenticationTests.cs index 014b616402b..78270a660a7 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/AuthenticationTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/AuthenticationTests.cs @@ -17,6 +17,7 @@ using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Microsoft.Diagnostics.Tools.Monitor; namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests { diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/DumpTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/DumpTests.cs index 1e7c741a243..f8c8d1c504d 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/DumpTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/DumpTests.cs @@ -22,6 +22,7 @@ using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Microsoft.Diagnostics.Monitoring.WebApi; namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests { diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/EgressTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/EgressTests.cs index cb5ee9c3414..ad12a137b57 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/EgressTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/EgressTests.cs @@ -11,6 +11,7 @@ using Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.Models; using Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.Runners; using Microsoft.Diagnostics.Monitoring.WebApi; +using Microsoft.Diagnostics.Tools.Monitor; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using System; @@ -22,7 +23,6 @@ using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; -using DiagnosticPortConnectionMode = Microsoft.Diagnostics.Monitoring.TestCommon.Options.DiagnosticPortConnectionMode; namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests { diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/HttpApi/ApiClient.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/HttpApi/ApiClient.cs index dedfddaf3e5..b25674845f0 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/HttpApi/ApiClient.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/HttpApi/ApiClient.cs @@ -26,6 +26,11 @@ namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.HttpApi { internal sealed class ApiClient { + private static readonly JsonSerializerOptions DefaultJsonDeserializeOptions + = CreateJsonDeserializeOptions(); + private static readonly JsonSerializerOptions DefaultJsonSerializeOptions + = CreateJsonSerializeOptions(); + private readonly HttpClient _httpClient; private readonly ITestOutputHelper _outputHelper; @@ -252,9 +257,7 @@ public Task CaptureLogsAsync(int pid, TimeSpan duration, L private Task CaptureLogsAsync(string processQuery, TimeSpan duration, LogsConfiguration configuration, LogFormat logFormat, CancellationToken token) { - JsonSerializerOptions options = new(); - options.Converters.Add(new JsonStringEnumConverter()); - string json = JsonSerializer.Serialize(configuration, options); + string json = JsonSerializer.Serialize(configuration, DefaultJsonSerializeOptions); return CaptureLogsAsync( HttpMethod.Post, @@ -426,7 +429,7 @@ public async Task CancelEgressOperation(Uri operation, Cancellat private static async Task ReadContentAsync(HttpResponseMessage responseMessage) { using Stream contentStream = await responseMessage.Content.ReadAsStreamAsync().ConfigureAwait(false); - return await JsonSerializer.DeserializeAsync(contentStream).ConfigureAwait(false); + return await JsonSerializer.DeserializeAsync(contentStream, DefaultJsonDeserializeOptions).ConfigureAwait(false); } private static Task> ReadContentEnumerableAsync(HttpResponseMessage responseMessage) @@ -548,5 +551,19 @@ private static string GetProcessQuery(int? pid = null, Guid? uid = null, string throw new ArgumentException("One of PID, UID, or Name must be specified."); } + + private static JsonSerializerOptions CreateJsonDeserializeOptions() + { + JsonSerializerOptions options = new(); + options.Converters.Add(new JsonStringEnumConverter()); + return options; + } + + private static JsonSerializerOptions CreateJsonSerializeOptions() + { + JsonSerializerOptions options = new(); + options.Converters.Add(new JsonStringEnumConverter()); + return options; + } } } \ No newline at end of file diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/InfoTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/InfoTests.cs index 2884e618c87..b0bf10348fa 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/InfoTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/InfoTests.cs @@ -15,6 +15,7 @@ using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Microsoft.Diagnostics.Monitoring.WebApi; namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests { diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/LogsTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/LogsTests.cs index f4f3e02b3b0..4e4f3cece47 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/LogsTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/LogsTests.cs @@ -23,7 +23,6 @@ using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; -using DiagnosticPortConnectionMode = Microsoft.Diagnostics.Monitoring.TestCommon.Options.DiagnosticPortConnectionMode; namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests { diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/MetricsTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/MetricsTests.cs index 5db0117a0a1..7401cbcf364 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/MetricsTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/MetricsTests.cs @@ -6,7 +6,6 @@ using Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.Fixtures; using Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.HttpApi; using Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.Runners; -using Microsoft.Diagnostics.Monitoring.TestCommon.Options; using Microsoft.Diagnostics.Monitoring.TestCommon.Runners; using Microsoft.Extensions.DependencyInjection; using System; @@ -16,6 +15,8 @@ using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Microsoft.Diagnostics.Tools.Monitor; +using Microsoft.Diagnostics.Monitoring.WebApi; namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests { diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.csproj b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.csproj index ddee7a4c05c..c3bd3b84d77 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.csproj +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.csproj @@ -10,20 +10,12 @@ - - - - - - - - @@ -40,10 +32,6 @@ - - - - @@ -53,6 +41,7 @@ + false @@ -64,4 +53,9 @@ + + + + + diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.cs index a334c5217a5..8d746c2b7d4 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Options/OptionsExtensions.cs @@ -2,6 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.Diagnostics.Tools.Monitor; +using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options; +using Microsoft.Diagnostics.Tools.Monitor.Egress.FileSystem; using Microsoft.Extensions.Configuration; using System; using System.Collections; @@ -12,12 +15,6 @@ using System.Security.Cryptography; using System.Text; -#if !UNITTEST -using Microsoft.Diagnostics.Tools.Monitor; -using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options; -using Microsoft.Diagnostics.Tools.Monitor.Egress.FileSystem; -#endif - namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options { internal static class OptionsExtensions diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/ProcessTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/ProcessTests.cs index fd4194aa01c..c3bf93a7e4b 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/ProcessTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/ProcessTests.cs @@ -20,6 +20,7 @@ using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; +using Microsoft.Diagnostics.Monitoring.WebApi; namespace Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests { diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Runners/MonitorRunner.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Runners/MonitorRunner.cs index 07132eb00b9..634e3bd4164 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Runners/MonitorRunner.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Runners/MonitorRunner.cs @@ -5,6 +5,8 @@ using Microsoft.Diagnostics.Monitoring.TestCommon; using Microsoft.Diagnostics.Monitoring.TestCommon.Options; using Microsoft.Diagnostics.Monitoring.TestCommon.Runners; +using Microsoft.Diagnostics.Monitoring.WebApi; +using Microsoft.Diagnostics.Tools.Monitor; using System; using System.Collections.Generic; using System.IO; diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Runners/ScenarioRunner.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Runners/ScenarioRunner.cs index 49ab423e4b8..81cbed82f2e 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Runners/ScenarioRunner.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests/Runners/ScenarioRunner.cs @@ -6,6 +6,7 @@ using Microsoft.Diagnostics.Monitoring.TestCommon.Options; using Microsoft.Diagnostics.Monitoring.TestCommon.Runners; using Microsoft.Diagnostics.Monitoring.Tool.FunctionalTests.HttpApi; +using Microsoft.Diagnostics.Monitoring.WebApi; using System; using System.Net.Http; using System.Reflection; diff --git a/src/Tests/Microsoft.Diagnostics.Monitoring.WebApi.UnitTests/EndpointInfoSourceTests.cs b/src/Tests/Microsoft.Diagnostics.Monitoring.WebApi.UnitTests/EndpointInfoSourceTests.cs index 1ea9238e953..ea82bc88d65 100644 --- a/src/Tests/Microsoft.Diagnostics.Monitoring.WebApi.UnitTests/EndpointInfoSourceTests.cs +++ b/src/Tests/Microsoft.Diagnostics.Monitoring.WebApi.UnitTests/EndpointInfoSourceTests.cs @@ -201,7 +201,7 @@ await runners.ExecuteAsync(async () => private TestServerEndpointInfoSource CreateServerSource(out string transportName) { - DiagnosticPortHelper.Generate(TestCommon.Options.DiagnosticPortConnectionMode.Listen, out _, out transportName); + DiagnosticPortHelper.Generate(DiagnosticPortConnectionMode.Listen, out _, out transportName); _outputHelper.WriteLine("Starting server endpoint info source at '" + transportName + "'."); return new TestServerEndpointInfoSource(transportName, _outputHelper); } @@ -209,7 +209,7 @@ private TestServerEndpointInfoSource CreateServerSource(out string transportName private AppRunner CreateAppRunner(string transportName = null, int appId = 1) { AppRunner appRunner = new(_outputHelper, Assembly.GetExecutingAssembly(), appId); - appRunner.ConnectionMode = TestCommon.Options.DiagnosticPortConnectionMode.Connect; + appRunner.ConnectionMode = DiagnosticPortConnectionMode.Connect; appRunner.DiagnosticPortPath = transportName; appRunner.ScenarioName = TestAppScenarios.AsyncWait.Name; return appRunner; diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ActionOptionsConstants.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ActionOptionsConstants.cs index e025ff92c13..e28e19de47c 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ActionOptionsConstants.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ActionOptionsConstants.cs @@ -4,11 +4,7 @@ using System.Globalization; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Actions -#endif { // Constants for action options allowing reuse among multiple actions and for tests to verify ranges. internal static class ActionOptionsConstants diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectDumpOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectDumpOptions.cs index a544e50873e..65a778bee35 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectDumpOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectDumpOptions.cs @@ -6,11 +6,7 @@ using System.ComponentModel.DataAnnotations; using System.Diagnostics; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Actions -#endif { /// /// Options for the CollectDump action. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectGCDumpOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectGCDumpOptions.cs index e0ed12a8bff..143f19f2a6c 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectGCDumpOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectGCDumpOptions.cs @@ -5,11 +5,7 @@ using System.ComponentModel.DataAnnotations; using System.Diagnostics; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Actions -#endif { /// /// Options for the CollectGCDump action. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLogsOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLogsOptions.cs index a312fa16f00..e2744d6c060 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLogsOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectLogsOptions.cs @@ -8,11 +8,7 @@ using System.ComponentModel.DataAnnotations; using System.Diagnostics; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Actions -#endif { /// /// Options for the CollectLogs action. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectTraceOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectTraceOptions.cs index 31f0a6649bb..2ef87d59732 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectTraceOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/CollectTraceOptions.cs @@ -8,11 +8,7 @@ using System.ComponentModel.DataAnnotations; using System.Diagnostics; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Actions -#endif { /// /// Options for the CollectTrace action. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ExecuteOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ExecuteOptions.cs index f3bbd4c9615..1d993af9907 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ExecuteOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Actions/ExecuteOptions.cs @@ -5,11 +5,7 @@ using System.ComponentModel.DataAnnotations; using System.Diagnostics; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Actions -#endif { /// /// Options for the Execute action. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionOptions.cs index 586e71743a4..3dffc81e08c 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleActionOptions.cs @@ -6,11 +6,7 @@ using System.ComponentModel.DataAnnotations; using System.Diagnostics; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options -#endif { /// /// Options for describing the type of action to execute and the settings to pass to that action. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleLimitsOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleLimitsOptions.cs index f4c32ee41eb..b6eebda4e7b 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleLimitsOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleLimitsOptions.cs @@ -6,11 +6,7 @@ using System; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options -#endif { /// /// Options for limiting the execution of a collection rule. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs index 1815e03d0a6..868289f6727 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptions.cs @@ -6,11 +6,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options -#endif { /// /// Options for describing an entire collection rule. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptionsConstants.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptionsConstants.cs index 4ad48e6ca44..ffcd10abc62 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptionsConstants.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleOptionsConstants.cs @@ -2,11 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options -#endif { internal static class CollectionRuleOptionsConstants { diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleTriggerOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleTriggerOptions.cs index c820bd87174..8dfda83ee6d 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleTriggerOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/CollectionRuleTriggerOptions.cs @@ -6,11 +6,7 @@ using System.ComponentModel.DataAnnotations; using System.Diagnostics; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options -#endif { /// /// Options for describing the type of trigger and the settings to pass to that trigger. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestCountOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestCountOptions.cs index c5d8d0d7538..b45b0122054 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestCountOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestCountOptions.cs @@ -5,11 +5,7 @@ using System; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Triggers -#endif { /// /// Options for the AspNetRequestCount trigger. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestDurationOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestDurationOptions.cs index fd4c81d824b..c80fda9caaa 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestDurationOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetRequestDurationOptions.cs @@ -5,11 +5,7 @@ using System; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Triggers -#endif { /// /// Options for the AspNetRequestDuration trigger. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs index f67868476fb..7eb10e68f69 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/AspNetResponseStatusOptions.cs @@ -5,11 +5,7 @@ using System; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Triggers -#endif { /// /// Options for the AspNetResponseStatus trigger. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterOptions.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterOptions.cs index 375f54be58d..daed120b240 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterOptions.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/EventCounterOptions.cs @@ -5,11 +5,7 @@ using System; using System.ComponentModel.DataAnnotations; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Triggers -#endif { /// /// Options for the EventCounter trigger. diff --git a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/TriggerOptionsConstants.cs b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/TriggerOptionsConstants.cs index b0a38e02bf3..dbf0a270cb3 100644 --- a/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/TriggerOptionsConstants.cs +++ b/src/Tools/dotnet-monitor/CollectionRules/Options/Triggers/TriggerOptionsConstants.cs @@ -4,11 +4,7 @@ using System.Globalization; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options.Triggers -#endif { // Constants for trigger options allowing reuse among multiple trigger and for tests to verify ranges. internal static class TriggerOptionsConstants diff --git a/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProvider.AutoFlushStream.cs b/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProvider.AutoFlushStream.cs new file mode 100644 index 00000000000..87905295886 --- /dev/null +++ b/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProvider.AutoFlushStream.cs @@ -0,0 +1,107 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Microsoft.Diagnostics.Tools.Monitor.Egress.AzureBlob +{ + partial class AzureBlobEgressProvider + { + /// + /// Automatically flushes the stream after a certain amount of bytes have been written. + /// + private sealed class AutoFlushStream : Stream + { + private readonly Stream _baseStream; + private readonly long _flushSize; + private long _written; + + public AutoFlushStream(Stream stream, long flushSize) + { + _flushSize = flushSize >= 0 ? flushSize : throw new ArgumentOutOfRangeException(nameof(flushSize)); + _baseStream = stream ?? throw new ArgumentNullException(nameof(stream)); + } + + public override bool CanRead => _baseStream.CanRead; + public override bool CanSeek => _baseStream.CanSeek; + public override bool CanWrite => _baseStream.CanWrite; + public override long Length => _baseStream.Length; + public override bool CanTimeout => _baseStream.CanTimeout; + public override int WriteTimeout { get => _baseStream.WriteTimeout; set => _baseStream.WriteTimeout = value; } + public override int ReadTimeout { get => _baseStream.ReadTimeout; set => _baseStream.ReadTimeout = value; } + public override long Position { get => _baseStream.Position; set => _baseStream.Position = value; } + public override int Read(byte[] buffer, int offset, int count) => _baseStream.Read(buffer, offset, count); + public override long Seek(long offset, SeekOrigin origin) => _baseStream.Seek(offset, origin); + public override void SetLength(long value) => _baseStream.SetLength(value); + public override void Close() => _baseStream.Close(); + public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) => + _baseStream.CopyToAsync(destination, bufferSize, cancellationToken); + public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => + _baseStream.ReadAsync(buffer, offset, count, cancellationToken); + public override int ReadByte() => _baseStream.ReadByte(); + + //CONSIDER These are not really used, but should still autoflush. + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => + _baseStream.BeginRead(buffer, offset, count, callback, state); + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) => + _baseStream.BeginWrite(buffer, offset, count, callback, state); + public override int EndRead(IAsyncResult asyncResult) => _baseStream.EndRead(asyncResult); + public override void EndWrite(IAsyncResult asyncResult) => _baseStream.EndWrite(asyncResult); + + public override void Write(byte[] buffer, int offset, int count) + { + _baseStream.Write(buffer, offset, count); + ProcessWrite(count); + } + + public override void WriteByte(byte value) + { + _baseStream.WriteByte(value); + ProcessWrite(1); + } + + public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) + { + await _baseStream.WriteAsync(buffer, offset, count, cancellationToken); + await ProcessWriteAsync(count, cancellationToken); + } + + public override void Flush() + { + _baseStream.Flush(); + _written = 0; + } + + public override async Task FlushAsync(CancellationToken cancellationToken) + { + await _baseStream.FlushAsync(cancellationToken); + _written = 0; + } + + private void ProcessWrite(int count) + { + _written += count; + if (_written >= _flushSize) + { + Flush(); + } + } + + private Task ProcessWriteAsync(int count, CancellationToken cancellationToken) + { + _written += count; + if (_written >= _flushSize) + { + return FlushAsync(cancellationToken); + } + return Task.CompletedTask; + } + } + } +} diff --git a/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProvider.cs b/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProvider.cs index 19df1b403ae..e0f1d203fcc 100644 --- a/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProvider.cs +++ b/src/Tools/dotnet-monitor/Egress/AzureBlob/AzureBlobEgressProvider.cs @@ -22,9 +22,11 @@ namespace Microsoft.Diagnostics.Tools.Monitor.Egress.AzureBlob /// /// Blobs created through this provider will overwrite existing blobs if they have the same blob name. /// - internal class AzureBlobEgressProvider : + internal partial class AzureBlobEgressProvider : EgressProvider { + private int BlobStorageBufferSize = 4 * 1024 * 1024; + public AzureBlobEgressProvider(ILogger logger) : base(logger) { @@ -75,12 +77,24 @@ public override async Task EgressAsync( BlockBlobClient blobClient = containerClient.GetBlockBlobClient(GetBlobName(options, artifactSettings)); // Write blob content - using (Stream blobStream = await blobClient.OpenWriteAsync(overwrite: true, cancellationToken: token)) + + var bloboptions = new BlockBlobOpenWriteOptions + { + BufferSize = BlobStorageBufferSize, + }; + using (Stream blobStream = await blobClient.OpenWriteAsync(overwrite: true, options: bloboptions, cancellationToken: token)) + using (AutoFlushStream flushStream = new AutoFlushStream(blobStream, BlobStorageBufferSize)) { + //Azure's stream from OpenWriteAsync will do the following + //1. Write the data to a local buffer + //2. Once that buffer is full, stage the data remotely (this data is not considered valid yet) + //3. After 4Gi of data has been staged, the data will be commited. This can be forced earlier by flushing + //the stream. + // Since we want the data to be readily available, we automatically flush (and therefore commit) every time we fill up the buffer. Logger?.EgressProviderInvokeStreamAction(EgressProviderTypes.AzureBlobStorage); - await action(blobStream, token); + await action(flushStream, token); - await blobStream.FlushAsync(token); + await flushStream.FlushAsync(token); } // Write blob headers diff --git a/src/Tools/dotnet-monitor/RootOptions.cs b/src/Tools/dotnet-monitor/RootOptions.cs index fdf2f00b696..bb2ca888bfc 100644 --- a/src/Tools/dotnet-monitor/RootOptions.cs +++ b/src/Tools/dotnet-monitor/RootOptions.cs @@ -2,19 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#if !UNITTEST using Microsoft.Diagnostics.Monitoring.WebApi; using Microsoft.Diagnostics.Tools.Monitor.CollectionRules.Options; -#endif using System.Collections.Generic; -#if UNITTEST -namespace Microsoft.Diagnostics.Monitoring.TestCommon.Options -#else namespace Microsoft.Diagnostics.Tools.Monitor -#endif { - internal sealed class RootOptions + internal partial class RootOptions { public ApiAuthenticationOptions ApiAuthentication { get; set; } diff --git a/src/Tools/dotnet-monitor/dotnet-monitor.csproj b/src/Tools/dotnet-monitor/dotnet-monitor.csproj index 9b063e2d0fe..5686254fd90 100644 --- a/src/Tools/dotnet-monitor/dotnet-monitor.csproj +++ b/src/Tools/dotnet-monitor/dotnet-monitor.csproj @@ -50,10 +50,12 @@ + +