Skip to content

feat(v8/core): Remove span.attributes top level field #11378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2024
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
16 changes: 0 additions & 16 deletions packages/core/src/tracing/sentrySpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,6 @@ export class SentrySpan implements Span {
// This rule conflicts with another eslint rule :(
/* eslint-disable @typescript-eslint/member-ordering */

/**
* Attributes for the span.
* @deprecated Use `spanToJSON(span).atttributes` instead.
*/
public get attributes(): SpanAttributes {
return this._attributes;
}

/**
* Attributes for the span.
* @deprecated Use `setAttributes()` instead.
*/
public set attributes(attributes: SpanAttributes) {
this._attributes = attributes;
}

/**
* Timestamp in seconds (epoch time) indicating when the span started.
* @deprecated Use `spanToJSON()` instead.
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/tracing/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,12 @@ function _startTransaction(transactionContext: TransactionArguments): Transactio
const client = getClient();
const options: Partial<ClientOptions> = (client && client.getOptions()) || {};

const { name, parentSampled, attributes } = transactionContext;
const [sampled, sampleRate] = sampleSpan(options, {
name: transactionContext.name,
parentSampled: transactionContext.parentSampled,
name,
parentSampled,
attributes,
transactionContext,
attributes: transactionContext.attributes,
});

// eslint-disable-next-line deprecation/deprecation
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/lib/tracing/transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('transaction', () => {
request: {},
});

expect(transaction.attributes).toEqual({
expect(spanToJSON(transaction).data).toEqual({
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'manual',
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'url',
[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: 0.5,
Expand Down
4 changes: 2 additions & 2 deletions packages/tracing-internal/src/browser/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function startTrackingInteractions(): void {
const startTime = msToSec((browserPerformanceTimeOrigin as number) + entry.startTime);
const duration = msToSec(entry.duration);

const spanOptions: StartSpanOptions = {
const spanOptions: StartSpanOptions & Required<Pick<StartSpanOptions, 'attributes'>> = {
name: htmlTreeAsString(entry.target),
op: `ui.interaction.${entry.name}`,
startTime: startTime,
Expand All @@ -121,7 +121,7 @@ export function startTrackingInteractions(): void {

const componentName = getComponentName(entry.target);
if (componentName) {
spanOptions.attributes = { 'ui.component_name': componentName };
spanOptions.attributes['ui.component_name'] = componentName;
}

const span = startInactiveSpan(spanOptions);
Expand Down
8 changes: 1 addition & 7 deletions packages/types/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DynamicSamplingContext } from './envelope';
import type { MeasurementUnit } from './measurement';
import type { ExtractedNodeRequestData, WorkerLocation } from './misc';
import type { PolymorphicRequest } from './polymorphics';
import type { SentrySpanArguments, Span, SpanAttributes } from './span';
import type { SentrySpanArguments, Span } from './span';

/**
* Interface holding Transaction-specific properties
Expand Down Expand Up @@ -63,12 +63,6 @@ export interface Transaction extends Omit<TransactionArguments, 'name' | 'op' |
*/
startTimestamp: number;

/**
* Attributes for the transaction.
* @deprecated Use `getSpanAttributes(transaction)` instead.
*/
attributes: SpanAttributes;

/**
* Metadata about the transaction.
* @deprecated Use attributes or store data on the scope instead.
Expand Down