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

Adding StatsBeat implementation #792

Merged
merged 10 commits into from
Jul 23, 2021
Merged

Adding StatsBeat implementation #792

merged 10 commits into from
Jul 23, 2021

Conversation

hectorhdzg
Copy link
Member

No description provided.

AutoCollection/StatsBeat.ts Outdated Show resolved Hide resolved
AutoCollection/StatsBeat.ts Outdated Show resolved Hide resolved
AutoCollection/StatsBeat.ts Outdated Show resolved Hide resolved
AutoCollection/StatsBeat.ts Outdated Show resolved Hide resolved
private _totalSuccesfulRequestCount: number = 0;
private _totalFailedRequestCount: number = 0;
private _retryCount: number = 0;
private _exceptionCount: number = 0;
Copy link

Choose a reason for hiding this comment

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

how does node.js handle multiple threading? these availables are needed to be thread-safe?

Copy link
Member Author

Choose a reason for hiding this comment

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

No need to worry about multiple threads in Javascript, this values must be good and counts will be associated by specific Telemetry Clients

AutoCollection/diagnostic-channel/azure-coretracing.sub.ts Outdated Show resolved Hide resolved
Declarations/Constants.ts Outdated Show resolved Hide resolved
}

export enum StatsBeatInstrumentation {
Copy link

@heyams heyams Jul 15, 2021

Choose a reason for hiding this comment

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

i would like to see how you can decode the long back to string on the kusto side? i guess you will have another map for the string -> 2 to the power of x.
Please add a test for encoding and decoding so that i have a rough idea how it looks like in kusto.

Copy link

Choose a reason for hiding this comment

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

you might also consider when it's exceeding 64 bits, a new enum will be required? java has BitSet which can hold more than 64 bits.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have around 8 instrumentations currently so we must be good, I believe signed number used by bitwise operations in JS is only 32 bits


class AzureVirtualMachine {

public isVM: boolean;
Copy link

Choose a reason for hiding this comment

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

how do you keep this running every 15 mins when it's from VM?

Copy link
Member Author

Choose a reason for hiding this comment

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

I assumed VM info is never updated during runtime, I will update so meta data request is made each time Statsbeat or Heartbeat need the info

Library/AzureVirtualMachine.ts Show resolved Hide resolved
@heyams
Copy link

heyams commented Jul 15, 2021

how does the config look like for statsbeat?
this is for Java:

"internal": {
"statsbeat": {
"instrumentationKey": "315e5083-0044-4134-93e7-55393d71a6c3",
"endpoint": "https://dc.services.visualstudio.com",
"intervalSeconds": 30, // default is 15 mins for network and attach statsbeat
"featureIntervalSeconds": 30 // default is 24 hours for feature statsbeat
}
},

AutoCollection/StatsBeat.ts Outdated Show resolved Hide resolved
@hectorhdzg
Copy link
Member Author

@heyams for Statsbeat here there is no configuration file available, everything is set as attributes or constants in Statsbeat class

AutoCollection/StatsBeat.ts Outdated Show resolved Hide resolved
@hectorhdzg hectorhdzg marked this pull request as ready for review July 22, 2021 04:20
AutoCollection/Statsbeat.ts Outdated Show resolved Hide resolved
private _getResourceProvider(callback: () => void) {
// Check resource provider
let waiting: boolean = false;
if (process.env.WEBSITE_SITE_NAME) { // Web apps
Copy link

Choose a reason for hiding this comment

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

where is rpId? I didn't find it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought rpId only exist in "attach" Statsbeat, this PR is only adding network Statbeats will add attach and feature in different PR

Copy link

Choose a reason for hiding this comment

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

yes, rpid is part of attach statsbeat.

value: this._statbeatMetrics[i].value,
properties: properties
};
let envelope = EnvelopeFactory.createEnvelope(statsbeat, Contracts.TelemetryType.Metric, null, null, this._statsbeatConfig);
Copy link

Choose a reason for hiding this comment

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

it looks like config is used to store statsbeat connection string only. can you just pass the connection string to createEnvelop? unless you will parse connection string from the json config file later?

Copy link
Member Author

Choose a reason for hiding this comment

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

We are using same mechanism as other envelopes created in the SDK, I'm trying to avoid specific code paths just for Statbeat here, added connection string as static so it could be updated if we add JSON config later

if (enabled) {
if (clients.length === 0) {
channel.subscribe<any>("azure-coretracing", subscriber);
if (statsbeat) {
statsbeat.addInstrumentation(StatsbeatInstrumentation.AZURE_CORE_TRACING);
Copy link

Choose a reason for hiding this comment

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

never mind about the other comment about instrumentation.. i think name is a good indicate what each number is for.

this._isInitialized = false;
this._statbeatMetrics = [];
this._config = config;
this._statsbeatConfig = new Config(STATSBEAT_CONNECTIONSTRING);
Copy link

Choose a reason for hiding this comment

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

it would be nice if you can get statsbeatConnectionString from the input parameter Config, then you can add statsbeat test to the e2e testing suite :)

Copy link

Choose a reason for hiding this comment

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

maybe add a todo for later if you like.

Copy link
Member Author

Choose a reason for hiding this comment

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

I created a task for that, current there is no way to configure in attach scenarios but it would be great to have something available

Tests/AutoCollection/Statsbeat.tests.ts Outdated Show resolved Hide resolved
Copy link

@heyams heyams left a comment

Choose a reason for hiding this comment

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

please exclude feature from the network payload. other than that, it looks good to me.

@hectorhdzg hectorhdzg merged commit 415c952 into develop Jul 23, 2021
hectorhdzg added a commit that referenced this pull request Jul 23, 2021
hectorhdzg added a commit that referenced this pull request Jul 23, 2021
hectorhdzg added a commit that referenced this pull request Jul 23, 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.

None yet

3 participants