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

Operationid algo screws up sampling algo #160

Closed
MaxShehovtsov opened this issue Jan 21, 2016 · 2 comments
Closed

Operationid algo screws up sampling algo #160

MaxShehovtsov opened this issue Jan 21, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@MaxShehovtsov
Copy link

New algorithm for creating operationid produces 6 char strings (much shorter than it used to be with guids). This seems to screw up sampling algorithm (DJB hash) which seems to not work properly on short strings (bad distribution, 98+% of hashes have score <= 20, score should be equal to distribution)

This makes sampling work incorrectly.

Proposed solution is to fall back to original guids instead of 6 char ids or investigate a use of a different hash algorithm which works on short strings (NOTE - both .net and JSSDK should use the same algorithm as both can have sampling ON and should sample in/out the same users)

@SergeyKanzhelev
Copy link
Contributor

@vitalyf007 - ID is quite random. Can we change sampling algorithm to work fine on small strings?

@SergeyKanzhelev
Copy link
Contributor

The decision was to concat the same string to the desired length like this. PR: microsoft/ApplicationInsights-JS#117

getSamplingHashCode: function (input) {
        if (input == "") {
            return 0;
        }

        var desiredResultLength = 8;
        while (input.length < desiredResultLength){
            input = input.concat(input);
            input = input.substr(0, desiredResultLength);
        }

Unit tests:
["ss", 1179811869],
["kxi", 34202699],
["wr", 1281077591],
["ynehgfhyuiltaiqovbpyhpm", 2139623659],
["iaxxtklcw", 1941943012],
["hjwvqjiiwhoxrtsjma", 1824011880],
["rpiauyg", 251412007],
["jekvjvh", 9189387],
["hq", 1807146729],
["kgqxrftjhefkwlufcxibwjcy", 270215819],
["lkfc", 1228617029],
["skrnpybqqu", 223230949],
["px", 70671963],
["dtn", 904623389],
["nqfcxobaequ", 397313566],
["togxlt", 948170633],
["jvvdkhnahkaujxarkd", 1486894898],
["mcloukvkamiaqja", 56804453],
["ornuu", 1588005865],
["otodvlhtvu", 1544494884],
["uhpwhasnvmnykjkitla", 981289895],
["itbnryqnjcgpmfuckghqtg", 1481733713],
["wauetkdnivwlafbfhiedsfx", 2114415420],
["fniwmeidbvd", 508699380],
["vuwdgoxspstvj", 1821547235],
["y", 1406544563],
["pceqcixfb", 1282453766],
["aentke", 255756533],
["ni", 1696510239],
["lbwehevltlnl", 1466602040],
["ymxql", 1974582171],
["mvqbaosfuip", 1560556398],
["urmwofajwmmlornynglm", 701710403],
["buptyvonyacerrt", 1315240646],
["cxsqcnyieliatqnwc", 76148095],
["svvco", 1849105799],
["luwmjhwyt", 553630912],
["lisvmmug", 822987687],
["mmntilfbmxwuyij", 882214597],
["hqmyv", 1510970959],

@SergeyKanzhelev SergeyKanzhelev self-assigned this Jan 25, 2016
@AlexBulankou AlexBulankou added this to the 95 milestone Jan 26, 2016
TimothyMothra added a commit that referenced this issue Oct 25, 2019
Adding default config for customers to find easily. Addressing #156
TimothyMothra pushed a commit that referenced this issue Oct 25, 2019
Tests fail in coreclr framework (in build), as TelemetryCOnfiguration…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants