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

Add AKS resource provider in Statsbeat #1237

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions AutoCollection/Statsbeat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ class Statsbeat {
);
if (currentCounter.totalSuccesfulRequestCount > 0) {
this._statbeatMetrics.push({
name: Constants.StatsbeatCounter.REQUEST_SUCCESS,
value: currentCounter.totalSuccesfulRequestCount,
properties: properties
name: Constants.StatsbeatCounter.REQUEST_SUCCESS,
value: currentCounter.totalSuccesfulRequestCount,
properties: properties
});
currentCounter.totalSuccesfulRequestCount = 0; //Reset
}
Expand Down Expand Up @@ -385,7 +385,11 @@ class Statsbeat {
let waiting: boolean = false;
this._resourceProvider = Constants.StatsbeatResourceProvider.unknown;
this._resourceIdentifier = Constants.StatsbeatResourceProvider.unknown;
if (process.env.WEBSITE_SITE_NAME) { // Web apps
if (process.env.AKS_ARM_NAMESPACE_ID) {//AKS
this._resourceProvider = Constants.StatsbeatResourceProvider.aks;
this._resourceIdentifier = process.env.AKS_ARM_NAMESPACE_ID;
}
else if (process.env.WEBSITE_SITE_NAME) { // Web apps
this._resourceProvider = Constants.StatsbeatResourceProvider.appsvc;
this._resourceIdentifier = process.env.WEBSITE_SITE_NAME;
if (process.env.WEBSITE_HOME_STAMPNAME) {
Expand Down
1 change: 1 addition & 0 deletions Declarations/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const StatsbeatTelemetryName = "Statsbeat";

export const StatsbeatResourceProvider = {
appsvc: "appsvc",
aks: "aks",
functions: "functions",
vm: "vm",
unknown: "unknown"
Expand Down
13 changes: 13 additions & 0 deletions Tests/AutoCollection/Statsbeat.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ describe("AutoCollection/Statsbeat", () => {
done();
}).catch((error) => { done(error); });
});

it("aks", (done) => {
var newEnv = <{ [id: string]: string }>{};
newEnv["AKS_ARM_NAMESPACE_ID"] = "Test AKS cluster and namespace";
var originalEnv = process.env;
process.env = newEnv;
statsBeat["_getResourceProvider"]().then(() => {
process.env = originalEnv;
assert.equal(statsBeat["_resourceProvider"], "aks");
assert.equal(statsBeat["_resourceIdentifier"], "Test AKS cluster and namespace");
done();
}).catch((error) => { done(error); });
});
});

describe("#trackStatbeats", () => {
Expand Down
Loading