Skip to content

Commit

Permalink
Add deployment correlation ID (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenWeatherford authored Mar 8, 2018
1 parent ef2ba99 commit 437caae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/explorer/SiteTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import WebSiteManagementClient = require('azure-arm-website');
import * as WebSiteModels from 'azure-arm-website/lib/models';
import { randomBytes } from 'crypto';
import * as fse from 'fs-extra';
import * as opn from 'opn';
import * as path from 'path';
Expand Down Expand Up @@ -116,6 +117,9 @@ export abstract class SiteTreeItem implements IAzureParentTreeItem {
confirmDeployment: boolean = true,
telemetryProperties: TelemetryProperties
): Promise<void> {
const correlationId = getRandomHexString(10);
telemetryProperties.correlationId = correlationId;

const workspaceConfig: WorkspaceConfiguration = workspace.getConfiguration(constants.extensionPrefix, Uri.file(fsPath));
if (workspaceConfig.get(constants.configurationSettings.showBuildDuringDeployPrompt)) {
const siteConfig: WebSiteModels.SiteConfigResource = await this.siteWrapper.getSiteConfig(client);
Expand All @@ -129,7 +133,7 @@ export abstract class SiteTreeItem implements IAzureParentTreeItem {
await this.siteWrapper.deploy(fsPath, client, outputChannel, configurationSectionName, confirmDeployment, telemetryProperties);

// Don't wait
validateWebSite(this, outputChannel, telemetryReporter).then(
validateWebSite(correlationId, this, outputChannel, telemetryReporter).then(
() => {
// ignore
},
Expand Down Expand Up @@ -175,3 +179,8 @@ export async function getAppServicePlan(site: WebSiteModels.Site, client: WebSit
const serverFarmId = util.parseAzureResourceId(site.serverFarmId.toLowerCase());
return await client.appServicePlans.get(serverFarmId.resourcegroups, serverFarmId.serverfarms);
}

function getRandomHexString(length: number): string {
const buffer: Buffer = randomBytes(Math.ceil(length / 2));
return buffer.toString('hex').slice(0, length);
}
4 changes: 3 additions & 1 deletion src/validateWebSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type WebError = {
interface IValidateProperties {
statusCodes?: string; // [[code,elapsedSeconds], [code,elapsedSeconds]...]
canceled?: 'true' | 'false';
correlationId?: string;
}

const initialPollingIntervalMs = 5000;
Expand All @@ -44,7 +45,7 @@ export function cancelWebsiteValidation(siteTreeItem: SiteTreeItem): void {
}
}

export async function validateWebSite(siteTreeItem: SiteTreeItem, outputChannel: OutputChannel, telemetryReporter: TelemetryReporter): Promise<void> {
export async function validateWebSite(deploymentCorelationId: string, siteTreeItem: SiteTreeItem, outputChannel: OutputChannel, telemetryReporter: TelemetryReporter): Promise<void> {
cancelWebsiteValidation(siteTreeItem);
const id = siteTreeItem.id;
const cancellation: ICancellation = { canceled: false };
Expand All @@ -55,6 +56,7 @@ export async function validateWebSite(siteTreeItem: SiteTreeItem, outputChannel:
this.suppressErrorDisplay = true;

const properties = <IValidateProperties>this.properties;
properties.correlationId = deploymentCorelationId;

let pollingIntervalMs = initialPollingIntervalMs;
const start = Date.now();
Expand Down

0 comments on commit 437caae

Please sign in to comment.