Skip to content

Commit 59516ce

Browse files
HazATkamilogorek
authored andcommitted
ref: Rename SpanProps to SpanContext
1 parent b3f0ed2 commit 59516ce

File tree

5 files changed

+34
-34
lines changed

5 files changed

+34
-34
lines changed

packages/hub/src/hub.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Integration,
99
IntegrationClass,
1010
Severity,
11-
SpanProps,
11+
SpanContext,
1212
User,
1313
} from '@sentry/types';
1414
import { consoleSandbox, dynamicRequire, getGlobalObject, isNodeEnv, logger, uuid4 } from '@sentry/utils';
@@ -389,17 +389,17 @@ export class Hub implements HubInterface {
389389
/**
390390
* @inheritDoc
391391
*/
392-
public startSpan(spanProps?: SpanProps): Span {
392+
public startSpan(SpanContext?: SpanContext): Span {
393393
const scope = this.getScope();
394394

395395
if (scope) {
396396
const span = scope.getSpan();
397397
if (span) {
398-
return span.newSpan(spanProps);
398+
return span.newSpan(SpanContext);
399399
}
400400
}
401401

402-
return new Span(spanProps);
402+
return new Span(SpanContext);
403403
}
404404

405405
/**

packages/hub/src/span.ts

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Span as SpanInterface, SpanProps } from '@sentry/types';
1+
import { Span as SpanInterface, SpanContext } from '@sentry/types';
22
import { uuid4 } from '@sentry/utils';
33

44
export const TRACEPARENT_REGEXP = /^[ \t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \t]*$/;
55

66
/**
77
* Span contains all data about a span
88
*/
9-
export class Span implements SpanInterface, SpanProps {
9+
export class Span implements SpanInterface, SpanContext {
1010
/**
1111
* Trace ID
1212
*/
@@ -67,44 +67,44 @@ export class Span implements SpanInterface, SpanProps {
6767
*/
6868
public finishedSpans: Span[] = [];
6969

70-
public constructor(spanProps?: SpanProps) {
71-
if (!spanProps) {
70+
public constructor(SpanContext?: SpanContext) {
71+
if (!SpanContext) {
7272
return this;
7373
}
7474

75-
if (spanProps.traceId) {
76-
this._traceId = spanProps.traceId;
75+
if (SpanContext.traceId) {
76+
this._traceId = SpanContext.traceId;
7777
}
78-
if (spanProps.spanId) {
79-
this._spanId = spanProps.spanId;
78+
if (SpanContext.spanId) {
79+
this._spanId = SpanContext.spanId;
8080
}
81-
if (spanProps.parentSpanId) {
82-
this._parentSpanId = spanProps.parentSpanId;
81+
if (SpanContext.parentSpanId) {
82+
this._parentSpanId = SpanContext.parentSpanId;
8383
}
84-
if (spanProps.sampled) {
85-
this.sampled = spanProps.sampled;
84+
if (SpanContext.sampled) {
85+
this.sampled = SpanContext.sampled;
8686
}
87-
if (spanProps.transaction) {
88-
this.transaction = spanProps.transaction;
87+
if (SpanContext.transaction) {
88+
this.transaction = SpanContext.transaction;
8989
}
90-
if (spanProps.op) {
91-
this.op = spanProps.op;
90+
if (SpanContext.op) {
91+
this.op = SpanContext.op;
9292
}
93-
if (spanProps.description) {
94-
this.description = spanProps.description;
93+
if (SpanContext.description) {
94+
this.description = SpanContext.description;
9595
}
96-
if (spanProps.data) {
97-
this.data = spanProps.data;
96+
if (SpanContext.data) {
97+
this.data = SpanContext.data;
9898
}
99-
if (spanProps.tags) {
100-
this.tags = spanProps.tags;
99+
if (SpanContext.tags) {
100+
this.tags = SpanContext.tags;
101101
}
102102
}
103103

104104
/** JSDoc */
105-
public newSpan(spanProps?: Pick<SpanProps, Exclude<keyof SpanProps, 'spanId'>>): Span {
105+
public newSpan(SpanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'spanId'>>): Span {
106106
const span = new Span({
107-
...spanProps,
107+
...SpanContext,
108108
parentSpanId: this._spanId,
109109
sampled: this.sampled,
110110
traceId: this._traceId,
@@ -121,7 +121,7 @@ export class Span implements SpanInterface, SpanProps {
121121
*/
122122
public static fromTraceparent(
123123
traceparent: string,
124-
spanProps?: Pick<SpanProps, Exclude<keyof SpanProps, 'spanId' | 'sampled' | 'traceid'>>,
124+
SpanContext?: Pick<SpanContext, Exclude<keyof SpanContext, 'spanId' | 'sampled' | 'traceid'>>,
125125
): Span | undefined {
126126
const matches = traceparent.match(TRACEPARENT_REGEXP);
127127
if (matches) {
@@ -133,7 +133,7 @@ export class Span implements SpanInterface, SpanProps {
133133
}
134134

135135
return new Span({
136-
...spanProps,
136+
...SpanContext,
137137
parentSpanId: matches[2],
138138
sampled,
139139
traceId: matches[1],

packages/types/src/hub.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Event, EventHint } from './event';
44
import { Integration, IntegrationClass } from './integration';
55
import { Scope } from './scope';
66
import { Severity } from './severity';
7-
import { Span, SpanProps } from './span';
7+
import { Span, SpanContext } from './span';
88
import { User } from './user';
99

1010
/**
@@ -173,7 +173,7 @@ export interface Hub {
173173
traceHeaders(): { [key: string]: string };
174174

175175
/** JSDoc */
176-
startSpan(spanProps?: SpanProps): Span;
176+
startSpan(SpanContext?: SpanContext): Span;
177177

178178
/** JSDoc */
179179
finishSpan(span: Span): string | undefined;

packages/types/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export { Response } from './response';
1616
export { Scope } from './scope';
1717
export { SdkInfo } from './sdkinfo';
1818
export { Severity } from './severity';
19-
export { Span, SpanProps } from './span';
19+
export { Span, SpanContext } from './span';
2020
export { StackFrame } from './stackframe';
2121
export { Stacktrace } from './stacktrace';
2222
export { Status } from './status';

packages/types/src/span.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface Span {
99
}
1010

1111
/** JSDoc */
12-
export interface SpanProps {
12+
export interface SpanContext {
1313
description?: string;
1414
op?: string;
1515
parentSpanId?: string;

0 commit comments

Comments
 (0)