docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.02k stars 5.11k forks source link

[BUG] when buildkit opentelementry is enabled, compose does not correctly create spans #10167

Open nicks opened 1 year ago

nicks commented 1 year ago

Description

when doing builds with compose, buildkit opentelemetry does not show end-to-end traces

the opentelemetry works correctly when using buildx directly

Steps To Reproduce

  1. Use this guide to setup buildkit opentelemetry - https://github.com/docker/buildx/blob/master/docs/guides/opentelemetry.md
  2. Run compose up on a compose file with a build stanza

Expected result: I should see an end to end build trace. Here's an example of what it looks like when I use buildx directly: Screenshot from 2023-01-09 18-20-51

Actual result: I get a bunch of disconnected buildkitd spans Screenshot from 2023-01-11 10-30-00

Compose Version

Docker Compose version v2.15.1

Docker Environment

Client:
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  compose: Docker Compose (Docker Inc., v2.15.1)
  dev: Docker Dev Environments (Docker Inc., v0.0.5)
  extension: Manages Docker extensions (Docker Inc., v0.2.17)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.23.0)

Server:
 Containers: 24
  Running: 11
  Paused: 0
  Stopped: 13
 Images: 65
 Server Version: 20.10.22
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9ba4b250366a5ddde94bb7c9d1def331423aa323
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.49-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 3.658GiB
 Name: docker-desktop
 ID: GUXY:5TEH:RSRI:NJHK:SHFQ:FARH:GSDW:N5DT:UXT5:IYST:656M:M7WM
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

@tonistiigi says:

in order to add extra StartSpan on client side you need client to be traced as well

https://github.com/docker/buildx/commit/9d884501186b2269d341df6a4242627a70715c46#diff-7fdd319c657fbde54b83a5dfa233c5c2c417b291739ff75c05dc5d83ee7a9d24 is the initial commit for tracing in buildx. maybe something from there is missing in compose vendor

ndeloof commented 1 year ago

There's already way to much code duplicated in compose to support buildkit builds :'( I suggest we reconsider https://github.com/docker/compose/issues/9477