Skip to content

Enable attributes on the session, and send as span attributes on replay#1313

Merged
waltjones merged 2 commits into
masterfrom
waltjones/session-attributes
Sep 18, 2025
Merged

Enable attributes on the session, and send as span attributes on replay#1313
waltjones merged 2 commits into
masterfrom
waltjones/session-attributes

Conversation

@waltjones

Copy link
Copy Markdown
Contributor

Description of the change

Enables attributes on the session instance, and updates the recorder to add session attributes to the replay span as span attributes.

Type of change

  • New feature (non-breaking change that adds functionality)

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

@matux matux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Beautiful

Comment thread src/tracing/session.js
return this.#attributes;
}

setAttributes(attributes) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: I think you can do set attributes here too, instead of making a function.

non-blocking

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The semantics are different. This method doesn't replace attributes, so I don't want code that looks like attributes =.

I'm considering updateAttributes.

expect(mockSpan.setAttribute.calledOnce).to.be.true;
expect(mockSpan.setAttribute.calledWith('rollbar.replay.id', testReplayId)).to.be.true;
expect(mockSpan.setAttributes.calledOnce).to.be.true;
expect(mockSpan.setAttributes.calledWith({'rollbar.replay.id': testReplayId})).to.be.true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, but how do you test it if you use the set keyword instead of making a setAttributes function?

@waltjones waltjones merged commit e5d010a into master Sep 18, 2025
4 checks passed
@waltjones waltjones deleted the waltjones/session-attributes branch September 18, 2025 20:00
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.

2 participants