Skip to content

Commit

Permalink
Add performance.mark and performance.measure for performance browser …
Browse files Browse the repository at this point in the history
…tool integration #617
  • Loading branch information
MSNev committed Aug 11, 2021
1 parent 2b5b2fc commit c2ea4e8
Show file tree
Hide file tree
Showing 22 changed files with 3,525 additions and 19 deletions.
92 changes: 74 additions & 18 deletions common/config/rush/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions extensions/applicationinsights-perfmarkmeasure-js/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# NPM Ignore

# ignore everything
*

# ... but these files
!package.json
!tsconfig.json
!/README.md
!/LICENSE
!dist-esm/**
!dist/**
!browser/**
!types/**
!src/**
21 changes: 21 additions & 0 deletions extensions/applicationinsights-perfmarkmeasure-js/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
84 changes: 84 additions & 0 deletions extensions/applicationinsights-perfmarkmeasure-js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Microsoft Application Insights JavaScript SDK - Performance Mark and Measure Plugin

[![npm version](https://badge.fury.io/js/%40microsoft%2Fapplicationinsights-perfmarkmeasure-js.svg)](https://badge.fury.io/js/%40microsoft%2Fapplicationinsights-perfmarkmeasure-js)

Performance Mark and Measure Manager Plugin for the Application Insights Javascript SDK is a replacement for the default Performance manager to
use the ```window.performance```, ```mark``` and ```measure``` api calls for the browsers.

It is intended that this plugin is to be used during development/testing only as enabling performance monitoring can affect the performance of the system.
And there is a limit on the number of performance events that browsers will retain.

## Getting Started

## NPM Setup (ignore if using Snippet Setup)

Install npm package:

```bash
npm install --save @microsoft/applicationinsights-applicationinsights-perfmarkmeasure-js @microsoft/applicationinsights-web
```

```js

import { ApplicationInsights } from '@microsoft/applicationinsights-web';
import { PerfMarkMeasureManager } from '@microsoft/applicationinsights-applicationinsights-perfmarkmeasure-js';

const perfManager = new PerfMarkMeasureManager();

// Application Insights Configuration
const configObj = {
instrumentationKey: "YOUR INSTRUMENTATION KEY",
};

const appInsights = new ApplicationInsights({ config: configObj });
appInsights.loadAppInsights();
appInsights.core.setPerfMgr(perfManager);
```

## Configuration Options

All of the configuration options are optional

### IPerfMarkMeasureConfiguration {

| Name | Type | Description
|------|-----------|--------------------
| useMarks | boolean | Should the Performance manager create and user window.performance.mark(), defaults to true
| markPrefix | string | Identifies the prefix for the mark, defaults to "ai.prfmrk.", the event name is appended for the mark
| uniqueNames | boolean | Make the marks and measures unique by appending a numeric value to the prefix value, defaults to false. Marks and measure for the same perfEvent will be assigned the same unique numeric value
| markNameMap | { [key: string]: string } | Provides a mapping between the internal perf names and the value used to create the mark, when a map is provided but no mapping is present that event will be ignored.
| useEndMarks | boolean | Should the Performance manager create a mark when the event is fired, defaults to false
| markEndPrefix | string | Identifies the prefix for the "end" mark of a perf event, defaults to "ai.prfmrk.end.", the event name is appended for the mark
| useMeasures | boolean | Should the Performance manager create and user window.performance.measure(), defaults to true
| measurePrefix | string | Identifies the prefix for the mark, defaults to "ai.prfmsr.", the event name is appended for the measure name
| measureNameMap | { [key: string]: string } | Provides a mapping between the internal perf names and the value used to create the measure, when no measureNameMap is provided this will default to using the markNameMap and when a map is provided but no mapping is present that event will be ignored.

## Build:
```
npm install -g grunt-cli
npm install
npm run build --silent
```

## Run unit tests:
```
npm run test
```

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## License

[MIT](LICENSE)
Loading

0 comments on commit c2ea4e8

Please sign in to comment.