Skip to content

Commit 565ffaa

Browse files
committed
fixes
1 parent 42f6441 commit 565ffaa

File tree

6 files changed

+96
-494
lines changed

6 files changed

+96
-494
lines changed

cmd/v1/main.go

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
Licensed under the Apache License, Version 2.0 (the "License");
3+
you may not use this file except in compliance with the License.
4+
You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
115
package main
216

317
import (
@@ -12,10 +26,11 @@ import (
1226
"github.com/aws/aws-sdk-go/service/ec2"
1327
"github.com/aws/aws-sdk-go/service/eks"
1428
"github.com/aws/aws-sdk-go/service/s3"
15-
"github.com/bwagner5/aws-sdk-go-metrics/pkg/awsmetrics"
1629
"github.com/prometheus/client_golang/prometheus"
1730
"github.com/prometheus/client_golang/prometheus/promhttp"
1831
"github.com/samber/lo"
32+
33+
"github.com/bwagner5/aws-sdk-go-metrics/pkg/awsmetrics"
1934
)
2035

2136
type Options struct {
@@ -47,8 +62,15 @@ func main() {
4762
registry,
4863
promhttp.HandlerOpts{EnableOpenMetrics: false},
4964
))
65+
srv := &http.Server{
66+
ReadTimeout: 1 * time.Second,
67+
WriteTimeout: 1 * time.Second,
68+
IdleTimeout: 30 * time.Second,
69+
ReadHeaderTimeout: 2 * time.Second,
70+
Addr: fmt.Sprintf("127.0.0.1:%d", opts.Port),
71+
}
5072
log.Printf("Serving prometheus metrics at http://127.0.0.1:%d/metrics", opts.Port)
51-
lo.Must0(http.ListenAndServe(fmt.Sprintf("127.0.0.1:%d", opts.Port), nil))
73+
lo.Must0(srv.ListenAndServe())
5274
}
5375

5476
func demo(sess *session.Session) {

cmd/v2/main.go

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
Licensed under the Apache License, Version 2.0 (the "License");
3+
you may not use this file except in compliance with the License.
4+
You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
115
package main
216

317
import (
@@ -16,10 +30,11 @@ import (
1630
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
1731
"github.com/aws/aws-sdk-go-v2/service/s3"
1832
s3types "github.com/aws/aws-sdk-go-v2/service/s3/types"
19-
"github.com/bwagner5/aws-sdk-go-metrics/pkg/awsmetricsv2"
2033
"github.com/prometheus/client_golang/prometheus"
2134
"github.com/prometheus/client_golang/prometheus/promhttp"
2235
"github.com/samber/lo"
36+
37+
"github.com/bwagner5/aws-sdk-go-metrics/pkg/awsmetricsv2"
2338
)
2439

2540
type Options struct {
@@ -49,8 +64,15 @@ func main() {
4964
registry,
5065
promhttp.HandlerOpts{EnableOpenMetrics: false},
5166
))
67+
srv := &http.Server{
68+
ReadTimeout: 1 * time.Second,
69+
WriteTimeout: 1 * time.Second,
70+
IdleTimeout: 30 * time.Second,
71+
ReadHeaderTimeout: 2 * time.Second,
72+
Addr: fmt.Sprintf("127.0.0.1:%d", opts.Port),
73+
}
5274
log.Printf("Serving prometheus metrics at http://127.0.0.1:%d/metrics", opts.Port)
53-
lo.Must0(http.ListenAndServe(fmt.Sprintf("127.0.0.1:%d", opts.Port), nil))
75+
lo.Must0(srv.ListenAndServe())
5476
}
5577

5678
func demo(cfg aws.Config) {

0 commit comments

Comments
 (0)