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

chore: rename span#context() to span#spanContext #45

Merged
merged 3 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ main();

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.

## Upgrade guidelines
## Upgrade Guidelines

### 1.0.0-rc.0 to x

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

## Useful links

Expand Down
2 changes: 1 addition & 1 deletion src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function setSpanContext(
* @param context context to get values from
*/
export function getSpanContext(context: Context): SpanContext | undefined {
return getSpan(context)?.context();
return getSpan(context)?.spanContext();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/trace/NonRecordingSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class NonRecordingSpan implements Span {
) {}

// Returns a SpanContext.
context(): SpanContext {
spanContext(): SpanContext {
return this._spanContext;
}

Expand Down
2 changes: 1 addition & 1 deletion src/trace/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface Span {
*
* @returns the SpanContext object associated with this Span.
*/
context(): SpanContext;
spanContext(): SpanContext;

/**
* Sets an attribute to the span.
Expand Down
2 changes: 1 addition & 1 deletion test/noop-implementations/noop-span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('NonRecordingSpan', () => {
span.updateName('my-span');

assert.ok(!span.isRecording());
assert.deepStrictEqual(span.context(), {
assert.deepStrictEqual(span.spanContext(), {
traceId: INVALID_TRACEID,
spanId: INVALID_SPANID,
traceFlags: TraceFlags.NONE,
Expand Down
6 changes: 3 additions & 3 deletions test/noop-implementations/noop-tracer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ describe('NoopTracer', () => {
{},
setSpanContext(context.active(), parent)
);
assert(span.context().traceId === parent.traceId);
assert(span.context().spanId === parent.spanId);
assert(span.context().traceFlags === parent.traceFlags);
assert(span.spanContext().traceId === parent.traceId);
assert(span.spanContext().spanId === parent.spanId);
assert(span.spanContext().traceFlags === parent.traceFlags);
});
});