Răsfoiți Sursa

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]>
Milas Bowman 2 ani în urmă
părinte
comite
c79f67fead
1 a modificat fișierele cu 13 adăugiri și 0 ștergeri
  1. 13 0
      internal/tracing/attributes.go

+ 13 - 0
internal/tracing/attributes.go

@@ -20,6 +20,8 @@ import (
 	"strings"
 	"time"
 
+	"github.com/docker/compose/v2/pkg/utils"
+
 	"github.com/compose-spec/compose-go/types"
 	moby "github.com/docker/docker/api/types"
 	"go.opentelemetry.io/otel/attribute"
@@ -73,6 +75,7 @@ func ProjectOptions(proj *types.Project) SpanOptions {
 		attribute.StringSlice("project.secrets", proj.SecretNames()),
 		attribute.StringSlice("project.configs", proj.ConfigNames()),
 		attribute.StringSlice("project.extensions", keys(proj.Extensions)),
+		attribute.StringSlice("project.includes", flattenIncludeReferences(proj.IncludeReferences)),
 	}
 	return []trace.SpanStartEventOption{
 		trace.WithAttributes(attrs...),
@@ -150,3 +153,13 @@ func timeAttr(key string, value time.Time) attribute.KeyValue {
 func unixTimeAttr(key string, value int64) attribute.KeyValue {
 	return timeAttr(key, time.Unix(value, 0).UTC())
 }
+
+func flattenIncludeReferences(includeRefs map[string][]types.IncludeConfig) []string {
+	ret := utils.NewSet[string]()
+	for _, included := range includeRefs {
+		for i := range included {
+			ret.AddAll(included[i].Path...)
+		}
+	}
+	return ret.Elements()
+}