Skip to content

Commit

Permalink
Automatic span creation
Browse files Browse the repository at this point in the history
ttrpc interceptor automatically formats (as JSON) and adds
server requests and responses as span attributes.

Host and guest bridge automatically creates spans for RPCs.

Replaced redundant `cmd/containerd-shim-runhcs-v1/service.go.(Service)`
`internal/gcs`, and `interna\guest\bridge` spans with `.Trace` log
entries, since they include
all the same (or less) information as those automatically generated by
the ttrp interceptor and `(*bridge).RPC`

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
  • Loading branch information
helsaawy committed Aug 3, 2023
1 parent 1665e4e commit 5bf616f
Show file tree
Hide file tree
Showing 11 changed files with 206 additions and 493 deletions.
10 changes: 9 additions & 1 deletion cmd/containerd-shim-runhcs-v1/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"go.opencensus.io/trace"
"golang.org/x/sys/windows"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"

runhcsopts "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
"github.com/Microsoft/hcsshim/internal/extendedtask"
hcslog "github.com/Microsoft/hcsshim/internal/log"
"github.com/Microsoft/hcsshim/internal/logfields"
"github.com/Microsoft/hcsshim/internal/shimdiag"
"github.com/Microsoft/hcsshim/pkg/octtrpc"
)
Expand Down Expand Up @@ -194,7 +196,13 @@ var serveCommand = cli.Command{
return fmt.Errorf("failed to create new service: %w", err)
}

s, err := ttrpc.NewServer(ttrpc.WithUnaryServerInterceptor(octtrpc.ServerInterceptor()))
s, err := ttrpc.NewServer(
ttrpc.WithUnaryServerInterceptor(octtrpc.ServerInterceptor(
octtrpc.WithAttributes( // todo (helsaawy) set these in resource when we switch to OTel
trace.StringAttribute(logfields.ShimID, svc.tid),
trace.BoolAttribute(logfields.IsSandbox, svc.isSandbox),
),
)))
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 5bf616f

Please sign in to comment.