Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.

Commit 9538416

Browse files
committed
Merge remote-tracking branch 'origin/main' into span-context-rename
2 parents 991e550 + c1f302e commit 9538416

File tree

8 files changed

+62
-31
lines changed

8 files changed

+62
-31
lines changed

Diff for: README.md

+38-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
1+
2+
---
3+
<p align="center">
4+
<strong>
5+
<a href="https://open-telemetry.github.io/opentelemetry-js">API Documentation<a/>
6+
&nbsp;&nbsp;&bull;&nbsp;&nbsp;
7+
<a href="https://github.com/open-telemetry/opentelemetry-js/discussions">Getting In Touch (GitHub Discussions)<a/>
8+
</strong>
9+
</p>
10+
11+
<p align="center">
12+
<a href="https://github.com/open-telemetry/opentelemetry-js-api/releases">
13+
<img alt="GitHub release (latest by date including pre-releases)" src="https://img.shields.io/github/v/release/open-telemetry/opentelemetry-js-api?include_prereleases&style=for-the-badge">
14+
</a>
15+
<a href="https://codecov.io/gh/open-telemetry/opentelemetry-js-api/branch/main/">
16+
<img alt="Codecov Status" src="https://img.shields.io/codecov/c/github/open-telemetry/opentelemetry-js-api?style=for-the-badge">
17+
</a>
18+
<a href="https://github.com/open-telemetry/opentelemetry-js-api/blob/main/LICENSE">
19+
<img alt="license" src="https://img.shields.io/badge/license-Apache_2.0-green.svg?style=for-the-badge">
20+
</a>
21+
<br/>
22+
<a href="https://github.com/open-telemetry/opentelemetry-js-api/actions/workflows/docs.yaml">
23+
<img alt="Build Status" src="https://github.com/open-telemetry/opentelemetry-js-api/actions/workflows/test.yaml/badge.svg?branch=main">
24+
</a>
25+
<a href="https://github.com/open-telemetry/opentelemetry-js-api/actions/workflows/test.yaml?query=branch%3Amain">
26+
<img alt="Build Status" src="https://github.com/open-telemetry/opentelemetry-js-api/actions/workflows/docs.yaml/badge.svg">
27+
</a>
28+
</p>
29+
30+
---
31+
132
# OpenTelemetry API for JavaScript
233

334
[![NPM Published Version][npm-img]][npm-url]
435
[![dependencies][dependencies-image]][dependencies-url]
536
[![devDependencies][devDependencies-image]][devDependencies-url]
6-
[![Apache License][license-image]][license-image]
737

838
This package provides everything needed to interact with the OpenTelemetry API, including all TypeScript interfaces, enums, and no-op implementations. It is intended for use both on the server and in the browser.
939

@@ -50,7 +80,7 @@ const tracer = trace.getTracer(name, version);
5080
// Trace your application by creating spans
5181
async function operation() {
5282
const span = tracer.startSpan("do operation");
53-
83+
5484
// mock some work by sleeping 1 second
5585
await new Promise((resolve, reject) => {
5686
setTimeout(resolve, 1000);
@@ -73,11 +103,13 @@ main();
73103

74104
Because the npm installer and node module resolution algorithm could potentially allow two or more copies of any given package to exist within the same `node_modules` structure, the OpenTelemetry API takes advantage of a variable on the `global` object to store the global API. When an API method in the API package is called, it checks if this `global` API exists and proxies calls to it if and only if it is a compatible API version. This means if a package has a dependency on an OpenTelemetry API version which is not compatible with the API used by the end user, the package will receive a no-op implementation of the API.
75105

106+
<<<<<<< HEAD
76107
## Upgrade Guidelines
77108

78-
- `1.0.0-rc.1`
109+
### 1.0.0-rc.0 to x
79110

80-
[#45](https://github.com/open-telemetry/opentelemetry-js-api/pull/45) `Span#context` renamed to `Span#spanContext`
111+
- `HttpBaggage` renamed to `HttpBaggagePropagator`
112+
- [#45](https://github.com/open-telemetry/opentelemetry-js-api/pull/45) `Span#context` renamed to `Span#spanContext`
81113

82114
## Useful links
83115

@@ -94,12 +126,11 @@ Apache 2.0 - See [LICENSE][license-url] for more information.
94126
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
95127
[license-url]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/LICENSE
96128
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
97-
[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-api/status.svg
129+
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-api.svg
98130
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-api
99-
[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-api/dev-status.svg
131+
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-api.svg?type=dev
100132
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-api?type=dev
101133
[npm-url]: https://www.npmjs.com/package/@opentelemetry/api
102134
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fapi.svg
103-
104135
[docs-tracing]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/docs/tracing.md
105136
[docs-sdk-registration]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/docs/sdk-registration.md

Diff for: src/context/context.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { Context } from './types';
1818
import { Baggage, Span, SpanContext } from '../';
19-
import { NoopSpan } from '../trace/NoopSpan';
19+
import { NonRecordingSpan } from '../trace/NonRecordingSpan';
2020

2121
/**
2222
* span key
@@ -56,7 +56,7 @@ export function setSpan(context: Context, span: Span): Context {
5656
}
5757

5858
/**
59-
* Wrap span context in a NoopSpan and set as span in a new
59+
* Wrap span context in a NonRecordingSpan and set as span in a new
6060
* context
6161
*
6262
* @param context context to set active span on
@@ -66,7 +66,7 @@ export function setSpanContext(
6666
context: Context,
6767
spanContext: SpanContext
6868
): Context {
69-
return setSpan(context, new NoopSpan(spanContext));
69+
return setSpan(context, new NonRecordingSpan(spanContext));
7070
}
7171

7272
/**

Diff for: src/trace/NoopSpan.ts renamed to src/trace/NonRecordingSpan.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import { SpanStatus } from './status';
2323
import { INVALID_SPAN_CONTEXT } from './spancontext-utils';
2424

2525
/**
26-
* The NoopSpan is the default {@link Span} that is used when no Span
26+
* The NonRecordingSpan is the default {@link Span} that is used when no Span
2727
* implementation is available. All operations are no-op including context
2828
* propagation.
2929
*/
30-
export class NoopSpan implements Span {
30+
export class NonRecordingSpan implements Span {
3131
constructor(
3232
private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT
3333
) {}
@@ -65,7 +65,7 @@ export class NoopSpan implements Span {
6565
// By default does nothing
6666
end(_endTime?: TimeInput): void {}
6767

68-
// isRecording always returns false for noopSpan.
68+
// isRecording always returns false for NonRecordingSpan.
6969
isRecording(): boolean {
7070
return false;
7171
}

Diff for: src/trace/NoopTracer.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { getSpanContext } from '../context/context';
1818
import { Context } from '../context/types';
19-
import { NoopSpan } from './NoopSpan';
19+
import { NonRecordingSpan } from './NonRecordingSpan';
2020
import { Span } from './span';
2121
import { isSpanContextValid } from './spancontext-utils';
2222
import { SpanOptions } from './SpanOptions';
@@ -31,7 +31,7 @@ export class NoopTracer implements Tracer {
3131
startSpan(name: string, options?: SpanOptions, context?: Context): Span {
3232
const root = Boolean(options?.root);
3333
if (root) {
34-
return new NoopSpan();
34+
return new NonRecordingSpan();
3535
}
3636

3737
const parentFromContext = context && getSpanContext(context);
@@ -40,9 +40,9 @@ export class NoopTracer implements Tracer {
4040
isSpanContext(parentFromContext) &&
4141
isSpanContextValid(parentFromContext)
4242
) {
43-
return new NoopSpan(parentFromContext);
43+
return new NonRecordingSpan(parentFromContext);
4444
} else {
45-
return new NoopSpan();
45+
return new NonRecordingSpan();
4646
}
4747
}
4848
}

Diff for: test/api/api.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import api, {
3434
diag,
3535
} from '../../src';
3636
import { DiagAPI } from '../../src/api/diag';
37-
import { NoopSpan } from '../../src/trace/NoopSpan';
37+
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';
3838

3939
// DiagLogger implementation
4040
const diagLoggerFunctions = [
@@ -78,7 +78,7 @@ describe('API', () => {
7878
spanId: '6e0c63257de34c92',
7979
traceFlags: TraceFlags.NONE,
8080
};
81-
const dummySpan = new NoopSpan(spanContext);
81+
const dummySpan = new NonRecordingSpan(spanContext);
8282

8383
beforeEach(() => {
8484
context.disable();

Diff for: test/noop-implementations/noop-span.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import {
2121
INVALID_TRACEID,
2222
TraceFlags,
2323
} from '../../src';
24-
import { NoopSpan } from '../../src/trace/NoopSpan';
24+
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';
2525

26-
describe('NoopSpan', () => {
26+
describe('NonRecordingSpan', () => {
2727
it('do not crash', () => {
28-
const span = new NoopSpan();
28+
const span = new NonRecordingSpan();
2929
span.setAttribute('my_string_attribute', 'foo');
3030
span.setAttribute('my_number_attribute', 123);
3131
span.setAttribute('my_boolean_attribute', false);

Diff for: test/noop-implementations/noop-tracer.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ import {
2323
context,
2424
setSpanContext,
2525
} from '../../src';
26-
import { NoopSpan } from '../../src/trace/NoopSpan';
26+
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';
2727

2828
describe('NoopTracer', () => {
2929
it('should not crash', () => {
3030
const tracer = new NoopTracer();
3131

32-
assert.ok(tracer.startSpan('span-name') instanceof NoopSpan);
32+
assert.ok(tracer.startSpan('span-name') instanceof NonRecordingSpan);
3333
assert.ok(
3434
tracer.startSpan('span-name1', { kind: SpanKind.CLIENT }) instanceof
35-
NoopSpan
35+
NonRecordingSpan
3636
);
3737
assert.ok(
3838
tracer.startSpan('span-name2', { kind: SpanKind.CLIENT }) instanceof
39-
NoopSpan
39+
NonRecordingSpan
4040
);
4141
});
4242

Diff for: test/proxy-implementations/proxy-tracer.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
ROOT_CONTEXT,
2828
SpanOptions,
2929
} from '../../src';
30-
import { NoopSpan } from '../../src/trace/NoopSpan';
30+
import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan';
3131

3232
describe('ProxyTracer', () => {
3333
let provider: ProxyTracerProvider;
@@ -51,14 +51,14 @@ describe('ProxyTracer', () => {
5151
it('startSpan should return Noop Spans', () => {
5252
const tracer = provider.getTracer('test');
5353

54-
assert.ok(tracer.startSpan('span-name') instanceof NoopSpan);
54+
assert.ok(tracer.startSpan('span-name') instanceof NonRecordingSpan);
5555
assert.ok(
5656
tracer.startSpan('span-name1', { kind: SpanKind.CLIENT }) instanceof
57-
NoopSpan
57+
NonRecordingSpan
5858
);
5959
assert.ok(
6060
tracer.startSpan('span-name2', { kind: SpanKind.CLIENT }) instanceof
61-
NoopSpan
61+
NonRecordingSpan
6262
);
6363
});
6464
});
@@ -91,7 +91,7 @@ describe('ProxyTracer', () => {
9191
let delegateTracer: Tracer;
9292

9393
beforeEach(() => {
94-
delegateSpan = new NoopSpan();
94+
delegateSpan = new NonRecordingSpan();
9595
delegateTracer = {
9696
startSpan() {
9797
return delegateSpan;

0 commit comments

Comments
 (0)