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

Commit

Permalink
chore: rename span#context() to span#spanContext (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Apr 26, 2021
1 parent c1f302e commit b5784d3
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
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);
});
});

0 comments on commit b5784d3

Please sign in to comment.