### Start Example Services with Docker Compose Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/examples/kafka-go/README.md Use this command to start all necessary services for the example, including the Go application, Kafka, and Jaeger, using the provided docker-compose.yml file. ```bash docker compose up ``` -------------------------------- ### Start Example Services with Docker Compose Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/examples/httpPlusdb/README.md This command starts the services defined in the `docker-compose.yaml` file, including the instrumented Go application, the database, and the Jaeger collector/UI. ```Shell docker compose up ``` -------------------------------- ### Start Docker Compose Services Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/getting-started.md This shell command is used to start the services defined in the `docker-compose.yaml` file, including the application and the OpenTelemetry Go Automatic Instrumentation service. ```shell docker compose up ``` -------------------------------- ### Build OpenTelemetry Go Auto-Instrumentation Binary Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/getting-started.md This shell command compiles the OpenTelemetry Go Automatic Instrumentation binary from source. It is a prerequisite for instrumenting applications running directly on the host. ```shell make build ``` -------------------------------- ### Run OpenTelemetry Go Auto-Instrumentation on Host Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/getting-started.md This shell command executes the compiled OpenTelemetry Go Automatic Instrumentation binary on a Linux host with root privileges. It sets required environment variables (`OTEL_GO_AUTO_TARGET_EXE`, `OTEL_SERVICE_NAME`, `OTEL_EXPORTER_OTLP_ENDPOINT`) inline before running the binary, targeting a specific application executable. ```shell sudo OTEL_GO_AUTO_TARGET_EXE=/home/bin/service_executable OTEL_SERVICE_NAME=my_service OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 ./otel-go-instrumentation ``` -------------------------------- ### Trigger HTTP Request and Database Query Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/examples/httpPlusdb/README.md This command sends an HTTP GET request to the running server endpoint `/query_db`, which is configured to interact with the database and generate a trace. ```Shell curl localhost:8080/query_db ``` -------------------------------- ### Configure OpenTelemetry Go Auto-Instrumentation Service in Docker Compose Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/getting-started.md This Docker Compose snippet defines a service for the OpenTelemetry Go Automatic Instrumentation. It specifies the image, enables privileged mode and host PID namespace access, sets environment variables for the OTLP endpoint, target executable, service name, and propagators, and mounts necessary volumes including the host's `/proc` and a shared application volume. ```yaml go-auto: image: otel/autoinstrumentation-go privileged: true pid: "host" environment: - OTEL_EXPORTER_OTLP_ENDPOINT=http://:4318 - OTEL_GO_AUTO_TARGET_EXE= - OTEL_SERVICE_NAME= - OTEL_PROPAGATORS=tracecontext,baggage volumes: - - /proc:/host/proc ``` -------------------------------- ### Configure OpenTelemetry Go Auto-Instrumentation Container in Kubernetes Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/getting-started.md This YAML snippet shows how to add the OpenTelemetry Go Automatic Instrumentation container to a Kubernetes pod manifest. It configures the container image, sets environment variables for the target executable, OTLP endpoint, and service name, and ensures the container runs with root privileges (`runAsUser: 0`, `privileged: true`) for process namespace access. ```yaml - name: autoinstrumentation-go image: otel/autoinstrumentation-go imagePullPolicy: IfNotPresent env: - name: OTEL_GO_AUTO_TARGET_EXE value: - name: OTEL_EXPORTER_OTLP_ENDPOINT value: "http://:4318" - name: OTEL_SERVICE_NAME value: "" securityContext: runAsUser: 0 privileged: true ``` -------------------------------- ### Clone Upstream Repo using Go Get Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/CONTRIBUTING.md Uses the `go get -d` command to download the upstream `opentelemetry-go-instrumentation` repository without installing it. This places the project source code within the user's GOPATH. ```Shell go get -d go.opentelemetry.io/auto ``` -------------------------------- ### Trigger Kafka Message Production via HTTP Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/examples/kafka-go/README.md Execute this curl command to send an HTTP request to the example server's /produce endpoint, initiating the Kafka producer to send messages and generate trace data. ```bash curl localhost:8080/produce ``` -------------------------------- ### Example Instrumentation Loaded Log Output Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/examples/rolldice/README.md An example log line indicating that the OpenTelemetry Go auto-instrumentation has successfully loaded for a service. ```terminal go-auto-user-1 | {"time":"2025-01-09T16:18:08.182081553Z","level":"INFO","source":{"function":"main.main","file":"/app/cli/main.go","line":129},"msg":"instrumentation loaded successfully, starting..."} ``` -------------------------------- ### Running Roll Dice Application with Docker Compose Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/examples/rolldice/README.md Starts the Roll Dice application and associated OpenTelemetry services using docker-compose. ```terminal docker-compose up ``` -------------------------------- ### Build Go Instrumentation Binary using Make Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/CONTRIBUTING.md Runs the `make build` command to compile the Go Automatic Instrumentation binary. Requires specific system dependencies like clang, gcc, go, libbpf-dev, llvm, and make. ```Shell make build ``` -------------------------------- ### Update libbpf Includes using Make Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/CONTRIBUTING.md Optionally sets the LIBBPF_VERSION environment variable to constrain the version, then runs the `make synclibbpf` command to update the internal libbpf includes. ```Shell export LIBBPF_VERSION="< 1.5, >= 1.4.7" make synclibbpf ``` -------------------------------- ### Fetching Latest Main and Creating Prerelease Branch - Git/Shell Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/RELEASING.md Fetches the latest changes from the 'origin' remote and creates a new branch named 'prerelease' based on the 'main' branch. This is the initial step for preparing a new release. ```Shell git fetch origin git checkout origin/main -b prerelease ``` -------------------------------- ### Running Prerelease Make Target - Make/Shell Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/RELEASING.md Executes the 'prerelease' make target for a specific module set, identified by the MODSET variable. This target automates the process of preparing release changes, including updating versions. Requires a Makefile with a 'prerelease' target. ```Shell make prerelease MODSET= ``` -------------------------------- ### Build Go Instrumentation in Docker using Make Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/CONTRIBUTING.md Runs the `make docker-build` command to build the Go Automatic Instrumentation project within a Linux Docker container as an alternative to building directly on the host. ```Shell make docker-build ``` -------------------------------- ### Verifying Prerelease Changes - Git/Shell Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/RELEASING.md Displays the differences between the current state and the branch created by the 'prerelease' make target. Used to verify that version updates and other release changes are correct before merging. ```Shell git diff ...prerelease__ ``` -------------------------------- ### Adding Release Tags - Make/Shell Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/RELEASING.md Executes the 'add-tags' make target for a specific module set and commit hash. This target is responsible for creating the necessary Git tags for the release on the specified commit. Requires a Makefile with an 'add-tags' target. ```Shell make add-tags MODSET= COMMIT= ``` -------------------------------- ### Generate compile_commands.json using Make Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/CONTRIBUTING.md Runs the `make compile_commands.json` command. This utilizes the `bear` utility to generate a `compile_commands.json` file, which is useful for IDE integration with tools like `clangd`. ```Shell make compile_commands.json ``` -------------------------------- ### Create and Checkout New Git Branch Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/CONTRIBUTING.md Creates a new Git branch with the specified name `` and immediately switches to it. This is the standard first step before making changes for a pull request. ```Shell git checkout -b # edit files ``` -------------------------------- ### Add Fork as Git Remote Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/CONTRIBUTING.md Adds your personal fork of the repository as a new remote origin in the local Git repository. Replace `` with a name for the remote and `` with your GitHub username. ```Shell git remote add git@github.com:/opentelemetry-go-instrumentation ``` -------------------------------- ### Clone Upstream Repo using Git Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/CONTRIBUTING.md Uses the standard `git clone` command to clone the upstream `opentelemetry-go-instrumentation` repository directly from GitHub into the current working directory. ```Shell git clone https://github.com/open-telemetry/opentelemetry-go-instrumentation ``` -------------------------------- ### Updating Changelog and Pushing Changes (Bash) Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/CONTRIBUTING.md This sequence of commands is used after updating the changelog. It runs pre-commit hooks, interactively stages changes, commits them, and pushes to a specified fork and branch. ```bash make precommit git add -p git commit git push ``` -------------------------------- ### Merging Prerelease Changes - Git/Shell Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/RELEASING.md Merges the changes from the 'prerelease__' branch (created by the make target) into the current prerelease branch. This incorporates the version updates and other automated changes. ```Shell git merge prerelease__ ``` -------------------------------- ### Pushing Release Tag to Upstream - Git/Shell Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/RELEASING.md Pushes the newly created Git tag to the 'upstream' remote repository. This action triggers release workflows (like building and publishing Docker images) associated with the tag. ```Shell git push upstream ``` -------------------------------- ### Manual OpenTelemetry Tracing in Go Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/examples/rolldice/README.md Demonstrates how to manually create a span using the OpenTelemetry Go API within the user service to trace the userQuota function, integrating with auto-instrumentation. ```go tracer := otel.Tracer("user") ctx, span := tracer.Start(ctx, "userQuota") u, err := useQuota(ctx, db, name) if err != nil { span.SetStatus(codes.Error, "failed to query user quota") span.RecordError(err) span.End() http.Error(w, err.Error(), http.StatusInternalServerError) return } span.End() ``` -------------------------------- ### Instrumenting HTTP Server Handler (Go) Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/design/context-propagation.md This Go function signature represents the target for HTTP server instrumentation. It is where the eBPF probe would attach to read incoming request headers for context propagation. ```Go func (mux *ServeMux) ServeHTTP(w ResponseWriter, r *Request) ``` -------------------------------- ### Go Proof-of-Concept Application for eBPF Argument Modification Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/design/context-propagation.md A simple Go program demonstrating how eBPF instrumentation can potentially modify function arguments. The `worker` function processes a string, and the `main` function calls it in a loop. This application is used to show the effect of eBPF modifying the `str` argument passed to `worker`. ```Go func worker(str string) { headers := make(map[string]string) headers["X-Request-Id"] = str fmt.Printf("The Headers are: %s\n", headers) } func main() { for i := 0; i < 10; i++ { worker(fmt.Sprintf("request number: %d", i)) time.Sleep(2 * time.Second) } } ``` -------------------------------- ### Instrumenting OpenTelemetry Go SDK Span Creation Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/design/manual-instrumentation.md This Go function from the OpenTelemetry Go SDK's `tracer.go` is identified as a potential target for instrumentation. By modifying the `psc.spanID` and `sc.traceID` parameters based on the current active span from an eBPF map, a manually created span can be made a child of the current active span, integrating it into the automatic trace. ```Go func (tr *tracer) newRecordingSpan(psc, sc trace.SpanContext, name string, sr SamplingResult, config *trace.SpanConfig) *recordingSpan { ``` -------------------------------- ### Listing Commits Since Last Tag - Git/Shell Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/RELEASING.md Lists commits between the last release tag and the current HEAD of the branch. Used to identify changes that should be included in the changelog for the new release. The --no-pager option prevents output from being piped to a pager. ```Shell git --no-pager log --pretty=oneline "..HEAD" ``` -------------------------------- ### Decoding gRPC Incoming Metadata (Go) Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/design/context-propagation.md This Go function signature is a potential target for gRPC client instrumentation to read incoming response headers. An eBPF probe could attach here to extract trace context information from the decoded metadata. ```Go func decodeMetadataHeader(k, v string) (string, error) ``` -------------------------------- ### Writing gRPC Outgoing Headers (Go) Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/design/context-propagation.md This Go function signature is a potential target for gRPC client instrumentation. An eBPF probe could attach here to modify the header fields (`hf`) array using `bpf_probe_write_user()` to inject the current span context. ```Go func (l *loopyWriter) writeHeader(streamID uint32, endStream bool, hf []hpack.HeaderField, onWrite func()) error ``` -------------------------------- ### Identify Go HTTP Header Write Function Source: https://github.com/open-telemetry/opentelemetry-go-instrumentation/blob/main/docs/design/context-propagation.md Identifies a potential Go function signature within the net/http package or similar that is responsible for writing headers to an HTTP response. This function is a candidate for eBPF uprobe instrumentation to intercept or modify header writing operations. ```Go func (h Header) writeSubset(w io.Writer, exclude map[string]bool, trace *httptrace.ClientTrace) error ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.