Skip to content

Commit 408bc45

Browse files
authored
Merge pull request #25 from t1agob/develop
Metrics: Added support for Attributes using Source Generators
2 parents d9edb33 + 10ebdf5 commit 408bc45

File tree

90 files changed

+183
-23196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+183
-23196
lines changed

.gitignore

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ docs/node_modules
22
docs/.cache
33
docs/public
44

5-
.idea
5+
.idea
6+
.vscode
7+
8+
AWS.Lambda.Powertools.sln.DotSettings.user
9+
[Oo]bj/**
10+
[Bb]in/**

examples/SimpleLambda/src/HelloWorld/Function.cs

+14-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System.Collections.Generic;
2-
using System.Threading.Tasks;
32
using System.Net.Http;
4-
53
using Amazon.Lambda.Core;
64
using Amazon.Lambda.APIGatewayEvents;
75

@@ -14,12 +12,10 @@
1412

1513
namespace HelloWorld
1614
{
17-
public class Function
15+
public partial class Function
1816
{
1917
private static readonly HttpClient client = new HttpClient();
20-
21-
private static Metrics _metricsLogger = new Metrics("dotnet-lambdapowertools", "lambda-example");
22-
18+
2319
//private static async Task<string> GetCallingIP()
2420
//{
2521
// client.DefaultRequestHeaders.Accept.Clear();
@@ -29,35 +25,37 @@ public class Function
2925

3026
// return msg.Replace("\n", "");
3127
//}
32-
28+
29+
//[Metrics("dotnet-lambdapowertools", "lambda-example")]
30+
[Metrics]
3331
public APIGatewayProxyResponse FunctionHandler(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
3432
{
35-
33+
3634
// CAPTURE METHOD EXECUTION METRICS FOR GETCALLINGIP (TWICE - TO REPRESENT THIS SPECIFIC METRIC AS AN ARRAY)
3735
//var watch = System.Diagnostics.Stopwatch.StartNew();
3836
//var location = await GetCallingIP();
3937
//watch.Stop();
40-
38+
4139
using (var logger = new Metrics("dotnet-lambdapowertools-single", "lambda-example"))
4240
{
4341
logger.AddDimension("Metric Type", "Single");
4442
logger.AddMetric("SingleExecution", 1, MetricUnit.COUNT);
4543
}
46-
47-
_metricsLogger.AddDimension("Metric Type", "Aggregate");
48-
_metricsLogger.AddDimension("Method Execution Metrics", "getCallingIP");
49-
_metricsLogger.AddMetric("ElapsedExecutionTime", 1234, MetricUnit.MILLISECONDS);
44+
45+
Metrics.AddDimension("Metric Type", "Aggregate");
46+
Metrics.AddDimension("Method Execution Metrics", "getCallingIP");
47+
Metrics.AddMetric("ElapsedExecutionTime", 1234, MetricUnit.MILLISECONDS);
5048

5149
//watch = System.Diagnostics.Stopwatch.StartNew();
5250
//location = await GetCallingIP();
5351
//watch.Stop();
5452

55-
_metricsLogger.AddMetric("ElapsedExecutionTime", 456124, MetricUnit.MILLISECONDS);
53+
Metrics.AddMetric("ElapsedExecutionTime", 456124, MetricUnit.MILLISECONDS);
5654

5755

58-
_metricsLogger.AddMetric("SuccessfulLocations", 1, MetricUnit.COUNT);
56+
Metrics.AddMetric("SuccessfulLocations", 1, MetricUnit.COUNT);
5957

60-
_metricsLogger.Flush();
58+
Metrics.Flush();
6159

6260
return new APIGatewayProxyResponse
6361
{

examples/SimpleLambda/src/HelloWorld/HelloWorld.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
66
<AWSProjectType>Lambda</AWSProjectType>
7+
<LangVersion>latest</LangVersion>
78
</PropertyGroup>
89

910
<ItemGroup>
1011
<PackageReference Include="Amazon.Lambda.Core" Version="1.2.0" />
1112
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.3.0" />
1213
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.1.0" />
13-
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
14+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
1415
</ItemGroup>
1516

1617
<ItemGroup>
17-
<ProjectReference Include="..\..\..\..\libraries\src\AWS.Lambda.PowerTools.Metrics\AWS.Lambda.PowerTools.Metrics.csproj" />
18+
<ProjectReference Include="..\..\..\..\libraries\src\AWS.Lambda.PowerTools.Metrics\AWS.Lambda.PowerTools.Metrics.csproj" OutputItemType="Analyzer" />
1819
</ItemGroup>
1920
</Project>
2021

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

examples/SimpleWeb/src/Web/bin/Debug/netcoreapp3.1/Properties/launchSettings.json

-16
This file was deleted.

0 commit comments

Comments
 (0)