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

WIP. Add a new Anonymizer adjuster #29

Closed
wants to merge 2 commits into from

Conversation

kwojcik
Copy link

@kwojcik kwojcik commented Dec 31, 2016

Initial prototype of the semantics of an Anonymizer adjuster, which will make it easy to include anonymized production traces for test suites in public repos.

@CLAassistant
Copy link

CLAassistant commented Dec 31, 2016

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 99.556% when pulling 1118b21 on kwojcik:anonymizer into 8048d63 on uber:master.

// This allows real production traces to safely be kept in public repositories for use in test
// suites, after anonymization.
//
// A custom mapping is provided that dictates how to anonymize data. If a value is encountered that
Copy link
Member

Choose a reason for hiding this comment

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

rm one "that"

//
// An example of a mapping:
//var mapping = AnonymizerMapping{
// adjuster.AnonymizedService: {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than providing a fixed mapping, another option is to provide a naming pattern like "service-%03d" that can be used to generate the replacement values (internally it can keep a map to ensure the same service name is mapped to the same replacement value). For even more flexibility, this can be a function that takes the original value and returns the replacement value.

Also, rather than passing this as a map, I would probably define a struct with public fields. In fact, that struct itself can be the anonymizer by implementing the Adjuster interface, e.g.

a := &adjuster.Anonymizer{
    ServiceName: CountingStringMapper("service-%03d"),
}

func CountingStringMapper(pattern string) func(in string) string {
  values := make(map[string]string)
  return func(in string) string {
    if out, ok := values[in]; ok {
        return out
    }
    out := fmt.Sprintf(pattern, len(values))
    values[in] = out
    return out
  }
}

Note - if you go with this approach, you may want to move this to a sub-package. In fact, in order to even use this adjuster you need some way to retrieve the trace, so perhaps it should be a standalone util under /cmd/anonymizer that reads/writes JSON.

Copy link
Author

Choose a reason for hiding this comment

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

I'm ok with having an Anonymizer struct.

The reason why I had it as an explicit mapping is so that it can be consistent across multiple traces, meaning if trace1 has services foo and bar and trace2 has services bar, then bar would be anonymized to service2 in both traces. Thinking about it now, I'm not sure if that really matters or not from the programmer's point of view. It certainly does reduce the effectiveness of anonymization, though, so maybe it's not such a great idea.

I do agree that there will need to be a standalone binary for convenience.

@yurishkuro
Copy link
Member

@kwojcik do we need this?

@yurishkuro
Copy link
Member

Implemented in these PRs:
008772e - [anonymizer] Save trace in UI format (#2629) (3 months ago)
1d22aaf - Implement anonymizer's main program (#2621) (4 months ago)
76b8fba - Extend anonymizer with additional parameters (#2585) (4 months ago)
5001225 - Add trace anonymizer prorotype (#2328) (8 months ago)

@yurishkuro yurishkuro closed this Feb 25, 2021
@jpkrohling jpkrohling added this to the Release 1.23.0 milestone Jun 4, 2021
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.

5 participants