Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Application Insight. Custom attribute length restriction

I'm using Azure App Insight as a logging tool and store log data by the following code:

    private void SendTrace(LoggingEvent loggingEvent)
    {
        loggingEvent.GetProperties();
        string message = "TestMessage";

        var trace = new TraceTelemetry(message)
        {
            SeverityLevel = SeverityLevel.Information
        };

        trace.Properties.Add("TetstKey", "TestValue");
        var telemetryClient = new TelemetryClient();
        telemetryClient.Context.InstrumentationKey = this.InstrumentationKey;
        telemetryClient.Track(trace);
    }

everything works well. I see logged record in App insight as well as in App insight analytics (in trace table). My custom attributes are written in special app insight row section - customDimensions. For example, the above code will add new attribute with "TestKey" key and "TestValue" value into customDimensions section.

But when I try to write some big text (for example JSON document with more then 15k letters) I still can do it without any exceptions, but the writable text will be cut off after some document length. As the result, the custom attribute value in customDimensions section will be cropped too and will have only first part of document. As I understand there is the restriction for max text length which is allowed to be written in app insight custom attribute.

Could someone know how can I get around with this?

like image 224
dododo Avatar asked Dec 08 '22 14:12

dododo


1 Answers

The message has the highest allowed limit of 32768. For items in the property collection, value has max limit of 8192.

So you can try one of the following options:

  1. Use message field to the fullest by putting the big text there.

  2. Split the data into multiple, and add to properties collection separately.

    eg:

    trace.Properties.Add("key_part1", "Bigtext1_upto8192");

    trace.Properties.Add("key_part2", "Bigtext2_upto8192");

Reference: https://github.com/MicrosoftDocs/azure-docs/blob/master/includes/application-insights-limits.md

like image 164
cijothomas Avatar answered Feb 25 '23 11:02

cijothomas