How to use the @opentelemetry/types.CanonicalCode.ABORTED function in @opentelemetry/types

To help you get started, we’ve selected a few @opentelemetry/types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-telemetry / opentelemetry-js / packages / opentelemetry-plugin-http / src / utils.ts View on Github external
span.setAttributes({
    [AttributeNames.HTTP_ERROR_NAME]: error.name,
    [AttributeNames.HTTP_ERROR_MESSAGE]: message,
  });

  if (!obj) {
    span.setStatus({ code: CanonicalCode.UNKNOWN, message });
    return;
  }

  let status: Status;
  if ((obj as IncomingMessage).statusCode) {
    status = parseResponseStatus((obj as IncomingMessage).statusCode!);
  } else if ((obj as ClientRequest).aborted) {
    status = { code: CanonicalCode.ABORTED };
  } else {
    status = { code: CanonicalCode.UNKNOWN };
  }

  status.message = message;

  span.setStatus(status);
};
github open-telemetry / opentelemetry-js / packages / opentelemetry-plugin-http / src / http.ts View on Github external
response.on('end', () => {
            this._logger.debug('outgoingRequest on end()');
            if (response.statusCode) {
              span.setAttributes({
                [AttributeNames.HTTP_STATUS_CODE]: response.statusCode,
                [AttributeNames.HTTP_STATUS_TEXT]: response.statusMessage,
              });
            }

            if (response.aborted && !response.complete) {
              span.setStatus({ code: CanonicalCode.ABORTED });
            } else {
              span.setStatus(Utils.parseResponseStatus(response.statusCode!));
            }

            if (this._config.applyCustomAttributesOnSpan) {
              this._config.applyCustomAttributesOnSpan(span, request, response);
            }

            span.end();
          });
          Utils.setSpanOnError(span, response);