-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add response time profiling code, add response time profiling to /pro…
…jects (#222) * add response time profiling code, add profile to /projects * add profiling api endpoint * remove report name assignment from startTimeRecord method * remove explicit return from startRimeRecord method * bump version -> v1.0.17
- Loading branch information
Showing
12 changed files
with
4,265 additions
and
5,680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
GA_TRACKING_ID="UA-123456789-0" | ||
GATSBY_API_ENDPOINT="https://pub-api-test.azurewebsites.net/api" | ||
GATSBY_PROFILING_API_ENDPOINT="https://pub-profiler-collector-test.azurewebsites.net" | ||
BUILD_PATH_PREFIX="/" | ||
BUILD_SITE_URL="https://projectunicorn-next.surge.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
GATSBY_API_ENDPOINT="https://pub-api.azurewebsites.net/api" | ||
GATSBY_PROFILING_API_ENDPOINT="https://pub-profiler-collector.azurewebsites.net" | ||
BUILD_PATH_PREFIX="/" | ||
BUILD_SITE_URL="https://projectunicorn.net" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export * from './types'; | ||
export * from './api-service'; | ||
export * from './auth-service'; | ||
export * from './profiling-service'; | ||
export * from './http-client'; | ||
export * from './service-resolver'; | ||
export * from './stack-exchange-service'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { HttpClient } from './http-client'; | ||
|
||
export interface ProfilingReport { | ||
name: string; | ||
value: number; | ||
additionalInfo: string; | ||
} | ||
|
||
export class ProfilingService { | ||
private headers = { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json; charset=utf-8', | ||
}; | ||
|
||
private apiEndpoint: string; | ||
|
||
public constructor() { | ||
this.apiEndpoint = process.env.GATSBY_PROFILING_API_ENDPOINT || ''; | ||
} | ||
|
||
public async sendReport(report: ProfilingReport) { | ||
return await HttpClient.post( | ||
`${this.apiEndpoint}/report`, | ||
this.headers, | ||
report, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export * from './responses'; | ||
export * from './mock-api-service'; | ||
export * from './mock-auth-service'; | ||
export * from './mock-profiling-service'; | ||
export * from './mock-stack-exchange-service'; | ||
export * from './mock-theme-provider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ProfilingReport } from '@api/profiling-service'; | ||
|
||
export class MockProfilingService { | ||
public sendReport(report: ProfilingReport) { | ||
return report; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* general profiling utility class to | ||
* measure and report application performance | ||
* based on report identifier - 'reportName' | ||
*/ | ||
import { ProfilingReport, ProfilingService } from '@api/profiling-service'; | ||
import { ServiceResolver } from '@api'; | ||
import { MockProfilingService } from '@mocks'; | ||
|
||
export class ProfilingUtils { | ||
private startTime: number; | ||
private endTime: number; | ||
private reportName: string; | ||
private additionalReportInfo: string; | ||
private profilingService: MockProfilingService | ProfilingService; | ||
|
||
constructor(reportName: string, additionalReportInfo: string) { | ||
this.startTime = 0; | ||
this.endTime = 0; | ||
this.reportName = reportName; | ||
this.additionalReportInfo = additionalReportInfo; | ||
this.profilingService = ServiceResolver.profilingResolver(); | ||
} | ||
|
||
public startTimeRecord(): void { | ||
this.startTime = Date.now(); | ||
} | ||
|
||
public endTimeRecord(): void { | ||
this.endTime = Date.now(); | ||
const elapsedTime = this.endTime - this.startTime; | ||
const report: ProfilingReport = { | ||
name: this.reportName, | ||
value: elapsedTime, | ||
additionalInfo: this.additionalReportInfo, | ||
}; | ||
|
||
this.sendReport(report); | ||
} | ||
|
||
private sendReport(report: ProfilingReport) { | ||
this.profilingService.sendReport(report); | ||
} | ||
} |