Skip to content
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

feat(tracing): Add transaction.setContext method #6154

Merged
merged 4 commits into from Nov 8, 2022

Conversation

AbhiPrasad
Copy link
Member

This is needed for the OpenTelemetry Span Processor. Same behaviour as scope.setContext here:

/**
* @inheritDoc
*/
public setContext(key: string, context: Context | null): this {
if (context === null) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete this._contexts[key];
} else {
this._contexts = { ...this._contexts, [key]: context };
}
this._notifyScopeListeners();
return this;
}

One thing to note, we don't want users to override trace context, so we set that here.

This is needed for the OpenTelemetry Span Processor.
@AbhiPrasad AbhiPrasad requested a review from mydea November 8, 2022 14:11
@AbhiPrasad AbhiPrasad self-assigned this Nov 8, 2022
@AbhiPrasad AbhiPrasad changed the title feat(tracing): Add transaction.setContext method feat(tracing): Add transaction.setContext method Nov 8, 2022
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete this._contexts[key];
} else {
this._contexts = { ...this._contexts, [key]: context };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: Is it important to make this a new object every time? Or could we just do:

this._contexts[key] = context;

? To avoid re-creating objects when we don't really need to do so.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this from

/**
* @inheritDoc
*/
public setContext(key: string, context: Context | null): this {
if (context === null) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete this._contexts[key];
} else {
this._contexts = { ...this._contexts, [key]: context };
}
this._notifyScopeListeners();
return this;
}

I agree though, will change. Perhaps we can update the scope file as well then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense as well 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.5 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 60.37 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.15 KB (+0.02% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 53.71 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.89 KB (0%)
@sentry/browser - Webpack (minified) 65.12 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.92 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 45.9 KB (+0.05% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.32 KB (+0.11% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.73 KB (+0.12% 🔺)

Copy link
Member

@mydea mydea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! When this is merged I can adjust the SpanProcessor to use this.

@AbhiPrasad AbhiPrasad merged commit 1e23e90 into master Nov 8, 2022
@AbhiPrasad AbhiPrasad deleted the abhi-transaction-set-context branch November 8, 2022 15:32
@AbhiPrasad AbhiPrasad added this to the OpenTelemetry Support milestone Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants