Skip to content

Commit

Permalink
Merge pull request #25 from t1agob/develop
Browse files Browse the repository at this point in the history
Metrics: Added support for Attributes using Source Generators
  • Loading branch information
sliedig authored Sep 22, 2021
2 parents d9edb33 + 10ebdf5 commit 408bc45
Show file tree
Hide file tree
Showing 90 changed files with 183 additions and 23,196 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ docs/node_modules
docs/.cache
docs/public

.idea
.idea
.vscode

AWS.Lambda.Powertools.sln.DotSettings.user
[Oo]bj/**
[Bb]in/**
30 changes: 14 additions & 16 deletions examples/SimpleLambda/src/HelloWorld/Function.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Net.Http;

using Amazon.Lambda.Core;
using Amazon.Lambda.APIGatewayEvents;

Expand All @@ -14,12 +12,10 @@

namespace HelloWorld
{
public class Function
public partial class Function
{
private static readonly HttpClient client = new HttpClient();

private static Metrics _metricsLogger = new Metrics("dotnet-lambdapowertools", "lambda-example");


//private static async Task<string> GetCallingIP()
//{
// client.DefaultRequestHeaders.Accept.Clear();
Expand All @@ -29,35 +25,37 @@ public class Function

// return msg.Replace("\n", "");
//}


//[Metrics("dotnet-lambdapowertools", "lambda-example")]
[Metrics]
public APIGatewayProxyResponse FunctionHandler(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
{

// CAPTURE METHOD EXECUTION METRICS FOR GETCALLINGIP (TWICE - TO REPRESENT THIS SPECIFIC METRIC AS AN ARRAY)
//var watch = System.Diagnostics.Stopwatch.StartNew();
//var location = await GetCallingIP();
//watch.Stop();

using (var logger = new Metrics("dotnet-lambdapowertools-single", "lambda-example"))
{
logger.AddDimension("Metric Type", "Single");
logger.AddMetric("SingleExecution", 1, MetricUnit.COUNT);
}

_metricsLogger.AddDimension("Metric Type", "Aggregate");
_metricsLogger.AddDimension("Method Execution Metrics", "getCallingIP");
_metricsLogger.AddMetric("ElapsedExecutionTime", 1234, MetricUnit.MILLISECONDS);
Metrics.AddDimension("Metric Type", "Aggregate");
Metrics.AddDimension("Method Execution Metrics", "getCallingIP");
Metrics.AddMetric("ElapsedExecutionTime", 1234, MetricUnit.MILLISECONDS);

//watch = System.Diagnostics.Stopwatch.StartNew();
//location = await GetCallingIP();
//watch.Stop();

_metricsLogger.AddMetric("ElapsedExecutionTime", 456124, MetricUnit.MILLISECONDS);
Metrics.AddMetric("ElapsedExecutionTime", 456124, MetricUnit.MILLISECONDS);


_metricsLogger.AddMetric("SuccessfulLocations", 1, MetricUnit.COUNT);
Metrics.AddMetric("SuccessfulLocations", 1, MetricUnit.COUNT);

_metricsLogger.Flush();
Metrics.Flush();

return new APIGatewayProxyResponse
{
Expand Down
5 changes: 3 additions & 2 deletions examples/SimpleLambda/src/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.2.0" />
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.3.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\libraries\src\AWS.Lambda.PowerTools.Metrics\AWS.Lambda.PowerTools.Metrics.csproj" />
<ProjectReference Include="..\..\..\..\libraries\src\AWS.Lambda.PowerTools.Metrics\AWS.Lambda.PowerTools.Metrics.csproj" OutputItemType="Analyzer" />
</ItemGroup>
</Project>

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Loading

0 comments on commit 408bc45

Please sign in to comment.