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

ddtrace/tracer: add SetUser function and userTagOption #1196

Merged
merged 4 commits into from Mar 7, 2022

Conversation

Hellzy
Copy link
Contributor

@Hellzy Hellzy commented Mar 2, 2022

Identity monitoring

Summary

The purpose of this change is to add an SDK to allow tracer users to identify the user for a specific trace, i.e who made the request. To do so, we expose the SetUser function that is in charge of adding tags holding authenticated user information to the root span of a trace.
Said tags hold for example user name, e-mail address, permissions, etc...

RFC: https://docs.google.com/document/d/15dxIrx4D2BM3eUnLNCdMZjN4fQHlzISq31H6RiWRmIM

Changes

  • ddtrace/tracer/option.go: add UserMonitoringOption and several WithX functions to generate options for SetUser
  • ddtrace/tracer/tracer.go: add SetUser function that rewinds back to the root span of the trace and adds the tags provided as parameters
  • ddtrace/tracer/tracer_test.go: add TestUserMonitoring test to cover SetUser use case (root + nested spans cases)

@Hellzy Hellzy self-assigned this Mar 2, 2022
@Hellzy Hellzy force-pushed the francois.mazeau/user-monitoring-sdk branch from 89172ec to 33c9ba2 Compare March 2, 2022 14:49
ddtrace/tracer/option.go Outdated Show resolved Hide resolved
ddtrace/tracer/option.go Outdated Show resolved Hide resolved
ddtrace/tracer/tracer.go Outdated Show resolved Hide resolved
@Julio-Guerra Julio-Guerra added this to the 1.37.0 milestone Mar 3, 2022
@Julio-Guerra Julio-Guerra added tracer and removed appsec labels Mar 3, 2022
- Change UserTagOption to UserMonitoringOption
- Options now return a closure that sets the tag directly
- Improve comments
- SetUser new sets the tags even if span type assertion fails
@Hellzy Hellzy force-pushed the francois.mazeau/user-monitoring-sdk branch from 2cacd2c to 62a610e Compare March 3, 2022 10:34
@Hellzy Hellzy marked this pull request as ready for review March 3, 2022 16:23
@Hellzy Hellzy requested review from a team and Julio-Guerra March 3, 2022 16:23
Copy link
Contributor

@Julio-Guerra Julio-Guerra left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@Hellzy Hellzy merged commit 94d830e into v1 Mar 7, 2022
@Hellzy Hellzy deleted the francois.mazeau/user-monitoring-sdk branch March 7, 2022 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants