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

Move Unmarshaler interface to Config instead of Factory #2867

Merged
merged 14 commits into from
Apr 12, 2021

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Mar 31, 2021

Description:

  • Remove component.ConfigUnmarshaler and WithCustomUnmarshaler. Add fallback behavior.
  • Add config.Unmarshable interface.
  • Move from using component.ConfigUnmarshaler to using config.Unmarshable interface on existing components.

Link to tracking Issue: Fixes #2597

Testing: Amended unit tests

To be tracked on #2819.

mx-psi added 3 commits March 31, 2021 11:30
If a component wants custom unmarshaling they need to add an
Unmarshal method to their Config struct instead of providing
it through the factory.
@codecov
Copy link

codecov bot commented Mar 31, 2021

Codecov Report

Merging #2867 (c00b5e6) into main (4aeef52) will decrease coverage by 0.04%.
The diff coverage is 82.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2867      +/-   ##
==========================================
- Coverage   91.76%   91.72%   -0.05%     
==========================================
  Files         286      286              
  Lines       15100    15056      -44     
==========================================
- Hits        13857    13810      -47     
- Misses        850      853       +3     
  Partials      393      393              
Impacted Files Coverage Δ
config/config.go 100.00% <ø> (ø)
receiver/hostmetricsreceiver/config.go 63.63% <61.90%> (-36.37%) ⬇️
receiver/prometheusreceiver/config.go 66.66% <64.70%> (-33.34%) ⬇️
config/configparser/config.go 98.55% <80.00%> (-1.45%) ⬇️
receiver/jaegerreceiver/config.go 91.17% <89.28%> (-8.83%) ⬇️
exporter/exporterhelper/factory.go 100.00% <100.00%> (ø)
extension/extensionhelper/factory.go 88.88% <100.00%> (-11.12%) ⬇️
internal/testcomponents/example_exporter.go 100.00% <100.00%> (ø)
processor/processorhelper/factory.go 100.00% <100.00%> (ø)
receiver/hostmetricsreceiver/factory.go 100.00% <100.00%> (+12.98%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4aeef52...c00b5e6. Read the comment docs.

@mx-psi mx-psi marked this pull request as ready for review March 31, 2021 10:04
@mx-psi mx-psi requested a review from a team March 31, 2021 10:04
config/config.go Outdated Show resolved Hide resolved
receiver/jaegerreceiver/factory_test.go Show resolved Hide resolved
receiver/hostmetricsreceiver/config.go Outdated Show resolved Hide resolved
Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Overall looks good

config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/configparser/config.go Show resolved Hide resolved
receiver/hostmetricsreceiver/config.go Outdated Show resolved Hide resolved
receiver/jaegerreceiver/factory_test.go Show resolved Hide resolved
receiver/otlpreceiver/config.go Outdated Show resolved Hide resolved
@bogdandrutu
Copy link
Member

@mx-psi not sure if you forgot to push changes or you are still working on them :)

@mx-psi
Copy link
Member Author

mx-psi commented Apr 2, 2021

@mx-psi not sure if you forgot to push changes or you are still working on them :)

@bogdandrutu had it half-finished yesterday but I didn't want to ping you. You can take a look now!

// load the non-dynamic config normally
err := componentParser.Unmarshal(cfg)
if err != nil {
return err
Copy link
Member Author

Choose a reason for hiding this comment

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

This (and other error modes on the customUnmarshalers) was untested before, I can add tests for this but I think it can be done on a different PR.

mx-psi added 3 commits April 2, 2021 14:02
Revert "Add deprecation comment"

This reverts commit 4e10ec2.

Revert "Amend comment"

This reverts commit ab5ae0a.

Revert "Deprecate factory unmarshaler interface"

This reverts commit e33c788.
Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Will wait for you to respond to the last round of comments.

config/config.go Outdated
@@ -168,6 +168,14 @@ type validatable interface {
Validate() error
}

// Unmarshable defines the optional interface for the configuration unmarshaling.
Copy link
Member

Choose a reason for hiding this comment

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

We should mention what is the default if not implemented. Configs will still be unmarshalled but using the default way. Maybe name the interface CustomUnmarshable (not sure asking for opinion)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe name the interface CustomUnmarshable (not sure asking for opinion)?

I agree, that name is less confusing. I will also update the docs to note that there is a default unmarshaler.

Comment on lines +94 to +96
if componentParser == nil || len(componentParser.AllKeys()) == 0 {
return fmt.Errorf("empty config for Jaeger receiver")
}
Copy link
Member

Choose a reason for hiding this comment

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

For future PR, maybe this validation belongs to Validate not to unmarshal?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 I will have a look at the custom unmarshalers and move whatever makes sense to the validation method in a future PR

@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 Apr 10, 2021
@mx-psi
Copy link
Member Author

mx-psi commented Apr 12, 2021

This is mergeable (maybe @tigrannajaryan can merge since Bogdan seems to be on PTO?)

@bogdandrutu bogdandrutu removed the Stale label Apr 12, 2021
@bogdandrutu bogdandrutu merged commit a31ad5b into open-telemetry:main Apr 12, 2021
@mx-psi mx-psi deleted the mx-psi/move-unmarshaler branch April 14, 2021 15:53
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
…y#2867)

Bumps [boto3](https://github.com/boto/boto3) from 1.26.96 to 1.26.97.
- [Release notes](https://github.com/boto/boto3/releases)
- [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst)
- [Commits](boto/boto3@1.26.96...1.26.97)

---
updated-dependencies:
- dependency-name: boto3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move custom unmarshaler to config instead of component factory
2 participants