mirror of
https://github.com/docker/compose.git
synced 2025-04-08 17:05:13 +02:00
This is a bunch of OTEL initialization code. It's all in `internal/` because there are re-usable parts here, but Compose isn't the right spot. Once we've stabilized the interfaces a bit and the need arises, we can move it to a separate module. Currently, a single span is produced to wrap the root Compose command. Compose will respect the standard OTEL environment variables as well as OTEL metadata from the Docker context. Both can be used simultaneously. The latter is intended for local system integration and is restricted to Unix sockets / named pipes. None of this is enabled by default. It requires setting the `COMPOSE_EXPERIMENTAL_OTEL=1` environment variable to gate it during development. Signed-off-by: Milas Bowman <milas.bowman@docker.com>
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
//go:build !windows
|
|
|
|
/*
|
|
Copyright 2023 Docker Compose CLI authors
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package tracing
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net"
|
|
"strings"
|
|
"syscall"
|
|
)
|
|
|
|
const maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path)
|
|
|
|
func DialInMemory(ctx context.Context, addr string) (net.Conn, error) {
|
|
if !strings.HasPrefix(addr, "unix://") {
|
|
return nil, fmt.Errorf("not a Unix socket address: %s", addr)
|
|
}
|
|
addr = strings.TrimPrefix(addr, "unix://")
|
|
|
|
if len(addr) > maxUnixSocketPathSize {
|
|
//goland:noinspection GoErrorStringFormat
|
|
return nil, fmt.Errorf("Unix socket address is too long: %s", addr)
|
|
}
|
|
|
|
var d net.Dialer
|
|
return d.DialContext(ctx, "unix", addr)
|
|
}
|