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

Convert unknown telemetry into custom event #988

Closed
Dmitry-Matveev opened this issue Nov 9, 2018 · 0 comments
Closed

Convert unknown telemetry into custom event #988

Dmitry-Matveev opened this issue Nov 9, 2018 · 0 comments
Assignees
Milestone

Comments

@Dmitry-Matveev
Copy link
Member

Dmitry-Matveev commented Nov 9, 2018

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
Projects
None yet
Development

No branches or pull requests

1 participant