Skip to content

Incorrect DI lookup in AddProducers #4202

Description

@dssldavidmorgan

Describe the bug

In Paramore.Brighter.Extensions.DependencyInjection.ServiceCollectionExtensions method Tracer line 903 Brighter attempts to get a registered BrighterTracer to construct an IAmAnOutBoxProducerMediator in method BuildOutBoxProducerMediator.

What is registered in Paramore.Brighter.Extensions.Diagnostics.AddBrighterInstrumentation is an IAmABrighterTracer and that's what code in other places of those service collection extensions looks for.

Getting around this problem requires a double-registration like this, of a service that should be registered automatically in AddBrighterInstrumentation.

var tracer = new BrighterTracer(TimeProvider.System);
builder.Services.AddSingleton<BrighterTracer>(tracer);
builder.Services.AddSingleton<IAmABrighterTracer>(tracer);

Otherwise the mediator is injected with a null tracer and subsequent spans aren't associated with the parent trace.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions