Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Instrumentation.AWSLambda] Remove AddAWSLambdaConfigurations with default parameter #943

Merged
merged 11 commits into from
Mar 13, 2023

Conversation

Kielek
Copy link
Contributor

@Kielek Kielek commented Feb 1, 2023

Propagate recommendations from https://github.com/open-telemetry/opentelemetry-dotnet/pull/3653/files#r970049254

Changes

Remove AddAWSLambdaConfigurations with default parameter

For significant contributions please make sure you have completed the following items:

  • Appropriate CHANGELOG.md updated for non-trivial changes
  • [ ] Design discussion issue #

@Kielek Kielek added the comp:instrumentation.awslambda Things related to OpenTelemetry.Instrumentation.AWSLambda label Feb 1, 2023
@Kielek Kielek requested a review from a team February 1, 2023 07:57
@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Merging #943 (858d37c) into main (7fda8d4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 858d37c differs from pull request most recent head 27f6230. Consider uploading reports for the commit 27f6230 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #943   +/-   ##
=======================================
  Coverage   70.18%   70.18%           
=======================================
  Files         210      210           
  Lines        7864     7865    +1     
=======================================
+ Hits         5519     5520    +1     
  Misses       2345     2345           
Impacted Files Coverage Δ
...ation.AWSLambda/TracerProviderBuilderExtensions.cs 100.00% <100.00%> (ø)

@Oberon00
Copy link
Member

Oberon00 commented Feb 8, 2023

What is the advantage of this change? It seems to make the code longer and less clear and is also API-breaking. I also don't see the relation to the linked comment, but probably I'm missing something?

@Kielek
Copy link
Contributor Author

Kielek commented Feb 10, 2023

@Oberon00, I have linked wrong comment, see https://github.com/open-telemetry/opentelemetry-dotnet/pull/3653/files#r969915942

If some user was binding to this reflectively and specifically looking at metadata for the optional parameter they would no longer find it and break but I don't think that is really worth worrying about. The benefit to this change is to keep consistency with everything else and allow for future safe expansion/overload additions without default parameter ambiguity issues.

In general it is binary-breaking change but does not require any source code changes.
As long as the package is in pre-GA phase it is safe to merge IMO.

Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

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

Can you maybe help me with some link to an explanation of this best practice of avoiding default parameters (assuming it is one)?

@@ -4,9 +4,13 @@

* Add HTTP server span attributes for API Gateway triggers
([#626](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/626))
* Removes `AddAWSLambdaConfigurations` method with default configure parameter.
Copy link
Member

Choose a reason for hiding this comment

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

This is confusing because from the user's perspective it is not removed but just replaced with another method. Probably we don't even need a changelog entry here, unless it's really ABI-breaking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In some strange cases it can be treated as ABI-breaking. https://stackoverflow.com/a/9916197
Most cases it is not.

@Kielek
Copy link
Contributor Author

Kielek commented Feb 14, 2023

Can you maybe help me with some link to an explanation of this best practice of avoiding default parameters (assuming it is one)?

I do not found anything beyond https://github.com/open-telemetry/opentelemetry-dotnet/pull/3653/files#r969915942.

For me, follow the rule from SDK repository is good enough argument to this change.

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Feb 22, 2023
@Kielek Kielek removed the Stale label Feb 27, 2023
Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

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

OK with me then, although I'm not entirely convinced, I don't want to block it either, because I do acknowledge that I might just be ignorant of the value of this change.

So the rule boils down to: "Never combine overloads and default arguments"? I.e. if I have an overloaded method, I must never add default arguments to any overload, and if I have default arguments I must never overload the method?

@utpilla
Copy link
Contributor

utpilla commented Mar 2, 2023

So the rule boils down to: "Never combine overloads and default arguments"? I.e. if I have an overloaded method, I must never add default arguments to any overload, and if I have default arguments I must never overload the method?

@Oberon00 Not having optional arguments in public methods makes it simpler to extend the methods to accept more arguments in future without worrying about making breaking changes. This doc talks about it in detail:

https://github.com/dotnet/roslyn/blob/main/docs/Adding%20Optional%20Parameters%20in%20Public%20API.md

We agreed that it's best to not have optional parameters in the public methods. This allows for a very easy way to change the method signature if required in future.

@utpilla utpilla merged commit d8ec6e0 into open-telemetry:main Mar 13, 2023
@Kielek Kielek deleted the awslambda-drop-default-parameter branch March 13, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.awslambda Things related to OpenTelemetry.Instrumentation.AWSLambda
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants