orleans icon indicating copy to clipboard operation
orleans copied to clipboard

Orleans.TelemetryConsumers.AI and Telemetry interfaces are not DI and usage friendly

Open pherbel opened this issue 8 years ago • 3 comments

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.

pherbel avatar Jun 13 '18 08:06 pherbel

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 ?

xiazen avatar Jun 13 '18 23:06 xiazen

You can get ITelemetryProducer from DI.

xiazen avatar Jun 13 '18 23:06 xiazen

Oh, I see. I just missed that, this ITelemetryProducer interface still there and can be used.

pherbel avatar Jun 15 '18 08:06 pherbel