Skip to content

Commit

Permalink
Add platform tracing socket paths and mounts
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
  • Loading branch information
gabriel-samfira committed Feb 9, 2023
1 parent 7d6bee2 commit 1dc803c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
22 changes: 7 additions & 15 deletions executor/oci/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"path"
"path/filepath"
"runtime"
"strings"
"sync"

Expand Down Expand Up @@ -36,6 +35,12 @@ const (
NoProcessSandbox
)

var tracingEnvVars = []string{
"OTEL_TRACES_EXPORTER=otlp",
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=unix://" + filepath.ToSlash(tracingSocketPath),
"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc",
}

func (pm ProcessMode) String() string {
switch pm {
case ProcessSandbox:
Expand Down Expand Up @@ -184,20 +189,7 @@ func GenerateSpec(ctx context.Context, meta executor.Meta, mounts []executor.Mou
}

if tracingSocket != "" {
if runtime.GOOS == "windows" {
s.Mounts = append(s.Mounts, specs.Mount{
Destination: `\\.\pipe\otel-grpc`,
Source: tracingSocket,
Options: []string{"ro"},
})
} else {
s.Mounts = append(s.Mounts, specs.Mount{
Destination: "/dev/otel-grpc.sock",
Type: "bind",
Source: tracingSocket,
Options: []string{"ro", "rbind"},
})
}
s.Mounts = append(s.Mounts, getTracingSocketMount(tracingSocket))
}

s.Mounts = dedupMounts(s.Mounts)
Expand Down
13 changes: 13 additions & 0 deletions executor/oci/spec_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import (
"github.com/pkg/errors"
)

const (
tracingSocketPath = "/dev/otel-grpc.sock"
)

var tracingEnvVars = []string{
"OTEL_TRACES_EXPORTER=otlp",
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=unix:///dev/otel-grpc.sock",
Expand Down Expand Up @@ -128,3 +132,12 @@ func withDefaultProfile() oci.SpecOpts {
return err
}
}

func getTracingSocketMount(socket string) specs.Mount {
return specs.Mount{
Destination: tracingSocketPath,
Type: "bind",
Source: socket,
Options: []string{"ro", "rbind"},
}
}
19 changes: 14 additions & 5 deletions executor/oci/spec_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
package oci

import (
"path/filepath"

"github.com/containerd/containerd/oci"
"github.com/docker/docker/pkg/idtools"
"github.com/moby/buildkit/solver/pb"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
)

var tracingEnvVars = []string{
"OTEL_TRACES_EXPORTER=otlp",
"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=npipe:////./pipe/otel-grpc",
"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc",
}
const (
tracingSocketPath = "//./pipe/otel-grpc"
)

func generateMountOpts(resolvConf, hostsFile string) ([]oci.SpecOpts, error) {
return nil, nil
Expand Down Expand Up @@ -49,3 +50,11 @@ func generateRlimitOpts(ulimits []*pb.Ulimit) ([]oci.SpecOpts, error) {
}
return nil, errors.New("no support for POSIXRlimit on Windows")
}

func getTracingSocketMount(socket string) specs.Mount {
return specs.Mount{
Destination: filepath.FromSlash(tracingSocketPath),
Source: socket,
Options: []string{"ro"},
}
}

0 comments on commit 1dc803c

Please sign in to comment.