Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for Go < 1.19 instrumentation #1815

Merged
merged 10 commits into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ OpenTelemetry Go Automatic Instrumentation adheres to [Semantic Versioning](http
- Support `golang.org/x/net` `0.35.0`. ([#1783](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/1783))
- Support Go `1.24.0`. ([#1795](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/1795), [#1798](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/1798))

### Changed

- Unused support for instrumentation of Go < 1.19 has been dropped. (#1815)

### Fixed

- `database/sql` instrumentation for Go < `1.17`. (#1772)
Expand Down
4 changes: 2 additions & 2 deletions COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Tracing instrumentation is provided for the following Go libraries.

Supported version ranges:

- `go1.12` to `go1.24.0`
- `go1.19` to `go1.24.0`

### github.com/segmentio/kafka-go

Expand All @@ -54,4 +54,4 @@ Supported version ranges:

Supported version ranges:

- `go1.12` to `go1.24.0`
- `go1.19` to `go1.24.0`
43 changes: 1 addition & 42 deletions internal/include/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@

#endif

// Injected in init
volatile const bool is_registers_abi;

static __always_inline void *get_argument_by_reg(struct pt_regs *ctx, int index)
static __always_inline void *get_argument(struct pt_regs *ctx, int index)
{
switch (index)
{
Expand All @@ -75,42 +72,4 @@ static __always_inline void *get_argument_by_reg(struct pt_regs *ctx, int index)
}
}

static __always_inline void *get_argument_by_stack(struct pt_regs *ctx, int index)
{
void *ptr = 0;
bpf_probe_read(&ptr, sizeof(ptr), (void *)(PT_REGS_SP(ctx) + (index * 8)));
return ptr;
}

static __always_inline void *get_argument(struct pt_regs *ctx, int index)
{
if (is_registers_abi)
{
return get_argument_by_reg(ctx, index);
}

return get_argument_by_stack(ctx, index);
}

// Every span created by the auto instrumentation should contain end timestamp.
// This end timestamp is recorded at the end of probed function by editing the struct that was created at the beginning.
// Usually probes create an eBPF map to store the span struct and retrieve it at the end of the function.
// Consistent key is used as a key for that map.
// For Go < 1.17: consistent key is the address of context.Context.
// For Go >= 1.17: consistent key is the goroutine address.
static __always_inline void *get_consistent_key(struct pt_regs *ctx, void *contextContext)
{
if (is_registers_abi)
{
return (void *)GOROUTINE(ctx);
}

return contextContext;
}

static __always_inline bool is_register_abi()
{
return is_registers_abi;
}

#endif
6 changes: 2 additions & 4 deletions internal/include/uprobe.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
// 4. Submit the constructed event to the agent code using perf buffer events_map
// 5. Delete the span from the global active spans map (in case the span is not tracked in the active spans map, this will be a no-op)
// 6. Delete the span from the uprobe_context_map
#define UPROBE_RETURN(name, event_type, uprobe_context_map, events_map, context_pos, context_offset, passed_as_arg) \
#define UPROBE_RETURN(name, event_type, uprobe_context_map) \
SEC("uprobe/##name##") \
int uprobe_##name##_Returns(struct pt_regs *ctx) { \
struct go_iface go_context = {0}; \
get_Go_context(ctx, context_pos, context_offset, passed_as_arg, &go_context); \
void *key = get_consistent_key(ctx, go_context.data); \
void *key = (void *)GOROUTINE(ctx); \
event_type *event = bpf_map_lookup_elem(&uprobe_context_map, &key); \
if (event == NULL) { \
bpf_printk("event is NULL in ret probe"); \
Expand Down
18 changes: 3 additions & 15 deletions internal/pkg/inject/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ var (
)

const (
keyIsRegistersABI = "is_registers_abi"
keyTotalCPUs = "total_cpus"
keyStartAddr = "start_addr"
keyEndAddr = "end_addr"
keyTotalCPUs = "total_cpus"
keyStartAddr = "start_addr"
keyEndAddr = "end_addr"
)

func init() {
Expand Down Expand Up @@ -108,17 +107,6 @@ func (o errOpt) apply(map[string]interface{}) error {
return o.err
}

// WithRegistersABI returns an option that will set the "is_registers_abi" to
// value. This information can be determined from the IsRegistersABI method of
// the TargetDetails in "go.opentelemetry.io/auto/internal/pkg/process".
//
// Commonly this is called like the following:
//
// WithRegistersABI(target.IsRegistersABI())
func WithRegistersABI(value bool) Option {
return option{keyIsRegistersABI: value}
}

// WithAllocationDetails returns an option that will set "total_cpus",
// "start_addr", and "end_addr".
func WithAllocationDetails(details process.AllocationDetails) Option {
Expand Down
11 changes: 0 additions & 11 deletions internal/pkg/inject/consts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@ import (
"go.opentelemetry.io/auto/internal/pkg/structfield"
)

func TestWithRegistersABI(t *testing.T) {
opts := []Option{WithRegistersABI(true)}
got, err := newConsts(opts)
require.NoError(t, err)
require.Contains(t, got, keyIsRegistersABI)

v := got[keyIsRegistersABI]
require.IsType(t, *(new(bool)), v)
assert.True(t, v.(bool))
}

func TestWithAllocationDetails(t *testing.T) {
const start, end, nCPU uint64 = 1, 2, 3
details := process.AllocationDetails{
Expand Down
Loading
Loading