Skip to content

Convert unknown telemetry into custom event #988

Closed

Description

Currently, any telemetry item that implements ITelemetry but is not directly supported in the serialization pipeline is dropped.

The suggestion is to convert such telemetry item into EventTelemetry and serialize all values from this unknown telemetry item into the Properties of Dictionary<string, string> type.

This will allow delivery of custom telemetry items implementing ITelemetry interface and public void SerializeData(ISerializationWriter serializationWriter) method into Application Insights backend as Custom Events.

For insance, an event like this:

    public class DmitryEvent : ITelemetry
    {
        public DmitryEvent()
        {
            this.Timestamp = DateTimeOffset.Now;
            this.Context = new TelemetryContext();
            this.MyMetrics = new Dictionary<string, double>();
        }

        public DateTimeOffset Timestamp { get; set; }

        public TelemetryContext Context { get; set; }

        public IExtension Extension { get; set; }

        public string Sequence { get; set; }

        public string DmitryField { get; set; }

        public Dictionary<string, double> MyMetrics;

        public ITelemetry DeepClone()
        {
            return new DmitryEvent() { DmitryField = this.DmitryField };
        }

        public void Sanitize() { }

        public void SerializeData(ISerializationWriter serializationWriter)
        {
            serializationWriter.WriteProperty("DmitryField", DmitryField);
            serializationWriter.WriteProperty("MyMetrics", MyMetrics);
        }
    }

And tracked like:

            DmitryEvent dmitryEvent = new DmitryEvent();
            dmitryEvent.DmitryField = "DmitryValue";
            dmitryEvent.MyMetrics = new Dictionary<string, double>
            {
                { "Dm1", 42.42 },
                { "Dm2", 24.24 }
            };
            client.Track(dmitryEvent);

Will be delivered as:
image

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

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions