opentelemetry-collector icon indicating copy to clipboard operation
opentelemetry-collector copied to clipboard

[confighttp] newDefault for confighttp package structs

Open Sanket-0510 opened this issue 1 year ago • 9 comments

Description:
NewDefault methods to all the exported structs in confighttp package

Link to tracking Issue: closes #9655

Testing: Added test for the same.

Documentation: godoc

Sanket-0510 avatar Mar 02 '24 11:03 Sanket-0510

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.56%. Comparing base (31528ce) to head (89d1c0d). Report is 152 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9672   +/-   ##
=======================================
  Coverage   91.56%   91.56%           
=======================================
  Files         360      360           
  Lines       16698    16704    +6     
=======================================
+ Hits        15289    15295    +6     
  Misses       1073     1073           
  Partials      336      336           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Mar 02 '24 11:03 codecov[bot]

why are contrib-tests failing? : |

Sanket-0510 avatar Mar 02 '24 13:03 Sanket-0510

@astencel-sumo some contrib tests are failing in github actions, but I did ran all tests on local but nothing failed there, I also looked into the failing test it is expecting nil value for our map.

Sanket-0510 avatar Mar 11 '24 11:03 Sanket-0510

ClientConfig and ServerConfig depend on configtls. I think we should wait on this PR until the NewDefault functions exist for configtls.

I don't think that's the problem. The reason the contrib tests are failing is that I asked Sanket to make the NewDefaultClientConfig and NewDefaultServerConfig to initialize the Headers and ResponseHeaders maps to empty maps. Previously those where nil. The tests in contrib expect those properties to be nil.

See e.g. here: https://github.com/open-telemetry/opentelemetry-collector/actions/runs/8231961010/job/22508354464?pr=9672#step:4:1109

=== FAIL: . TestLoadConfig/zipkin/2 (0.00s)
    config_test.go:86: 
        	Error Trace:	/tmp/opentelemetry-collector-contrib/exporter/zipkinexporter/config_test.go:86
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -39,3 +39,4 @@
        	            	   Timeout: (time.Duration) 5000000000,
        	            	-  Headers: (map[string]configopaque.String) <nil>,
        	            	+  Headers: (map[string]configopaque.String) {
        	            	+  },

I'm not exactly sure what's the preferred course of action here.

  • Allow contrib tests to fail and fix them after updating core in contrib?
  • Fix those tests before merging this change so that those tests to not check that Response and ResponseHeaders are nil?
  • ...?

What's your opinion @TylerHelmuth ?

andrzej-stencel avatar Mar 13 '24 14:03 andrzej-stencel

Oh my comment was only a general statement, not a reason for the failing tests. I dont think we should introduce NewDefault* functions here until they can depend on the NewDefault* functions from configtls.

For the tests themselves I'd say we have 2 options:

  1. Not use empty map as the default value and instead use nil
  2. Allow contrib tests to fail and fix them after updating core in contrib

TylerHelmuth avatar Mar 13 '24 17:03 TylerHelmuth

Oh my comment was only a general statement, not a reason for the failing tests. I dont think we should introduce NewDefault* functions here until they can depend on the NewDefault* functions from configtls.

Oh, I see :smile: Makes sense, @Sanket-0510 this means this PR should wait for https://github.com/open-telemetry/opentelemetry-collector/pull/9658. After https://github.com/open-telemetry/opentelemetry-collector/pull/9658 is merged, you can incorporate changes from main (by merging or rebasing) and then we can continue with this.

For the tests themselves I'd say we have 2 options:

1. Not use empty map as the default value and instead use nil

2. Allow contrib tests to fail and fix them after updating core in contrib

I don't like 1, I believe the functions should not leave the map as nil, as this would expose users of those functions to potential panic. Let's go with 2 if possible.

andrzej-stencel avatar Mar 15 '24 22:03 andrzej-stencel

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

github-actions[bot] avatar Mar 30 '24 03:03 github-actions[bot]

@Sanket-0510 this is ready to use the configtls. NewDefault* funcs

TylerHelmuth avatar Apr 15 '24 17:04 TylerHelmuth

@Sanket-0510 this is ready to use the configtls. NewDefault* funcs

I'll rebase!

Sanket-0510 avatar Apr 15 '24 17:04 Sanket-0510

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

github-actions[bot] avatar May 21 '24 03:05 github-actions[bot]

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

github-actions[bot] avatar Jun 05 '24 03:06 github-actions[bot]

Closed as inactive. Feel free to reopen if this PR is still being worked on.

github-actions[bot] avatar Jun 22 '24 03:06 github-actions[bot]