Skip to content

feat: Added support for Attributes using Source Generators #25

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

Merged
merged 9 commits into from
Sep 22, 2021
Merged
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
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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;

@@ -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();
@@ -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
{
5 changes: 3 additions & 2 deletions examples/SimpleLambda/src/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
@@ -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