Skip to content

[BUG] Unnecessary options Configure call in Azure.Monitor.OpenTelemetry.AspNetCore #38787

@amis92

Description

@amis92

Library name and version

Azure.Monitor.OpenTelemetry.AspNetCore 1.0.0-beta.6

Describe the bug

There's an unnecessary/nonsense object instantiation in the following code: builder.UseAzureMonitor(o => o = new AzureMonitorOptions()). The assignment has no impact on actual configured options instance, as it is a local lambda variable/parameter being "overwritten". It's a nonsense code in general.

return builder.UseAzureMonitor(o => o = new AzureMonitorOptions());

Expected behavior

A null lambda is passed, or an empty-bodied lambda is passed. Preferable a null lambda, because then it won't be registered in DI container and take up space in options-configuration-pipeline. However, the API contract is non-nullable and so it might be unwanted. Were it nullable, I'd happily open a PR, but in current situation a decision is necessary.

Actual behavior

An essentially no-op lambda is passed (which creates a throw-away object instance in the process), and then gets registered into Options-configuration pipeline, which makes no sense.

Reproduction Steps

It's a code nitpick, non-reproducible.

Environment

Not applicable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue is related to a non-management packageMonitor - DistroMonitor OpenTelemetry DistroService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions