Skip to content

Conversation

@jonathanpeppers
Copy link
Member

Context: https://github.com/jonathanpeppers/MauiAspireWithTelemetry/tree/peppers
Context: dotnet/maui#31058

We are in the process of adding Metrics to .NET MAUI to enable dotnet-counters such as:

> dotnet-counters monitor --dsrouter android --counters Microsoft.Maui
Press p to pause, r to resume, q to quit.
Status: Running

Name                                      Current Value
[Microsoft.Maui]
    maui.layout.arrange_count ({times})               6
    maui.layout.arrange_duration (ns)
        Percentile
        50                                      518,656
        95                                    2,367,488
        99                                    2,367,488
    maui.layout.measure_count ({times})              11
    maui.layout.measure_duration (ns)
        Percentile
        50                                      389,632
        95                                   28,475,392
        99                                   28,475,392

For this to work, you'd unfortunately need to build the app with:

dotnet build -c Release -p:EnableDiagnostics=true -p:MetricsSupport=true -p:EventSourceSupport=true

That's way too many properties to mess with!

So, we should make the defaults:

  • For Release mode, $(Optimize) is true.

  • Only if $(AndroidEnableProfiler) and $(EnableDiagnostics) are not true, then:

    • $(MetricsSupport) is false.

    • $(EventSourceSupport) is false.

I also refactored other properties that default to false in Release mode by checking the $(Optimize) property.

@jonathanpeppers
Copy link
Member Author

The one AppWithAndroidJavaSource test failure is being fixed in:

<DebuggerSupport Condition=" '$(DebuggerSupport)' == '' ">false</DebuggerSupport>
<HttpActivityPropagationSupport Condition=" '$(HttpActivityPropagationSupport)' == '' ">false</HttpActivityPropagationSupport>
<!-- Only set if *not* using $(EnableDiagnostics) -->
<MetricsSupport Condition=" '$(MetricsSupport)' == '' and '$(AndroidEnableProfiler)' != 'true' ">false</MetricsSupport>
Copy link
Member

@lateralusX lateralusX Aug 8, 2025

Choose a reason for hiding this comment

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

There is a use case just profiling or tracing the native runtime events that doesn't need the large set of diagnostic libraries on Release. With this change users needs to opt out of metric + event source if they enable AndroidEnableProfiler on Release builds. I guess that is fine, just want to point out the scenario and that we might need to document how to run under that configuration when we enable more libraries in Release builds by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

Context: https://github.com/jonathanpeppers/MauiAspireWithTelemetry/tree/peppers
Context: dotnet/maui#31058

We are in the process of adding `Metrics` to .NET MAUI to enable
`dotnet-counters` such as:

    > dotnet-counters monitor --dsrouter android --counters Microsoft.Maui
    Press p to pause, r to resume, q to quit.
    Status: Running

    Name                                      Current Value
    [Microsoft.Maui]
        maui.layout.arrange_count ({times})               6
        maui.layout.arrange_duration (ns)
            Percentile
            50                                      518,656
            95                                    2,367,488
            99                                    2,367,488
        maui.layout.measure_count ({times})              11
        maui.layout.measure_duration (ns)
            Percentile
            50                                      389,632
            95                                   28,475,392
            99                                   28,475,392

For this to work, you'd unfortunately need to build the app with:

    dotnet build -c Release -p:EnableDiagnostics=true -p:MetricsSupport=true -p:EventSourceSupport=true

That's way too many properties to mess with!

So, we should make the defaults:

* For `Release` mode, `$(Optimize)` is `true`.

* Only if `$(AndroidEnableProfiler)` and `$(EnableDiagnostics)` are
  not `true`, then:

  * `$(MetricsSupport)` is `false`.

  * `$(EventSourceSupport)` is `false`.

I also refactored other properties that default to `false` in Release
mode by checking the `$(Optimize)` property.
@jonathanpeppers jonathanpeppers force-pushed the dev/peppers/trimmer-Metrics branch from e529a1f to 9e6a3e2 Compare August 8, 2025 18:40
@jonathanpeppers
Copy link
Member Author

@jonathanpeppers jonathanpeppers enabled auto-merge (squash) August 8, 2025 20:41
@jonathanpeppers jonathanpeppers merged commit dc6b2cb into main Aug 8, 2025
59 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/peppers/trimmer-Metrics branch August 8, 2025 22:42
rolfbjarne added a commit to dotnet/macios that referenced this pull request Aug 11, 2025
…icsSupport'.

Context: dotnet/maui#31058
Context: dotnet/android#10388

We are in the process of adding `Metrics` to .NET MAUI to enable `dotnet-counters` such as:

    > dotnet-counters monitor --dsrouter ios --counters Microsoft.Maui
    Press p to pause, r to resume, q to quit.
    Status: Running

    Name                                      Current Value
    [Microsoft.Maui]
        maui.layout.arrange_count ({times})               6
        maui.layout.arrange_duration (ns)
            Percentile
            50                                      518,656
            95                                    2,367,488
            99                                    2,367,488
        maui.layout.measure_count ({times})              11
        maui.layout.measure_duration (ns)
            Percentile
            50                                      389,632
            95                                   28,475,392
            99                                   28,475,392

For this to work, you'd unfortunately need to build the app with:

    dotnet build -c Release -p:EnableDiagnostics=true -p:MetricsSupport=true -p:EventSourceSupport=true

That's way too many properties to mess with!

So, we should make the defaults:

* For `Release` mode, `$(Optimize)` is `true`.

* Only if `$(EnableDiagnostics)` is not `true`, then:

  * `$(MetricsSupport)` is `false`.

  * `$(EventSourceSupport)` is `false`.
@rolfbjarne
Copy link
Member

/cc @rolfbjarne I guess we will want some of the same defaults on iOS:

dotnet/macios@dff978e/dotnet/targets/Xamarin.Shared.Sdk.targets#L116

dotnet/macios#23543

rolfbjarne added a commit to dotnet/macios that referenced this pull request Aug 12, 2025
…icsSupport'. (#23543)

Context: dotnet/maui#31058
Context: dotnet/android#10388

We are in the process of adding `Metrics` to .NET MAUI to enable `dotnet-counters` such as:

    > dotnet-counters monitor --dsrouter ios --counters Microsoft.Maui
    Press p to pause, r to resume, q to quit.
    Status: Running

    Name                                      Current Value
    [Microsoft.Maui]
        maui.layout.arrange_count ({times})               6
        maui.layout.arrange_duration (ns)
            Percentile
            50                                      518,656
            95                                    2,367,488
            99                                    2,367,488
        maui.layout.measure_count ({times})              11
        maui.layout.measure_duration (ns)
            Percentile
            50                                      389,632
            95                                   28,475,392
            99                                   28,475,392

For this to work, you'd unfortunately need to build the app with:

    dotnet build -c Release -p:EnableDiagnostics=true -p:MetricsSupport=true -p:EventSourceSupport=true

That's way too many properties to mess with!

So, we should make the defaults:

* For `Release` mode, `$(Optimize)` is `true`.

* Only if `$(EnableDiagnostics)` is not `true`, then:

  * `$(MetricsSupport)` is `false`.

  * `$(EventSourceSupport)` is `false`.
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants