summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/telemetry/application_name_find.js
blob: 35b86a95f53dfd0f246a0f51c4397a5e5548ab3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
 * Test that applicationName and namespace appear in telemetry for the find command.
 * @tags: [featureFlagTelemetry]
 */
load("jstests/libs/telemetry_utils.js");
(function() {
"use strict";

const kApplicationName = "MongoDB Shell";
const kHashedCollName = "w6Ax20mVkbJu4wQWAMjL8Sl+DfXAr2Zqdc3kJRB7Oo0=";
const kHashedFieldName = "lU7Z0mLRPRUL+RfAD5jhYPRRpXBsZBxS/20EzDwfOG4=";

// Turn on the collecting of telemetry metrics.
let options = {
    setParameter: {internalQueryConfigureTelemetrySamplingRate: -1},
};

const conn = MongoRunner.runMongod(options);
conn.setLogLevel(3, "query");
const testDB = conn.getDB('test');
var coll = testDB[jsTestName()];
coll.drop();

coll.insert({v: 1});
coll.insert({v: 2});
coll.insert({v: 3});

coll.find({v: 1}).toArray();

let telemetry = getTelemetry(conn);
assert.eq(1, telemetry.length, telemetry);
assert.eq(kApplicationName, telemetry[0].key.applicationName, telemetry);

telemetry = getTelemetryRedacted(conn, true);
assert.eq(1, telemetry.length, telemetry);
assert.eq(kApplicationName, telemetry[0].key.applicationName, telemetry);

MongoRunner.stopMongod(conn);
}());