Skip to content

HandledAt is not tracked in ExceptionΒ #569

Closed

Description

We found handledAt is not being tracked in the v1.0.15 anymore. We are seeing this field as empty. Looked into the code I found handledAt is available in the TrackException function's parameter, but it's never used inside. Is this a plan to move away from using handledAt?

/**
             * Log an exception you have caught.
             * @param   exception   An Error from a catch clause, or the string error message.
             * @param   handledAt   Not used
             * @param   properties  map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
             * @param   measurements    map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
             * @param   severityLevel   AI.SeverityLevel - severity level
             */
            AppInsights.prototype.trackException = function (exception, handledAt, properties, measurements, severityLevel) {
                try {
                    if (!ApplicationInsights.Util.isError(exception)) {
                        // ensure that we have an error object (user could pass a string/message)
                        try {
                            throw new Error(exception);
                        }
                        catch (error) {
                            exception = error;
                        }
                    }
                    var exceptionTelemetry = new ApplicationInsights.Telemetry.Exception(exception, properties, measurements, severityLevel);
                    var data = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.Exception.dataType, exceptionTelemetry);
                    var envelope = new ApplicationInsights.Telemetry.Common.Envelope(data, ApplicationInsights.Telemetry.Exception.envelopeType);
                    this.context.track(envelope);
                }
                catch (e) {
                    ApplicationInsights._InternalLogging.throwInternal(ApplicationInsights.LoggingSeverity.CRITICAL, ApplicationInsights._InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) });
                }
            };

However, v1.0.14.js has the handledAt as the parameter and being tracked in the code below.

/**
             * Log an exception you have caught.
             * @param   exception   An Error from a catch clause, or the string error message.
             * @param   properties  map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
             * @param   measurements    map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
             * @param   severityLevel   AI.SeverityLevel - severity level
             */
            AppInsights.prototype.trackException = function (exception, handledAt, properties, measurements, severityLevel) {
                try {
                    if (!ApplicationInsights.Util.isError(exception)) {
                        // ensure that we have an error object (user could pass a string/message)
                        try {
                            throw new Error(exception);
                        }
                        catch (error) {
                            exception = error;
                        }
                    }
                    var exceptionTelemetry = new ApplicationInsights.Telemetry.Exception(exception, handledAt, properties, measurements, severityLevel);
                    var data = new ApplicationInsights.Telemetry.Common.Data(ApplicationInsights.Telemetry.Exception.dataType, exceptionTelemetry);
                    var envelope = new ApplicationInsights.Telemetry.Common.Envelope(data, ApplicationInsights.Telemetry.Exception.envelopeType);
                    this.context.track(envelope);
                }
                catch (e) {
                    ApplicationInsights._InternalLogging.throwInternal(ApplicationInsights.LoggingSeverity.CRITICAL, ApplicationInsights._InternalMessageId.TrackExceptionFailed, "trackException failed, exception will not be collected: " + ApplicationInsights.Util.getExceptionName(e), { exception: ApplicationInsights.Util.dump(e) });
                }
            };

Activity

  1. wqoq commented on Jun 20, 2018

    @wqoq

    I would say that's the case, given the details in #556 and #327. It looks like handledAt was meant to be internal-only.

  2. markwolff commented on Dec 14, 2018

    @markwolff
    Contributor

    handledAt hasn't been used for several iterations of the SDK, and won't be included in the v2 version either. Closing this for now...

  3. dagoltz commented on Jan 4, 2019

    @dagoltz

    This feature is still documented. I tried to use handledAt only to discover this bug that it is not working.
    Pleaes remove it from docs and instruct users to pass "null":
    https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#trackexception
    https://github.com/Microsoft/ApplicationInsights-JS/blob/1.0.15/API-reference.md#trackexception

  4. github-actions commented on Aug 19, 2021

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  5. locked as resolved and limited conversation to collaborators on Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions