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 (
11
11
12
12
var yamlFiles []string
13
13
14
- // mergeYamlCmd represents the mergeYaml command
15
14
var mergeYamlCmd = & cobra.Command {
16
15
Use : "mergeYaml" ,
17
16
Short : "Merge two yaml files" ,
Original file line number Diff line number Diff line change 1
1
package sync
2
2
3
3
import (
4
+ "context"
5
+
6
+ "github.com/Altinity/docker-sync/internal/telemetry"
4
7
"github.com/Altinity/docker-sync/structs"
5
8
"github.com/rs/zerolog/log"
9
+ "go.opentelemetry.io/otel/attribute"
10
+ "go.opentelemetry.io/otel/metric"
6
11
"go.uber.org/multierr"
7
12
)
8
13
9
- func SyncImage (image * structs.Image ) error {
14
+ func SyncImage (ctx context. Context , image * structs.Image ) error {
10
15
var merr error
11
16
12
17
tags , err := image .GetTags ()
@@ -18,6 +23,18 @@ func SyncImage(image *structs.Image) error {
18
23
if serr := SyncTag (image , tag ); serr != nil {
19
24
errs := multierr .Errors (serr )
20
25
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
+ )
21
38
log .Error ().
22
39
Errs ("errors" , errs ).
23
40
Msg ("Failed to sync tag" )
Original file line number Diff line number Diff line change @@ -7,14 +7,6 @@ import (
7
7
8
8
var meter = otel .Meter ("docker-sync" )
9
9
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" ),
20
12
))
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ func Start(ctx context.Context) error {
28
28
resource .WithContainer (),
29
29
resource .WithHost (),
30
30
resource .WithAttributes (
31
- attribute .String ("service" , "docker-sync " ),
31
+ attribute .String ("service" , "dockersync " ),
32
32
),
33
33
)
34
34
if err != nil {
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ func Run(ctx context.Context) error {
34
34
default :
35
35
image := images [k ]
36
36
37
- if err := sync .SyncImage (image ); err != nil {
37
+ if err := sync .SyncImage (ctx , image ); err != nil {
38
38
log .Error ().
39
39
Err (err ).
40
40
Str ("source" , image .Source ).
You can’t perform that action at this time.
0 commit comments