Skip to content

Commit c79f67f

Browse files
milasndeloof
authored andcommitted
otel: add include to project up span
Flatten the list of included files and add as a slice attribute. Signed-off-by: Milas Bowman <[email protected]>
1 parent 3b294bf commit c79f67f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/tracing/attributes.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"strings"
2121
"time"
2222

23+
"github.com/docker/compose/v2/pkg/utils"
24+
2325
"github.com/compose-spec/compose-go/types"
2426
moby "github.com/docker/docker/api/types"
2527
"go.opentelemetry.io/otel/attribute"
@@ -73,6 +75,7 @@ func ProjectOptions(proj *types.Project) SpanOptions {
7375
attribute.StringSlice("project.secrets", proj.SecretNames()),
7476
attribute.StringSlice("project.configs", proj.ConfigNames()),
7577
attribute.StringSlice("project.extensions", keys(proj.Extensions)),
78+
attribute.StringSlice("project.includes", flattenIncludeReferences(proj.IncludeReferences)),
7679
}
7780
return []trace.SpanStartEventOption{
7881
trace.WithAttributes(attrs...),
@@ -150,3 +153,13 @@ func timeAttr(key string, value time.Time) attribute.KeyValue {
150153
func unixTimeAttr(key string, value int64) attribute.KeyValue {
151154
return timeAttr(key, time.Unix(value, 0).UTC())
152155
}
156+
157+
func flattenIncludeReferences(includeRefs map[string][]types.IncludeConfig) []string {
158+
ret := utils.NewSet[string]()
159+
for _, included := range includeRefs {
160+
for i := range included {
161+
ret.AddAll(included[i].Path...)
162+
}
163+
}
164+
return ret.Elements()
165+
}

0 commit comments

Comments
 (0)