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

Using component for no op host instead of component test #6058

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

chahatsagarmain
Copy link

Which problem is this PR solving?

Description of the changes

  • Created a no op host using component and removed code for component test

How was this change tested?

  • Using make lint test
  • Please review and suggest changes and improvements

@@ -98,7 +107,8 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger)
for _, opt := range opts {
clientOpts = append(clientOpts, configgrpc.WithGrpcDialOption(opt))
}
return f.config.ToClientConn(context.Background(), componenttest.NewNopHost(), telset, clientOpts...)
noophost := NewNopHost()
Copy link
Contributor

Choose a reason for hiding this comment

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

we also have a usage of componenttest.NewNopHost in https://github.com/jaegertracing/jaeger/blob/main/cmd/jaeger/internal/integration/span_writer.go#L55. Maybe we can move the NopHost to a shared package rather than just having it live here so we don't have to define it every time we need it?

Copy link
Member

Choose a reason for hiding this comment

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

the point was to use the real Host provided by OTEL collector. There's no reason to define our own noop host.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

So we need host implementation here with its related methods ?

@@ -98,7 +107,8 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger)
for _, opt := range opts {
clientOpts = append(clientOpts, configgrpc.WithGrpcDialOption(opt))
}
return f.config.ToClientConn(context.Background(), componenttest.NewNopHost(), telset, clientOpts...)
noophost := NewNopHost()
Copy link
Contributor

Choose a reason for hiding this comment

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

@chahatsagarmain instead of creating a nophost here, you can just pass component.Host into NewFactoryWithConfig from https://github.com/jaegertracing/jaeger/blob/main/cmd/jaeger/internal/extension/jaegerstorage/extension.go#L115

mahadzaryab1 and others added 4 commits October 7, 2024 15:57
## Which problem is this PR solving?
- Part of jaegertracing#6040

## Description of the changes
- Added the
[attributesprocessor](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/attributesprocessor/README.md)
to the Jaeger V2 binary to replace `--collector.tags`. See the
[migration
guide](https://docs.google.com/document/d/18B1yTMewRft2N0nW9K-ecVRTt5VaNgnrPTW1eL236t4/edit?usp=sharing)
for more details.

## How was this change tested?
- 

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `yarn lint` and `yarn test`

---------

Signed-off-by: Mahad Zaryab <[email protected]>
Signed-off-by: chahatsagarmain <[email protected]>
@chahatsagarmain
Copy link
Author

@mahadzaryab1 can you check the host interface commit , I have created the host interface with extensions method . do i need to add the same for factories here ?

Comment on lines +51 to +53
type host struct {
extensions map[component.ID]component.Component
}
Copy link
Contributor

@mahadzaryab1 mahadzaryab1 Oct 8, 2024

Choose a reason for hiding this comment

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

@chahatsagarmain so we actually don't need to define a host at all. if you take a look at this method, you'll see that the host is available to us already. What you need to do is pass the host down from the method I linked above into this function and you can then pass it into Initialize and then into ToClientConn. Does that make sense?

Copy link
Author

Choose a reason for hiding this comment

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

Passing as a params to Initialize gives declaration error for Factory but Creating a host in NewFactoryWithConfig wouldnt that also be a no op host?

Copy link
Author

Choose a reason for hiding this comment

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

@mahadzaryab1 can the otel collector initialize a component.Host in collectorParams which can be used here ?

Copy link
Contributor

@mahadzaryab1 mahadzaryab1 Oct 11, 2024

Choose a reason for hiding this comment

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

I think you'll want to do something like this:

  1. Update Factory struct to contain the host
type Factory struct {
	metricsFactory metrics.Factory
	logger         *zap.Logger
	tracerProvider trace.TracerProvider
	config         Config
	services       *ClientPluginServices
	remoteConn     *grpc.ClientConn
	host           component.Host
}
  1. Update NewFactoryWithConfig so that it takes in the host and sets it in the factory
func NewFactoryWithConfig(
	cfg Config,
	metricsFactory metrics.Factory,
	logger *zap.Logger,
	host component.Host,
) (*Factory, error) {
	f := NewFactory()
	f.config = cfg
	f.host = host
	if err := f.Initialize(metricsFactory, logger); err != nil {
		return nil, err
	}
	return f, nil
}
  1. Use f.host in Initialize

Copy link
Member

Choose a reason for hiding this comment

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

+1 - don't change the interface, but ok to change constructor

Signed-off-by: chahatsagarmain <[email protected]>
@@ -126,7 +126,7 @@ func (s *storageExt) Start(_ context.Context, _ component.Host) error {
factory, err = badger.NewFactoryWithConfig(*cfg.Badger, mf, s.telset.Logger)
case cfg.GRPC != nil:
//nolint: contextcheck
factory, err = grpc.NewFactoryWithConfig(*cfg.GRPC, mf, s.telset.Logger)
factory, err = grpc.NewFactoryWithConfig(*cfg.GRPC, mf, s.telset.Logger, grpc.NewHost())
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to create a new host, its passed into this method. Just change the _ in the function signature to be host and pass that in here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants