How to use the @opentelemetry/types.CanonicalCode 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-tracing / src / Span.ts View on Github external
/**
 * This class represents a span.
 */
export class Span implements types.Span, ReadableSpan {
  // Below properties are included to implement ReadableSpan for export
  // purposes but are not intended to be written-to directly.
  readonly spanContext: types.SpanContext;
  readonly kind: types.SpanKind;
  readonly parentSpanId?: string;
  readonly attributes: types.Attributes = {};
  readonly links: types.Link[] = [];
  readonly events: types.TimedEvent[] = [];
  readonly startTime: types.HrTime;
  name: string;
  status: types.Status = {
    code: types.CanonicalCode.OK,
  };
  endTime: types.HrTime = [0, 0];
  private _ended = false;
  private _duration: types.HrTime = [-1, -1];
  private readonly _logger: types.Logger;
  private readonly _spanProcessor: SpanProcessor;
  private readonly _traceParams: TraceParams;

  /** Constructs a new Span instance. */
  constructor(
    parentTracer: BasicTracer,
    spanName: string,
    spanContext: types.SpanContext,
    kind: types.SpanKind,
    parentSpanId?: string,
    links: types.Link[] = [],
github open-telemetry / opentelemetry-js / packages / opentelemetry-shim-opentracing / src / shim.ts View on Github external
setTag(key: string, value: unknown): this {
    if (
      key === opentracing.Tags.ERROR &&
      (value === true || value === 'true')
    ) {
      this._span.setStatus({ code: types.CanonicalCode.UNKNOWN });
      return this;
    }

    this._span.setAttribute(key, value);
    return this;
  }
github open-telemetry / opentelemetry-js / packages / opentelemetry-exporter-zipkin / src / transform.ts View on Github external
export function _toZipkinTags(
  attributes: types.Attributes,
  status: types.Status,
  statusCodeTagName: string,
  statusDescriptionTagName: string
): zipkinTypes.Tags {
  const tags: { [key: string]: string } = {};
  for (const key of Object.keys(attributes)) {
    tags[key] = String(attributes[key]);
  }
  tags[statusCodeTagName] = String(types.CanonicalCode[status.code]);
  if (status.message) {
    tags[statusDescriptionTagName] = status.message;
  }
  return tags;
}