ProjectOptions returns common attributes from a Compose project. For convenience, it's returned as a SpanOptions object to allow it to be passed directly to the wrapping helper methods in this package such as SpanWrapFunc.
(ctx context.Context, proj *types.Project)
| 64 | // passed directly to the wrapping helper methods in this package such as |
| 65 | // SpanWrapFunc. |
| 66 | func ProjectOptions(ctx context.Context, proj *types.Project) SpanOptions { |
| 67 | if proj == nil { |
| 68 | return nil |
| 69 | } |
| 70 | capabilities, gpu, tpu := proj.ServicesWithCapabilities() |
| 71 | attrs := []attribute.KeyValue{ |
| 72 | attribute.String("project.name", proj.Name), |
| 73 | attribute.String("project.dir", proj.WorkingDir), |
| 74 | attribute.StringSlice("project.compose_files", proj.ComposeFiles), |
| 75 | attribute.StringSlice("project.profiles", proj.Profiles), |
| 76 | attribute.StringSlice("project.volumes", proj.VolumeNames()), |
| 77 | attribute.StringSlice("project.networks", proj.NetworkNames()), |
| 78 | attribute.StringSlice("project.secrets", proj.SecretNames()), |
| 79 | attribute.StringSlice("project.configs", proj.ConfigNames()), |
| 80 | attribute.StringSlice("project.models", proj.ModelNames()), |
| 81 | attribute.StringSlice("project.extensions", keys(proj.Extensions)), |
| 82 | attribute.StringSlice("project.services.active", proj.ServiceNames()), |
| 83 | attribute.StringSlice("project.services.disabled", proj.DisabledServiceNames()), |
| 84 | attribute.StringSlice("project.services.build", proj.ServicesWithBuild()), |
| 85 | attribute.StringSlice("project.services.depends_on", proj.ServicesWithDependsOn()), |
| 86 | attribute.StringSlice("project.services.models", proj.ServicesWithModels()), |
| 87 | attribute.StringSlice("project.services.capabilities", capabilities), |
| 88 | attribute.StringSlice("project.services.capabilities.gpu", gpu), |
| 89 | attribute.StringSlice("project.services.capabilities.tpu", tpu), |
| 90 | } |
| 91 | if metrics, ok := ctx.Value(MetricsKey{}).(Metrics); ok { |
| 92 | attrs = append(attrs, attribute.Int("project.services.extends", metrics.CountExtends)) |
| 93 | attrs = append(attrs, attribute.Int("project.includes.local", metrics.CountIncludesLocal)) |
| 94 | attrs = append(attrs, attribute.Int("project.includes.remote", metrics.CountIncludesRemote)) |
| 95 | } |
| 96 | |
| 97 | if projHash, ok := projectHash(proj); ok { |
| 98 | attrs = append(attrs, attribute.String("project.hash", projHash)) |
| 99 | } |
| 100 | return []trace.SpanStartEventOption{ |
| 101 | trace.WithAttributes(attrs...), |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // ServiceOptions returns common attributes from a Compose service. |
| 106 | // |
no test coverage detected
searching dependent graphs…