Orleans.TelemetryConsumers.AI and Telemetry interfaces are not DI and usage friendly
We are upgrading our Orleans solution from 1.5.x to 2.0 and we have to port the telemetry consumer code for the new version. We are using the Application Insights telemetry consumer and the current implementation looks like this which is not to friendly to use it.
public class SampleTelemetryGrain : Grain, ISampleTelemetryGrain
{
public readonly ITraceTelemetryConsumer _traceTelemetry;
public readonly IEventTelemetryConsumer _eventTelemetry;
public readonly IExceptionTelemetryConsumer _exceptionTelemetry;
public SampleTelemetryGrain(ITraceTelemetryConsumer traceTelemetry, IEventTelemetryConsumer eventTelemetry, IExceptionTelemetryConsumer exceptionTelemetry)
{
_traceTelemetry = traceTelemetry;
_eventTelemetry = eventTelemetry;
_exceptionTelemetry = exceptionTelemetry;
}
public Task DoSomthing()
{
try
{
_eventTelemetry.TrackEvent("Event");
_traceTelemetry.TrackTrace("Event", Severity.Info);
//Do somthing
}
catch (Exception ex)
{
_exceptionTelemetry.TrackException(ex);
throw;
}
return Task.CompletedTask;
}
}
I also for this I have to register all these interfaces into the DI container separately
Would be great a Common Interface to register and use.
Do you know the interface ITelemetryProducer, if you log messages through ITelemetryProducer , it will send those messages to all telemetry consumer. And each telemetry consumer will filter on their end on what kind of message they want to log, such as exception specifically or just traces.
Is this the ability you want ?
You can get ITelemetryProducer from DI.
Oh, I see. I just missed that, this ITelemetryProducer interface still there and can be used.