diff --git a/.codespellignore b/.codespellignore new file mode 100644 index 000000000..ad33f60cc --- /dev/null +++ b/.codespellignore @@ -0,0 +1,2 @@ +mmaped +ect diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000..d990bfe4e --- /dev/null +++ b/.codespellrc @@ -0,0 +1,10 @@ +# https://github.com/codespell-project/codespell +[codespell] +builtin = clear,rare,informal +check-filenames = +check-hidden = +ignore-words = .codespellignore +interactive = 1 +skip = .git,go.mod,go.sum,CHANGELOG.md,LICENSES,venv,./internal/include/libbpf +uri-ignore-words-list = * +write = diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 63af0b3b9..ab52a66f0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -217,3 +217,12 @@ updates: schedule: interval: weekly day: sunday + - package-ecosystem: pip + directory: / + labels: + - dependencies + - python + - Skip Changelog + schedule: + interval: weekly + day: sunday diff --git a/.github/workflows/codespell.yaml b/.github/workflows/codespell.yaml new file mode 100644 index 000000000..774c020cb --- /dev/null +++ b/.github/workflows/codespell.yaml @@ -0,0 +1,14 @@ +name: codespell +on: + push: + branches: + - main + pull_request: +jobs: + codespell: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4 + - name: Codespell + run: make codespell diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 58cd8a103..e2bd2df13 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -42,7 +42,7 @@ jobs: ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }} - name: Build and push - uses: docker/build-push-action@v5.4.0 + uses: docker/build-push-action@v6.2.0 with: push: true tags: ${{ steps.meta.outputs.tags }} diff --git a/.gitignore b/.gitignore index 7702607bb..00e965ff3 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,9 @@ # VSCode .vscode/ +# Installed by `make codespell` +venv/ + otel-go-instrumentation launcher/ opentelemetry-helm-charts/ diff --git a/.golangci.yml b/.golangci.yml index 3b26be847..80160748a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -107,7 +107,7 @@ linters-settings: - name: constant-logical-expr disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument - # TODO (#3372) reenable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280 + # TODO (#3372) re-enable linter when it is compatible. https://github.com/golangci/golangci-lint/issues/3280 - name: context-as-argument disabled: true arguments: diff --git a/CHANGELOG.md b/CHANGELOG.md index c4cdf60fc..8dad3ebf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ OpenTelemetry Go Automatic Instrumentation adheres to [Semantic Versioning](http - Support Go versions from apps defining GOEXPERIMENT. ([#813](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/813)) - Update `net/http` instrumentation to comply with semantic conventions v1.25.0. ([#790](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/790)) - Update existing 3rd party licenses. ([#864](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/864)) +- Add make target 'codespell'. ([#863](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/863)) ## [v0.12.0-alpha] - 2024-04-10 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4976df5b5..48d458653 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,6 +85,11 @@ git commit git push ``` +Additionally, there is a `codespell` target that checks for common +typos in the code. It is not run by default, but you can run it +manually with `make codespell`. It will set up a virtual environment +in `venv` and install `codespell` there. + Open a pull request against the main `opentelemetry-go-instrumentation` repo. Be sure to add the pull request ID to the entry you added to `CHANGELOG.md`. diff --git a/Makefile b/Makefile index 879f04db4..f7d0c44cb 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ CGO_ENABLED=0 .DEFAULT_GOAL := precommit .PHONY: precommit -precommit: license-header-check dependabot-generate go-mod-tidy golangci-lint-fix +precommit: license-header-check dependabot-generate go-mod-tidy golangci-lint-fix codespell # Tools $(TOOLS): @@ -208,3 +208,40 @@ check-clean-work-tree: echo 'Working tree is not clean, did you forget to run "make precommit", "make generate" or "make offsets"?'; \ exit 1; \ fi + +# Virtualized python tools via docker + +# The directory where the virtual environment is created. +VENVDIR := venv + +# The directory where the python tools are installed. +PYTOOLS := $(VENVDIR)/bin + +# The pip executable in the virtual environment. +PIP := $(PYTOOLS)/pip + +# The directory in the docker image where the current directory is mounted. +WORKDIR := /workdir + +# The python image to use for the virtual environment. +PYTHONIMAGE := python:3.11.3-slim-bullseye + +# Run the python image with the current directory mounted. +DOCKERPY := docker run --rm -v "$(CURDIR):$(WORKDIR)" -w $(WORKDIR) $(PYTHONIMAGE) + +# Create a virtual environment for Python tools. +$(PYTOOLS): +# The `--upgrade` flag is needed to ensure that the virtual environment is +# created with the latest pip version. + @$(DOCKERPY) bash -c "python3 -m venv $(VENVDIR) && $(PIP) install --upgrade pip" + +# Install python packages into the virtual environment. +$(PYTOOLS)/%: $(PYTOOLS) + @$(DOCKERPY) $(PIP) install -r requirements.txt + +CODESPELL = $(PYTOOLS)/codespell +$(CODESPELL): PACKAGE=codespell + +.PHONY: codespell +codespell: $(CODESPELL) + @$(DOCKERPY) $(CODESPELL) diff --git a/README.md b/README.md index 1bc6779aa..081b2399d 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ See the [contributing documentation](./CONTRIBUTING.md). OpenTelemetry Go Automatic Instrumentation is licensed under the terms of the [Apache Software License version 2.0]. See the [license file](./LICENSE) for more details. -Third-party licesnes and copyright notices can be found in the [LICENSES directory](./LICENSES). +Third-party licenses and copyright notices can be found in the [LICENSES directory](./LICENSES). [OpenTelemetry]: https://opentelemetry.io/ [Go]: https://go.dev/ diff --git a/docs/how-it-works.md b/docs/how-it-works.md index a9d340b26..3441cf7a5 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -109,7 +109,7 @@ The offsets-tracker generates the [offset_results.json](../internal/pkg/inject/o ### Uretprobes -One of the basic requirments of OpenTelemetry spans is to contain start timestamp and end timestamp. Getting those timestamps is possible by placing an eBPF code at the start and the end of the instrumented function. eBPF supports this requirement via uprobes and uretprobes. Uretprobes are used to invoke eBPF code at the end of the function. Unfortunately, uretprobes and Go [do not play well together](https://github.com/golang/go/issues/22008). +One of the basic requirements of OpenTelemetry spans is to contain start timestamp and end timestamp. Getting those timestamps is possible by placing an eBPF code at the start and the end of the instrumented function. eBPF supports this requirement via uprobes and uretprobes. Uretprobes are used to invoke eBPF code at the end of the function. Unfortunately, uretprobes and Go [do not play well together](https://github.com/golang/go/issues/22008). We overcome this issue by analyzing the target binary and detecting all the return statements in the instrumented functions. We then place a uprobe at the end of each return statement. This uprobe invokes the eBPF code that collects the end timestamp. diff --git a/internal/include/go_context.h b/internal/include/go_context.h index 0b2404f1b..ac011a8ed 100644 --- a/internal/include/go_context.h +++ b/internal/include/go_context.h @@ -106,7 +106,7 @@ static __always_inline void stop_tracking_span(struct span_context *sc, struct s void *ctx = bpf_map_lookup_elem(&tracked_spans_by_sc, sc); if (ctx == NULL) { - bpf_printk("stop_tracking_span: cant find span context"); + bpf_printk("stop_tracking_span: can't find span context"); return; } diff --git a/internal/include/otel_types.h b/internal/include/otel_types.h index 8caa5440a..badbe39df 100644 --- a/internal/include/otel_types.h +++ b/internal/include/otel_types.h @@ -31,7 +31,7 @@ volatile const u64 attr_type_int64slice; volatile const u64 attr_type_float64slice; volatile const u64 attr_type_stringslice; -/* Defintions should mimic structs defined in go.opentelemetry.io/otel/attribute */ +/* Definitions should mimic structs defined in go.opentelemetry.io/otel/attribute */ typedef struct go_otel_attr_value { u64 vtype; diff --git a/internal/include/uprobe.h b/internal/include/uprobe.h index 8f2a03cc8..967822df0 100644 --- a/internal/include/uprobe.h +++ b/internal/include/uprobe.h @@ -27,7 +27,7 @@ struct span_context psc; // Common flow for uprobe return: -// 1. Find consistend key for the current uprobe context +// 1. Find consistent key for the current uprobe context // 2. Use the key to lookup for the uprobe context in the uprobe_context_map // 3. Update the end time of the found span // 4. Submit the constructed event to the agent code using perf buffer events_map diff --git a/internal/pkg/instrumentation/bpf/github.com/segmentio/kafka-go/consumer/bpf/probe.bpf.c b/internal/pkg/instrumentation/bpf/github.com/segmentio/kafka-go/consumer/bpf/probe.bpf.c index f515d7434..dfc3032b2 100644 --- a/internal/pkg/instrumentation/bpf/github.com/segmentio/kafka-go/consumer/bpf/probe.bpf.c +++ b/internal/pkg/instrumentation/bpf/github.com/segmentio/kafka-go/consumer/bpf/probe.bpf.c @@ -146,7 +146,7 @@ int uprobe_FetchMessage(struct pt_regs *ctx) { 3. Blocking wait for message 4. internal kafka code after blocking 5. Return from FetchMessage - Steps 2-4 are executed in a seperate goroutine from the one the user of the library. + Steps 2-4 are executed in a separate goroutine from the one the user of the library. */ void *reader = get_argument(ctx, 1); void *context_data_ptr = get_Go_context(ctx, 3, 0, true); diff --git a/internal/pkg/instrumentation/bpf/github.com/segmentio/kafka-go/producer/bpf/probe.bpf.c b/internal/pkg/instrumentation/bpf/github.com/segmentio/kafka-go/producer/bpf/probe.bpf.c index 62d6bf493..dcebb24a4 100644 --- a/internal/pkg/instrumentation/bpf/github.com/segmentio/kafka-go/producer/bpf/probe.bpf.c +++ b/internal/pkg/instrumentation/bpf/github.com/segmentio/kafka-go/producer/bpf/probe.bpf.c @@ -125,7 +125,7 @@ static __always_inline int inject_kafka_header(void *message, struct kafka_heade static __always_inline long collect_kafka_attributes(void *message, struct message_attributes_t *attrs, bool collect_topic) { if (collect_topic) { - // Topic might be globaly set for a writer, or per message + // Topic might be globally set for a writer, or per message get_go_string_from_user_ptr((void *)(message + message_topic_pos), attrs->topic, sizeof(attrs->topic)); } @@ -188,7 +188,7 @@ int uprobe_WriteMessages(struct pt_regs *ctx) { // https://github.com/segmentio/kafka-go/blob/v0.2.3/message.go#L24C2-L24C6 // 2. the time.Time struct is 24 bytes. This looks to be correct for all the reasnobaly latest versions according to // https://github.com/golang/go/blame/master/src/time/time.go#L135 - // In the future if more libraries will need to get structs sizes we probably want to have simillar + // In the future if more libraries will need to get structs sizes we probably want to have similar // mechanism to the one we have for the offsets u16 msg_size = message_time_pos + 8 + 8 + 8; __builtin_memcpy(current_sc.TraceID, kafka_request->TraceID, TRACE_ID_SIZE); @@ -198,7 +198,7 @@ int uprobe_WriteMessages(struct pt_regs *ctx) { if (i >= msgs_array_len) { break; } - // Optionaly collect the topic, and always collect key + // Optionally collect the topic, and always collect key collect_kafka_attributes(msg_ptr, &kafka_request->msgs[i], !global_topic); // Generate span id for each message generate_random_bytes(kafka_request->msgs[i].SpanID, SPAN_ID_SIZE); @@ -216,7 +216,7 @@ int uprobe_WriteMessages(struct pt_regs *ctx) { bpf_map_update_elem(&kafka_events, &key, kafka_request, 0); - // don't need to start tracking the span, as we don't have a context to propagate localy + // don't need to start tracking the span, as we don't have a context to propagate locally return 0; } @@ -237,6 +237,6 @@ int uprobe_WriteMessages_Returns(struct pt_regs *ctx) { bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, kafka_request, sizeof(*kafka_request)); bpf_map_delete_elem(&kafka_events, &key); - // don't need to stop tracking the span, as we don't have a context to propagate localy + // don't need to stop tracking the span, as we don't have a context to propagate locally return 0; } \ No newline at end of file diff --git a/internal/pkg/instrumentation/bpffs/bpfsfs.go b/internal/pkg/instrumentation/bpffs/bpfsfs_linux.go similarity index 100% rename from internal/pkg/instrumentation/bpffs/bpfsfs.go rename to internal/pkg/instrumentation/bpffs/bpfsfs_linux.go diff --git a/internal/pkg/instrumentation/bpffs/bpfsfs_other.go b/internal/pkg/instrumentation/bpffs/bpfsfs_other.go new file mode 100644 index 000000000..6e189751c --- /dev/null +++ b/internal/pkg/instrumentation/bpffs/bpfsfs_other.go @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry 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. + + //go:build !linux + + package bpffs + + import "go.opentelemetry.io/auto/internal/pkg/process" + + // Stubs for non-linux systems + + func PathForTargetApplication(target *process.TargetDetails) string { + return "" + } + + func Mount(target *process.TargetDetails) error { + return nil + } + + func Cleanup(target *process.TargetDetails) error { + return nil + } + \ No newline at end of file diff --git a/internal/pkg/instrumentation/probe/probe.go b/internal/pkg/instrumentation/probe/probe.go index 804245e33..ab4b11fdc 100644 --- a/internal/pkg/instrumentation/probe/probe.go +++ b/internal/pkg/instrumentation/probe/probe.go @@ -227,7 +227,7 @@ func (i *Base[BPFObj, BPFEvent]) Close() error { // shutdown to avoid leaking system resources. type UprobeFunc[BPFObj any] func(symbol string, exec *link.Executable, target *process.TargetDetails, obj *BPFObj) ([]link.Link, error) -// Uprobe is an eBPF program that is attached in the entry point and/or the reutrn of a function. +// Uprobe is an eBPF program that is attached in the entry point and/or the return of a function. type Uprobe[BPFObj any] struct { // Sym is the symbol name of the function to attach the eBPF program to. Sym string diff --git a/internal/pkg/instrumentation/utils/kernel.go b/internal/pkg/instrumentation/utils/kernel_linux.go similarity index 73% rename from internal/pkg/instrumentation/utils/kernel.go rename to internal/pkg/instrumentation/utils/kernel_linux.go index e398f66a9..ee27e9a96 100644 --- a/internal/pkg/instrumentation/utils/kernel.go +++ b/internal/pkg/instrumentation/utils/kernel_linux.go @@ -19,9 +19,13 @@ import ( "errors" "fmt" "os" + "runtime" "strconv" "strings" "syscall" + "time" + + "golang.org/x/sys/unix" "github.com/hashicorp/go-version" ) @@ -184,3 +188,48 @@ func GetCPUCount() (int, error) { return 0, err } + +func EstimateBootTimeOffset() (bootTimeOffset int64, err error) { + // The datapath is currently using ktime_get_boot_ns for the pcap timestamp, + // which corresponds to CLOCK_BOOTTIME. To be able to convert the the + // CLOCK_BOOTTIME to CLOCK_REALTIME (i.e. a unix timestamp). + + // There can be an arbitrary amount of time between the execution of + // time.Now() and unix.ClockGettime() below, especially under scheduler + // pressure during program startup. To reduce the error introduced by these + // delays, we pin the current Go routine to its OS thread and measure the + // clocks multiple times, taking only the smallest observed difference + // between the two values (which implies the smallest possible delay + // between the two snapshots). + var minDiff int64 = 1<<63 - 1 + estimationRounds := 25 + runtime.LockOSThread() + defer runtime.UnlockOSThread() + for round := 0; round < estimationRounds; round++ { + var bootTimespec unix.Timespec + + // Ideally we would use __vdso_clock_gettime for both clocks here, + // to have as little overhead as possible. + // time.Now() will actually use VDSO on Go 1.9+, but calling + // unix.ClockGettime to obtain CLOCK_BOOTTIME is a regular system call + // for now. + unixTime := time.Now() + err = unix.ClockGettime(unix.CLOCK_BOOTTIME, &bootTimespec) + if err != nil { + return 0, err + } + + offset := unixTime.UnixNano() - bootTimespec.Nano() + diff := offset + if diff < 0 { + diff = -diff + } + + if diff < minDiff { + minDiff = diff + bootTimeOffset = offset + } + } + + return bootTimeOffset, nil +} diff --git a/internal/pkg/instrumentation/utils/kernel_test.go b/internal/pkg/instrumentation/utils/kernel_linux_test.go similarity index 100% rename from internal/pkg/instrumentation/utils/kernel_test.go rename to internal/pkg/instrumentation/utils/kernel_linux_test.go diff --git a/internal/pkg/instrumentation/utils/kernel_other.go b/internal/pkg/instrumentation/utils/kernel_other.go new file mode 100644 index 000000000..d4e6f2294 --- /dev/null +++ b/internal/pkg/instrumentation/utils/kernel_other.go @@ -0,0 +1,47 @@ +// Copyright The OpenTelemetry 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. + + //go:build !linux + + package utils + + import "github.com/hashicorp/go-version" + + // Stubs for non-linux systems + + func GetLinuxKernelVersion() (*version.Version, error) { + return &version.Version{}, nil + } + + type KernelLockdown uint8 + + const ( + KernelLockdownNone KernelLockdown = iota + 1 // Linux Kernel security lockdown mode [none] + KernelLockdownIntegrity // Linux Kernel security lockdown mode [integrity] + KernelLockdownConfidentiality // Linux Kernel security lockdown mode [confidentiality] + KernelLockdownOther // Linux Kernel security lockdown mode unknown + ) + + func KernelLockdownMode() KernelLockdown { + return 0 + } + + func GetCPUCount() (int, error) { + return 0, nil + } + + func EstimateBootTimeOffset() (bootTimeOffset int64, err error) { + return 0, nil + } + \ No newline at end of file diff --git a/internal/pkg/opentelemetry/controller.go b/internal/pkg/opentelemetry/controller.go index af7d895b3..402821e9b 100644 --- a/internal/pkg/opentelemetry/controller.go +++ b/internal/pkg/opentelemetry/controller.go @@ -16,14 +16,13 @@ package opentelemetry import ( "context" - "runtime" "time" "github.com/go-logr/logr" "go.opentelemetry.io/otel/trace" - "golang.org/x/sys/unix" "go.opentelemetry.io/auto/internal/pkg/instrumentation/probe" + "go.opentelemetry.io/auto/internal/pkg/instrumentation/utils" ) // Controller handles OpenTelemetry telemetry generation for events. @@ -84,7 +83,7 @@ func (c *Controller) convertTime(t int64) time.Time { func NewController(logger logr.Logger, tracerProvider trace.TracerProvider, ver string) (*Controller, error) { logger = logger.WithName("Controller") - bt, err := estimateBootTimeOffset() + bt, err := utils.EstimateBootTimeOffset() if err != nil { return nil, err } @@ -97,48 +96,3 @@ func NewController(logger logr.Logger, tracerProvider trace.TracerProvider, ver bootTime: bt, }, nil } - -func estimateBootTimeOffset() (bootTimeOffset int64, err error) { - // The datapath is currently using ktime_get_boot_ns for the pcap timestamp, - // which corresponds to CLOCK_BOOTTIME. To be able to convert the the - // CLOCK_BOOTTIME to CLOCK_REALTIME (i.e. a unix timestamp). - - // There can be an arbitrary amount of time between the execution of - // time.Now() and unix.ClockGettime() below, especially under scheduler - // pressure during program startup. To reduce the error introduced by these - // delays, we pin the current Go routine to its OS thread and measure the - // clocks multiple times, taking only the smallest observed difference - // between the two values (which implies the smallest possible delay - // between the two snapshots). - var minDiff int64 = 1<<63 - 1 - estimationRounds := 25 - runtime.LockOSThread() - defer runtime.UnlockOSThread() - for round := 0; round < estimationRounds; round++ { - var bootTimespec unix.Timespec - - // Ideally we would use __vdso_clock_gettime for both clocks here, - // to have as little overhead as possible. - // time.Now() will actually use VDSO on Go 1.9+, but calling - // unix.ClockGettime to obtain CLOCK_BOOTTIME is a regular system call - // for now. - unixTime := time.Now() - err = unix.ClockGettime(unix.CLOCK_BOOTTIME, &bootTimespec) - if err != nil { - return 0, err - } - - offset := unixTime.UnixNano() - bootTimespec.Nano() - diff := offset - if diff < 0 { - diff = -diff - } - - if diff < minDiff { - minDiff = diff - bootTimeOffset = offset - } - } - - return bootTimeOffset, nil -} diff --git a/internal/pkg/process/binary/ret_other.go b/internal/pkg/process/binary/ret_other.go new file mode 100644 index 000000000..dd96419e3 --- /dev/null +++ b/internal/pkg/process/binary/ret_other.go @@ -0,0 +1,24 @@ +// Copyright The OpenTelemetry 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. + + //go:build !linux + + package binary + + // Stubs for non-linux systems + + func findRetInstructions(data []byte) ([]uint64, error) { + return nil, nil + } + \ No newline at end of file diff --git a/internal/pkg/process/ptrace/ptrace_linux.go b/internal/pkg/process/ptrace/ptrace_linux.go index 9ee27d344..98112ad17 100644 --- a/internal/pkg/process/ptrace/ptrace_linux.go +++ b/internal/pkg/process/ptrace/ptrace_linux.go @@ -76,7 +76,7 @@ func NewTracedProgram(pid int, logger logr.Logger) (*TracedProgram, error) { tidMap := make(map[int]bool) retryCount := make(map[int]int) - // iterate over the thread group, until it doens't change + // iterate over the thread group, until it doesn't change // // we have tried several ways to ensure that we have stopped all the tasks: // 1. iterating over and over again to make sure all of them are tracee diff --git a/internal/pkg/process/ptrace/ptrace_other.go b/internal/pkg/process/ptrace/ptrace_other.go new file mode 100644 index 000000000..fbd926551 --- /dev/null +++ b/internal/pkg/process/ptrace/ptrace_other.go @@ -0,0 +1,48 @@ +// Copyright The OpenTelemetry 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. + + //go:build !linux + + package ptrace + + import "github.com/go-logr/logr" + + // Stubs for non-linux systems + + type TracedProgram struct {} + + func NewTracedProgram(pid int, logger logr.Logger) (*TracedProgram, error) { + return nil, nil + } + + func (p *TracedProgram) Detach() error { + return nil + } + + func (p *TracedProgram) SetMemLockInfinity() error { + return nil + } + + func (p *TracedProgram) Mmap(length uint64, fd uint64) (uint64, error) { + return 0, nil + } + + func (p *TracedProgram) Madvise(addr uint64, length uint64) error { + return nil + } + + func (p *TracedProgram) Mlock(addr uint64, length uint64) error { + return nil + } + \ No newline at end of file diff --git a/internal/pkg/structfield/json.go b/internal/pkg/structfield/json.go index 62f9963a5..240a90ebf 100644 --- a/internal/pkg/structfield/json.go +++ b/internal/pkg/structfield/json.go @@ -107,7 +107,7 @@ func find[T any](slice *[]*T, f func(*T) bool) *T { // mergeSorted merges the two sorted slices slice0 and slice1 using the cmp // function to compare elements. // -// The cmp function needs to return negative values when ab, and 0 when a==b. func mergeSorted[T any](slice0, slice1 []T, cmp func(a, b T) int) []T { merged := make([]T, 0, len(slice0)+len(slice1)) diff --git a/internal/test/e2e/gin/verify.bats b/internal/test/e2e/gin/verify.bats index 89e41b035..859df63d0 100644 --- a/internal/test/e2e/gin/verify.bats +++ b/internal/test/e2e/gin/verify.bats @@ -34,7 +34,7 @@ SCOPE="go.opentelemetry.io/auto/net/http" assert_equal "$result" '"/hello-gin"' } -@test "server :: includes hhttp.response.status_code attribute" { +@test "server :: includes http.response.status_code attribute" { result=$(server_span_attributes_for ${SCOPE} | jq "select(.key == \"http.response.status_code\").value.intValue") assert_equal "$result" '"200"' } diff --git a/internal/test/e2e/nethttp/verify.bats b/internal/test/e2e/nethttp/verify.bats index a27266566..ce191b100 100644 --- a/internal/test/e2e/nethttp/verify.bats +++ b/internal/test/e2e/nethttp/verify.bats @@ -34,7 +34,7 @@ SCOPE="go.opentelemetry.io/auto/net/http" assert_equal "$result" '"/hello/42"' } -@test "server :: includes hhttp.response.status_code attribute" { +@test "server :: includes http.response.status_code attribute" { result=$(server_span_attributes_for ${SCOPE} | jq "select(.key == \"http.response.status_code\").value.intValue") assert_equal "$result" '"200"' } diff --git a/internal/test/e2e/nethttp_custom/verify.bats b/internal/test/e2e/nethttp_custom/verify.bats index 993ea302a..6ab343ddc 100644 --- a/internal/test/e2e/nethttp_custom/verify.bats +++ b/internal/test/e2e/nethttp_custom/verify.bats @@ -34,7 +34,7 @@ SCOPE="go.opentelemetry.io/auto/net/http" assert_equal "$result" '"/hello"' } -@test "server :: includes hhttp.response.status_code attribute" { +@test "server :: includes http.response.status_code attribute" { result=$(server_span_attributes_for ${SCOPE} | jq "select(.key == \"http.response.status_code\").value.intValue") assert_equal "$result" '"200"' } diff --git a/internal/tools/inspect/inspector.go b/internal/tools/inspect/inspector.go index e716e3ace..a2aebc2b8 100644 --- a/internal/tools/inspect/inspector.go +++ b/internal/tools/inspect/inspector.go @@ -87,7 +87,7 @@ func (i *Inspector) AddManifest(manifest Manifest) error { goVer := manifest.Application.GoVerions if goVer == nil { - // Passsing nil to newBuilder will mean the application is built with + // Passing nil to newBuilder will mean the application is built with // the latest version of Go. b := newBuilder(i.log, i.client, nil) for _, ver := range manifest.Application.Versions { diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..ab09daf9d --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +codespell==2.3.0