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

Rephrasing documentation for clariry. #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
96 changes: 60 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,80 @@
# Dotnet Build Metrics

This is a custom MSBuild task that will measure the time to build each project and publishes the information to a datastore. The intent is to measure and improve developer experience on local workstations.
## Overview

**_Username and hostname are collected as a part of build information_**
Dotnet Build Metrics is an enhanced MSBuild task that measures the time to build each project and storing the information in a datastore.
It now includes additional functionalities, such as **monitoring web server startup time and collecting test data within the repository.**

```
{
"id": "026fe42b-7888-4a76-81ee-2ab431ae4987",
"userName": "aanand",
"cpuCount": 12,
"hostname": "25BVM13",
"platform": 2,
"os": "Microsoft Windows NT 10.0.19042.0",
"timeTaken": "453",
"branch": "master",
"type": ".Net",
"projectName": "Agoda.Cronos.Accommodation",
"repository": "git@github.xxxx.io:front-end/dotnet-build-metrics.git",
"date": "2021-06-28T02:53:22.1420552Z"
}
```
The objective is centered around measuring and improving the overall developer F5 experience on local workstations.

**_The tool collects username and hostname as a part of build information. [See example payload](#data-sent-to-the-datastore)_**

To use the task simply install the [`Agoda.Builds.Metrics` NuGet package](https://www.nuget.org/packages/Agoda.Builds.Metrics) to all of the projects in your solution, this will automatically enable metrics publication for that project.
## Installation

Web API URL and the name of the endpoint are taken from environment variables if they are present as per the following table:
To use the task, install the [Agoda.Builds.Metrics NuGet package](https://www.nuget.org/packages/Agoda.Builds.Metrics) to all projects in your solution. This will automatically enable metrics publication for that project.

|Parameter |Environment Variable |Default Value |
|-----------------------|-------------------------|-------------------------------------|
|Elastic Search Endpoint|BUILD_METRICS_ES_ENDPOINT|http://compilation-metrics/dotnet |
## Configuration

We recommend create a CNAME on your internal DNS servers for compilation-metrics to point at an internal API that captures the data and stores it.
Web API URL and the name of the endpoint are taken from environment variables. If they are present, they will override the defaults as per the following table:

Example build log output in Visual Studio using MSBuild.
| Parameter | Environment Variable | Default Value |
| --- | --- | --- |
| Elastic Search Endpoint | BUILD_METRICS_ES_ENDPOINT | http://compilation-metrics/dotnet |

We recommend creating a CNAME on your internal DNS servers for `compilation-metrics` to point at an internal API that captures the data and stores it.

## Example Output

### Visual Studio

Example build log output in Visual Studio using MSBuild:

![](doc/img/VSBuildOutput.PNG)

Example build log output in Dotnet core CLI.
### .NET Core CLI

Example build log output in .NET Core CLI:

![](doc/img/DotnetCLIBuildTimeOutput.PNG)

## Agoda.DevFeedback.AspNetStartup NuGet Package

### Agoda.DevFeedback.AspNetStartup NuGet package
### Overview

The goal of this package is to measure the application startup time as an additional metrics that affects developer feedback besides build time.
Monoliths are especially prone to slow startup times on developer laptops and this provides visibility and tracking of improvements/regressions thereof.
The goal of the Agoda.DevFeedback.AspNetStartup NuGet package is to measure the application startup time as an additional metric that affects developer feedback besides build time. Monoliths are especially prone to slow startup times on developer laptops, and this provides visibility and tracking of improvements/regressions thereof.

This package measures the ASP.NET application's startup time in two ways.
1) The time from WebHostBuilder ConfigureServices until HostApplicationLifetime OnStarted sent with type '.AspNetStartup'.
2) The time from WebHostBuilder ConfigureServices until the first HTTP Reponse (measured from middleware) sent with type '.AspNetResponse'.
### Measurement

Two environment variables are required to be set to enable the measurements.
1) `ASPNETCORE_ENVIRONMENT` needs to be set as `Development` for the functionality to be added. This is so it's only enabled locally and not on production.
2) `ASPNETCORE_HOSTINGSTARTUPASSEMBLIES` needs to be/include `Agoda.DevFeedback.AspNetStartup`. This is for package activation due to the use of [HostingStartup](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.hostingstartupattribute?view=aspnetcore-6.0).
This package measures the [ASP.NET](http://asp.net/) application's startup time in two ways:

For convenience these environment variables can be set under the lauch profile of the web application's `launchSettings.json` file and committed to the repository.
1. The time from WebHostBuilder ConfigureServices until HostApplicationLifetime OnStarted sent with type '.AspNetStartup'.
2. The time from WebHostBuilder ConfigureServices until the first HTTP Response (measured from middleware) sent with type '.AspNetResponse'.

### Configuration

Two environment variables are required to be set to enable measurements:

1. `ASPNETCORE_ENVIRONMENT` needs to be set as `Development` for the functionality to be added. This is so it's only enabled locally and not on production.
2. `ASPNETCORE_HOSTINGSTARTUPASSEMBLIES` needs to include `Agoda.DevFeedback.AspNetStartup`. This is for package activation due to the use of [HostingStartup](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.hostingstartupattribute?view=aspnetcore-6.0).

For convenience, these environment variables can be set under the launch profile of the web application's `launchSettings.json` file and committed to the repository.

### Data sent to the datastore
> This is an example payload sent to the datastore.

```
{
"id": "026fe42b-7888-4a76-81ee-2ab431ae4987",
"userName": "aanand",
"cpuCount": 12,
"hostname": "25BVM13",
"platform": 2,
"os": "Microsoft Windows NT 10.0.19042.0",
"timeTaken": "453",
"branch": "master",
"type": ".Net",
"projectName": "Agoda.Cronos.Accommodation",
"repository": "git@github.xxxx.io:front-end/dotnet-build-metrics.git",
"date": "2021-06-28T02:53:22.1420552Z"
}
```