-
Notifications
You must be signed in to change notification settings - Fork 4
Option to pass a bucket size for the httpRequestsDuration #2
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
Open
gustavomassa
wants to merge
11
commits into
rocklan:master
Choose a base branch
from
movidesk:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b0e39ff
Using constructors to be able to pass a bucket size value for the his…
gustavomassa d8d8f43
Atualizado packages
epmallmann 6bc5fa1
Atualizando informações para deploy
gustavomassa 23299db
Merge pull request #2 from movidesk/BEH-1731-update-packages
epmallmann 2f88f1a
BEH-1731 Alterado versao
epmallmann 171a025
versao do nuget
epmallmann 6b9e085
Update readme.md
epmallmann 3c4eb3f
Update readme.md
epmallmann 11d7f26
[MOV-1031] Alteração do pacote para o formato packagereference (#3)
ReinaldoMT bf8d1fe
fix: correção nas versões da lib e dependências (#4)
ReinaldoMT 39c6e25
refact: framwork and prometheus-net compatible version (#5)
ReinaldoMT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -9,24 +9,83 @@ namespace Prometheus.AspNet | |
| /// </summary> | ||
| public class PrometheusHttpRequestModule : IHttpModule | ||
| { | ||
| private static readonly Counter _globalExceptions = Metrics | ||
| .CreateCounter("global_exceptions", "Number of global exceptions."); | ||
| private static Counter _globalExceptions; | ||
| private static Gauge _httpRequestsInProgress; | ||
| private static Gauge _httpRequestsTotal; | ||
| private static Histogram _httpRequestsDuration; | ||
| private const string _timerKey = "PrometheusHttpRequestModule.Timer"; | ||
|
|
||
| private static readonly Gauge _httpRequestsInProgress = Metrics | ||
| .CreateGauge("http_requests_in_progress", "The number of HTTP requests currently in progress"); | ||
| /// <summary> | ||
| /// | ||
| /// </summary> | ||
| public PrometheusHttpRequestModule() | ||
| { | ||
| if (_globalExceptions == null) | ||
| { | ||
| _globalExceptions = Metrics | ||
| .CreateCounter("global_exceptions", "Number of global exceptions."); | ||
| } | ||
|
|
||
| private static readonly Gauge _httpRequestsTotal = Metrics | ||
| .CreateGauge("http_requests_received_total", "Provides the count of HTTP requests that have been processed by this app", | ||
| new GaugeConfiguration { LabelNames = new[] { "code", "method", "controller", "action" } }); | ||
| if (_httpRequestsInProgress == null) | ||
| { | ||
| _httpRequestsInProgress = Metrics | ||
| .CreateGauge("http_requests_in_progress", "The number of HTTP requests currently in progress"); | ||
| } | ||
|
|
||
| private static readonly Histogram _httpRequestsDuration = Metrics | ||
| .CreateHistogram("http_request_duration_seconds", "The duration of HTTP requests processed by this app.", | ||
| new HistogramConfiguration { LabelNames = new[] { "code", "method", "controller", "action" } }); | ||
| if (_httpRequestsTotal == null) | ||
| { | ||
| _httpRequestsTotal = Metrics | ||
| .CreateGauge("http_requests_received_total", "Provides the count of HTTP requests that have been processed by this app", | ||
| new GaugeConfiguration {LabelNames = new[] {"code", "method", "controller", "action"}}); | ||
| } | ||
|
|
||
| private const string _timerKey = "PrometheusHttpRequestModule.Timer"; | ||
| if (_httpRequestsDuration == null) | ||
| { | ||
| _httpRequestsDuration = Metrics | ||
| .CreateHistogram("http_request_duration_seconds", "The duration of HTTP requests processed by this app.", | ||
| new HistogramConfiguration {LabelNames = new[] {"code", "method", "controller", "action"}}); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// </summary> | ||
| /// <param name="bucektSize"></param> | ||
| public PrometheusHttpRequestModule(double[] bucektSize) | ||
| { | ||
| if (_globalExceptions == null) | ||
| { | ||
| _globalExceptions = Metrics | ||
| .CreateCounter("global_exceptions", "Number of global exceptions."); | ||
| } | ||
|
|
||
| if (_httpRequestsInProgress == null) | ||
| { | ||
| _httpRequestsInProgress = Metrics | ||
| .CreateGauge("http_requests_in_progress", "The number of HTTP requests currently in progress"); | ||
| } | ||
|
|
||
| if (_httpRequestsTotal == null) | ||
| { | ||
| _httpRequestsTotal = Metrics | ||
| .CreateGauge("http_requests_received_total", "Provides the count of HTTP requests that have been processed by this app", | ||
| new GaugeConfiguration {LabelNames = new[] {"code", "method", "controller", "action"}}); | ||
| } | ||
|
|
||
| if (_httpRequestsDuration == null) | ||
| { | ||
| _httpRequestsDuration = Metrics | ||
| .CreateHistogram("http_request_duration_seconds", "The duration of HTTP requests processed by this app.", | ||
| new HistogramConfiguration | ||
| { | ||
| LabelNames = new[] {"code", "method", "controller", "action"}, | ||
| Buckets = bucektSize | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// | ||
| /// </summary> | ||
| /// <param name="httpApp"></param> | ||
| public void Init(HttpApplication httpApp) | ||
|
|
@@ -42,12 +101,12 @@ private void HttpApp_Error(object sender, EventArgs e) | |
| } | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// | ||
| /// </summary> | ||
| /// <param name="sender"></param> | ||
| /// <param name="e"></param> | ||
| // Record the time of the begin request event. | ||
| public void OnBeginRequest(Object sender, EventArgs e) | ||
| private void OnBeginRequest(Object sender, EventArgs e) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason to change this to private? |
||
| { | ||
| _httpRequestsInProgress.Inc(); | ||
|
|
||
|
|
@@ -58,11 +117,11 @@ public void OnBeginRequest(Object sender, EventArgs e) | |
| } | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// | ||
| /// </summary> | ||
| /// <param name="sender"></param> | ||
| /// <param name="e"></param> | ||
| public void OnEndRequest(Object sender, EventArgs e) | ||
| private void OnEndRequest(Object sender, EventArgs e) | ||
| { | ||
| _httpRequestsInProgress.Dec(); | ||
|
|
||
|
|
@@ -98,9 +157,9 @@ public void OnEndRequest(Object sender, EventArgs e) | |
| } | ||
|
|
||
| /// <summary> | ||
| /// | ||
| /// | ||
| /// </summary> | ||
| public void Dispose() { /* Not needed */ } | ||
| } | ||
|
|
||
| } | ||
| } | ||
This file contains hidden or 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,70 +1,43 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
| <ProjectGuid>{D47CE1F2-949B-452E-B446-6A977C64F105}</ProjectGuid> | ||
| <OutputType>Library</OutputType> | ||
| <AppDesignerFolder>Properties</AppDesignerFolder> | ||
| <RootNamespace>prometheus.AspNet</RootNamespace> | ||
| <AssemblyName>prometheus.AspNet</AssemblyName> | ||
| <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> | ||
| <FileAlignment>512</FileAlignment> | ||
| <Deterministic>true</Deterministic> | ||
| <LangVersion>default</LangVersion> | ||
| <AssemblyTitle>Prometheus.AspNet</AssemblyTitle> | ||
| <Product>Prometheus.AspNet</Product> | ||
| <Description>Exposes prometheus metrics inside full framework asp.net applications using WebApi</Description> | ||
| <Copyright>Copyright 2022</Copyright> | ||
| <Version>4.2.0</Version> | ||
| <AssemblyVersion>4.2.0.0</AssemblyVersion> | ||
| <FileVersion>4.2.0.0</FileVersion> | ||
| <OutputPath>bin\$(Configuration)\</OutputPath> | ||
| <DocumentationFile>bin\$(Configuration)\prometheus.AspNet.xml</DocumentationFile> | ||
| <Authors>Lachlan Barclay</Authors> | ||
| <PackageIcon>prometheus-net-logo.png</PackageIcon> | ||
| <PackageId>movidesk-prometheus-net.AspNet</PackageId> | ||
| <RepositoryUrl>https://github.com/movidesk/prometheus-net.AspNet</RepositoryUrl> | ||
| <PackageTags>movidesk-prometheus-net.AspNet</PackageTags> | ||
| <TargetFrameworks>net471;net472;net48;net481</TargetFrameworks> | ||
| <PackageVersion>4.2.0</PackageVersion> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
| <DebugSymbols>true</DebugSymbols> | ||
| <DebugType>full</DebugType> | ||
| <Optimize>false</Optimize> | ||
| <OutputPath>bin\Debug\</OutputPath> | ||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | ||
| <ErrorReport>prompt</ErrorReport> | ||
| <WarningLevel>4</WarningLevel> | ||
| <DocumentationFile>bin\Debug\prometheus.AspNet.xml</DocumentationFile> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
| <DebugType>pdbonly</DebugType> | ||
| <Optimize>true</Optimize> | ||
| <OutputPath>bin\Release\</OutputPath> | ||
| <DefineConstants>TRACE</DefineConstants> | ||
| <ErrorReport>prompt</ErrorReport> | ||
| <WarningLevel>4</WarningLevel> | ||
| <DocumentationFile>bin\Release\prometheus.AspNet.xml</DocumentationFile> | ||
| <DebugType>portable</DebugType> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
| <HintPath>..\..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="Prometheus.NetStandard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a243e9817ba9d559, processorArchitecture=MSIL"> | ||
| <HintPath>..\..\packages\prometheus-net.3.1.0\lib\netstandard2.0\Prometheus.NetStandard.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="System" /> | ||
| <Reference Include="System.Core" /> | ||
| <Reference Include="System.Net.Http.Formatting, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
| <HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.0.0\lib\net45\System.Net.Http.Formatting.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="mscorlib" /> | ||
| <Reference Include="System.Web" /> | ||
| <Reference Include="System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> | ||
| <HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.0.0\lib\net45\System.Web.Http.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="System.Xml.Linq" /> | ||
| <Reference Include="System.Data.DataSetExtensions" /> | ||
| <Reference Include="Microsoft.CSharp" /> | ||
| <Reference Include="System.Data" /> | ||
| <Reference Include="System.Net.Http" /> | ||
| <Reference Include="System.Xml" /> | ||
| <None Include="../../prometheus-net-logo.png" Pack="true" PackagePath="\" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Compile Include="Classes\PrometheusHttpRequestModule.cs" /> | ||
| <Compile Include="Classes\PerformanceMonitorModule.cs" /> | ||
| <Compile Include="Classes\PrometheusConfig.cs" /> | ||
| <Compile Include="Classes\PrometheusMetricsController.cs" /> | ||
| <Compile Include="Properties\AssemblyInfo.cs" /> | ||
| <PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" /> | ||
| <PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.9" /> | ||
| <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
| <PackageReference Include="prometheus-net" Version="4.2.0" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <None Include="packages.config" /> | ||
| <None Include="prometheus.AspNet.nuspec" /> | ||
| </ItemGroup> | ||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
| </Project> |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,17 +1,17 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <configuration> | ||
| <configSections> | ||
| <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> | ||
| <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> | ||
|
|
||
| <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> | ||
| </configSections> | ||
| <entityFramework> | ||
| <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> | ||
| <parameters> | ||
| <parameter value="v13.0"/> | ||
| <parameter value="v13.0" /> | ||
| </parameters> | ||
| </defaultConnectionFactory> | ||
| <providers> | ||
| <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/> | ||
| <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> | ||
| </providers> | ||
| </entityFramework> | ||
| <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration> | ||
| <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /></startup></configuration> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change this constructor so that it looks like this:
Does that mean you don't need the other constructor at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Also, please fix the spelling mistake :)