@opentelemetry/api
Version:
Public API for OpenTelemetry
1 lines • 2.48 kB
Source Map (JSON)
{"version":3,"file":"NonRecordingSpan.mjs","names":[],"sources":["../../src/trace/NonRecordingSpan.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { Exception } from '../common/Exception';\nimport type { TimeInput } from '../common/Time';\nimport type { SpanAttributes } from './attributes';\nimport { INVALID_SPAN_CONTEXT } from './invalid-span-constants';\nimport type { Span } from './span';\nimport type { SpanContext } from './span_context';\nimport type { SpanStatus } from './status';\nimport type { Link } from './link';\n\n/**\n * The NonRecordingSpan is the default {@link Span} that is used when no Span\n * implementation is available. All operations are no-op including context\n * propagation.\n */\nexport class NonRecordingSpan implements Span {\n private readonly _spanContext: SpanContext;\n\n constructor(spanContext: SpanContext = INVALID_SPAN_CONTEXT) {\n this._spanContext = spanContext;\n }\n\n // Returns a SpanContext.\n spanContext(): SpanContext {\n return this._spanContext;\n }\n\n // By default does nothing\n setAttribute(_key: string, _value: unknown): this {\n return this;\n }\n\n // By default does nothing\n setAttributes(_attributes: SpanAttributes): this {\n return this;\n }\n\n // By default does nothing\n addEvent(_name: string, _attributes?: SpanAttributes): this {\n return this;\n }\n\n addLink(_link: Link): this {\n return this;\n }\n\n addLinks(_links: Link[]): this {\n return this;\n }\n\n // By default does nothing\n setStatus(_status: SpanStatus): this {\n return this;\n }\n\n // By default does nothing\n updateName(_name: string): this {\n return this;\n }\n\n // By default does nothing\n end(_endTime?: TimeInput): void {}\n\n // isRecording always returns false for NonRecordingSpan.\n isRecording(): boolean {\n return false;\n }\n\n // By default does nothing\n recordException(_exception: Exception, _time?: TimeInput): void {}\n}\n"],"mappings":";;;;;;;AAmBA,IAAa,mBAAb,MAA8C;CAG5C,YAAY,cAA2B,sBAAsB;EAC3D,KAAK,eAAe;CACtB;CAGA,cAA2B;EACzB,OAAO,KAAK;CACd;CAGA,aAAa,MAAc,QAAuB;EAChD,OAAO;CACT;CAGA,cAAc,aAAmC;EAC/C,OAAO;CACT;CAGA,SAAS,OAAe,aAAoC;EAC1D,OAAO;CACT;CAEA,QAAQ,OAAmB;EACzB,OAAO;CACT;CAEA,SAAS,QAAsB;EAC7B,OAAO;CACT;CAGA,UAAU,SAA2B;EACnC,OAAO;CACT;CAGA,WAAW,OAAqB;EAC9B,OAAO;CACT;CAGA,IAAI,UAA4B,CAAC;CAGjC,cAAuB;EACrB,OAAO;CACT;CAGA,gBAAgB,YAAuB,OAAyB,CAAC;AACnE"}