File tree Expand file tree Collapse file tree 5 files changed +22
-14
lines changed
Expand file tree Collapse file tree 5 files changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import (
1111
1212var yamlFiles []string
1313
14- // mergeYamlCmd represents the mergeYaml command
1514var mergeYamlCmd = & cobra.Command {
1615 Use : "mergeYaml" ,
1716 Short : "Merge two yaml files" ,
Original file line number Diff line number Diff line change 11package sync
22
33import (
4+ "context"
5+
6+ "github.com/Altinity/docker-sync/internal/telemetry"
47 "github.com/Altinity/docker-sync/structs"
58 "github.com/rs/zerolog/log"
9+ "go.opentelemetry.io/otel/attribute"
10+ "go.opentelemetry.io/otel/metric"
611 "go.uber.org/multierr"
712)
813
9- func SyncImage (image * structs.Image ) error {
14+ func SyncImage (ctx context. Context , image * structs.Image ) error {
1015 var merr error
1116
1217 tags , err := image .GetTags ()
@@ -18,6 +23,18 @@ func SyncImage(image *structs.Image) error {
1823 if serr := SyncTag (image , tag ); serr != nil {
1924 errs := multierr .Errors (serr )
2025 if len (errs ) > 0 {
26+ telemetry .Errors .Add (ctx , int64 (len (errs )),
27+ metric .WithAttributes (
28+ attribute.KeyValue {
29+ Key : "image" ,
30+ Value : attribute .StringValue (image .Source ),
31+ },
32+ attribute.KeyValue {
33+ Key : "tag" ,
34+ Value : attribute .StringValue (tag ),
35+ },
36+ ),
37+ )
2138 log .Error ().
2239 Errs ("errors" , errs ).
2340 Msg ("Failed to sync tag" )
Original file line number Diff line number Diff line change @@ -7,14 +7,6 @@ import (
77
88var meter = otel .Meter ("docker-sync" )
99
10- // ReceivedBytes track the total number of bytes received.
11- var ReceivedBytes = must (meter .Int64Counter ("received_bytes" ,
12- metric .WithDescription ("The total number of bytes received" ),
13- metric .WithUnit ("By" ),
14- ))
15-
16- // SentBytes track the total number of bytes sent.
17- var SentBytes = must (meter .Int64Counter ("sent_bytes" ,
18- metric .WithDescription ("The total number of bytes sent" ),
19- metric .WithUnit ("By" ),
10+ var Errors = must (meter .Int64Counter ("errors" ,
11+ metric .WithDescription ("The total number of errors" ),
2012))
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ func Start(ctx context.Context) error {
2828 resource .WithContainer (),
2929 resource .WithHost (),
3030 resource .WithAttributes (
31- attribute .String ("service" , "docker-sync " ),
31+ attribute .String ("service" , "dockersync " ),
3232 ),
3333 )
3434 if err != nil {
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ func Run(ctx context.Context) error {
3434 default :
3535 image := images [k ]
3636
37- if err := sync .SyncImage (image ); err != nil {
37+ if err := sync .SyncImage (ctx , image ); err != nil {
3838 log .Error ().
3939 Err (err ).
4040 Str ("source" , image .Source ).
You can’t perform that action at this time.
0 commit comments