-
Notifications
You must be signed in to change notification settings - Fork 24
/
ValuesController.cs
71 lines (62 loc) · 1.79 KB
/
ValuesController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using Microsoft.AspNetCore.Mvc;
using System;
using AWS.Lambda.Powertools.Logging;
using AWS.Lambda.Powertools.Tracing;
using AWS.Lambda.Powertools.Metrics;
namespace LambdaPowertoolsAPI.Controllers;
[Route("api/[controller]")]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
[Tracing(SegmentName = "Values::Get")]
public IEnumerable<string> Get()
{
Logger.LogInformation("Log entry information only about getting values? Or maybe something more ");
return new string[] { "value1", "value2" };
}
// GET api/values/5
[HttpGet("{id}")]
[Tracing(SegmentName = "Values::GetById")]
public string Get(int id)
{
try
{
Metrics.AddMetric("SuccessfulRetrieval", 1, MetricUnit.Count);
}
catch (Exception e)
{
Logger.LogError("Failed to add metric", e);
}
return "value";
}
// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}