Skip to content

Commit

Permalink
tracing: Add OpenTracing support
Browse files Browse the repository at this point in the history
Add OpenTracing [1] support using Jaeger [2]. Introduces two new gRPC
API calls to enable and disable tracing dynamically: `StartTracing()`
and `StopTracing()`.

Full details of this feature are provided in `TRACING.md`.

Updated vendoring for github.com/mdlayher/vsock to resolve hangs using a
vsock socket with `grpcServer.Serve()`. Changes:

    498f144 Handle return result in Accept test
    fda437e Fix unblocking after closing listener
    4b12813 Add go.mod
    ce2ff06 vsock: factor out newConn function on Linux
    d8b0f13 vsock: adjust listener test for nonblocking
    7a158c6 vsock: enable timeouts also on listener connections
    f68ad55 vsock: allow timeouts with Go 1.11
    d0067a6 vsock/conn: don't use struct embedding

Note: the agent **must** be built with golang 1.11* or newer to ensure
correct behaviour.

Fixes kata-containers#322.

[1] - https://opentracing.io
[2] - https://jaegertracing.io

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Mar 13, 2019
1 parent cbd0aae commit 00cf907
Show file tree
Hide file tree
Showing 123 changed files with 19,933 additions and 310 deletions.
47 changes: 45 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

[[constraint]]
name = "github.com/mdlayher/vsock"
revision = "738c88d6e4cfd60e8124a5344fa10d205fd828b9"
revision = "676f733b747cd6406f297a51bd086ee8ec8abdbe"

[[constraint]]
name = "github.com/opencontainers/runc"
Expand Down Expand Up @@ -46,6 +46,11 @@
name = "github.com/containerd/console"
revision = "2748ece16665b45a47f884001d5831ec79703880"

[[constraint]]
name = "github.com/uber/jaeger-client-go"
version = "2.15.0"


[prune]
non-go = true
go-tests = true
Expand Down
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,36 @@ PREFIX := /usr
BINDIR := $(PREFIX)/bin
# Define if agent will be installed as init
INIT := no

# Set to "yes" if agent should support OpenTracing with http://jaegertracing.io.
TRACE := no

# Tracing cannot currently be supported when running the agent as PID 1 since
# the tracing requires additional services to be started _before_ the agent
# process starts.
#
# These services are required since Jaeger does not currently support VSOCK.
# Once Jaeger does support VSOCK, this limitation can be removed as the
# additional services will no longer be required.
#
# See TRACING.md for further details.
ifeq ($(TRACE),yes)
ifeq ($(INIT),yes)
$(error ERROR: "TRACE=yes" requires "INIT=no")
endif
endif

# If "yes", install additional services to redirect guest OS journal messages
# to the host using VSOCK.
TRACE_DEV_MODE := no

# Path to systemd unit directory if installed as not init.
UNIT_DIR := /usr/lib/systemd/system

# Path to systemd drop-in snippet directory used to override the agent's
# service without having to modify the pristine agent service file.
SNIPPET_DIR := /etc/systemd/system/$(AGENT_SERVICE).d/

GENERATED_FILES :=

ifeq ($(INIT),no)
Expand All @@ -24,6 +51,15 @@ ifeq ($(INIT),no)
UNIT_FILES += kata-containers.target
endif

ifeq ($(TRACE),yes)
UNIT_FILES += jaeger-client-socat-redirector.service
endif

ifeq ($(TRACE_DEV_MODE),yes)
UNIT_FILES += kata-journald-host-redirect.service
SNIPPET_FILES += kata-redirect-agent-output-to-journal.conf
endif

VERSION_FILE := ./VERSION
VERSION := $(shell grep -v ^\# $(VERSION_FILE))
COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
Expand Down Expand Up @@ -56,6 +92,11 @@ ifeq ($(INIT),no)
@echo "Installing systemd unit files..."
$(foreach f,$(UNIT_FILES),$(call INSTALL_FILE,$f,$(UNIT_DIR)))
endif
ifeq ($(TRACE_DEV_MODE),yes)
@echo "Installing systemd snippet files..."
@mkdir -p $(SNIPPET_DIR)
$(foreach f,$(SNIPPET_FILES),$(call INSTALL_FILE,$f,$(SNIPPET_DIR)))
endif

build-image:
# build an docker image for development
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

* [Debug mode](#debug-mode)
* [Developer mode](#developer-mode)
* [Enable trace support](#enable-trace-support)

This project implements an agent called `kata-agent` that runs inside a virtual machine (VM).

Expand All @@ -22,3 +23,7 @@ See the [developer guide](https://github.com/kata-containers/documentation/blob/
Add `agent.devmode` to the guest kernel command line to allow the agent
process to coredump (disabled by default). Specifying this option implicitly
enables [debug mode](#debug-mode).

## Enable trace support

See [the tracing guide](TRACING.md).
Loading

0 comments on commit 00cf907

Please sign in to comment.