question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] It is not possible to specify Aggregations on using QueryResourceAsync on a MetricsQueryClient

See original GitHub issue

Library name and version

Azure.Monitor.Query

Describe the bug

It is not possible to specify Aggregations on using QueryResourceAsync on a MetricsQueryClient instance.

Expected behavior

The MetricsQueryOptions class does provide a setter for the property for Aggregations.

Actual behavior

The MetricsQueryOptions class does not provide a setter for the property for Aggregations.

Reproduction Steps

var response = await _metricsQueryClient.QueryResourceAsync(
    _logAnalyticsWorkspaceResourceId,
    new[] { MetricConstants.SomeKeyForAValue},
    new MetricsQueryOptions
    {
        MetricNamespace = DiagnosticsClient.MetricNamespace,
        TimeRange = new QueryTimeRange(queryTime),
        Granularity = _granularityForMetrics
        // the setter for Aggregations is missing here
    }).ConfigureAwait(false);

Environment

.NET SDK (reflecting any global.json): Version: 6.0.301 Commit: 43f9b18481

Runtime Environment: OS Name: Windows OS Version: 10.0.19044 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.301\

Host (useful for support): Version: 6.0.6 Commit: 7cca709db2

.NET SDKs installed: 3.1.420 [C:\Program Files\dotnet\sdk] 5.0.401 [C:\Program Files\dotnet\sdk] 5.0.408 [C:\Program Files\dotnet\sdk] 6.0.203 [C:\Program Files\dotnet\sdk] 6.0.300 [C:\Program Files\dotnet\sdk] 6.0.301 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
scottaddiecommented, Jun 24, 2022

@adymorz Thanks for getting back to me and for creating this issue. I’m glad you were able to figure this out.

1reaction
scottaddiecommented, Jun 23, 2022

@adymorz Is there something that prevents you from setting the property in the way I’ve illustrated above? See https://github.com/Azure/azure-sdk-for-net/issues/29334#issuecomment-1160851591. The technique is explained at Object initializers with collection read-only property initialization.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Setting an aggregation for a metrics query doesn't work
Describe the bug I'm building a small client application that gathers traffic data from some event hubs and I want to use AggregationType....
Read more >
Announcing the new Azure Monitor Query client libraries
Specifically, the snippets demonstrate querying the Ingress metric and including the Average and Maximum aggregations. Notice that unlike Logs ...
Read more >
Azure Monitor Query client library for .NET
You can query metrics on an Azure resource using the MetricsQueryClient.QueryResourceAsync method. For each requested metric, a set of ...
Read more >
Unlock petabyte-scale datasets in Azure with ... - YouTube
Christian Wade joins Scott Hanselman to show you how to unlock petabyte-scale datasets in Azure with a way that was not previously possible....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found