Skip to content

Commit 4b55aa7

Browse files
committed
Add package constraints to otelglobal uprobes
1 parent 4428c3d commit 4b55aa7

File tree

1 file changed

+41
-3
lines changed
  • internal/pkg/instrumentation/bpf/go.opentelemetry.io/otel/traceglobal

1 file changed

+41
-3
lines changed

internal/pkg/instrumentation/bpf/go.opentelemetry.io/otel/traceglobal/probe.go

+41-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ import (
3636
const (
3737
// pkg is the package being instrumented.
3838
pkg = "go.opentelemetry.io/otel/internal/global"
39+
40+
// Minimum version of go.opentelemetry.io/otel that supports using the
41+
// go.opentelemetry.io/auto/sdk in the global API.
42+
minAutoSDK = "1.33.0"
43+
)
44+
45+
var (
46+
otelWithAutoSDK = probe.PackageConstrainst{
47+
Package: "go.opentelemetry.io/otel",
48+
Constraints: version.MustConstraints(
49+
version.NewConstraint(fmt.Sprintf(">= %s", minAutoSDK)),
50+
),
51+
FailureMode: probe.FailureModeIgnore,
52+
}
53+
otelWithoutAutoSDK = probe.PackageConstrainst{
54+
Package: "go.opentelemetry.io/otel",
55+
Constraints: version.MustConstraints(
56+
version.NewConstraint(fmt.Sprintf("< %s", minAutoSDK)),
57+
),
58+
FailureMode: probe.FailureModeIgnore,
59+
}
3960
)
4061

4162
// New returns a new [probe.Probe].
@@ -46,9 +67,11 @@ func New(logger *slog.Logger) probe.Probe {
4667
}
4768

4869
uprobeNewStart := &probe.Uprobe{
49-
Sym: "go.opentelemetry.io/otel/internal/global.(*tracer).newSpan",
50-
EntryProbe: "uprobe_newStart",
51-
FailureMode: probe.FailureModeWarn,
70+
Sym: "go.opentelemetry.io/otel/internal/global.(*tracer).newSpan",
71+
EntryProbe: "uprobe_newStart",
72+
PackageConstrainsts: []probe.PackageConstrainst{
73+
otelWithAutoSDK,
74+
},
5275
}
5376

5477
c := &converter{
@@ -127,25 +150,40 @@ func New(logger *slog.Logger) probe.Probe {
127150
Sym: "go.opentelemetry.io/otel/internal/global.(*tracer).Start",
128151
EntryProbe: "uprobe_Start",
129152
ReturnProbe: "uprobe_Start_Returns",
153+
PackageConstrainsts: []probe.PackageConstrainst{
154+
otelWithoutAutoSDK,
155+
},
130156
},
131157
{
132158
Sym: "go.opentelemetry.io/otel/internal/global.(*nonRecordingSpan).End",
133159
EntryProbe: "uprobe_End",
160+
PackageConstrainsts: []probe.PackageConstrainst{
161+
otelWithoutAutoSDK,
162+
},
134163
},
135164
{
136165
Sym: "go.opentelemetry.io/otel/internal/global.(*nonRecordingSpan).SetAttributes",
137166
EntryProbe: "uprobe_SetAttributes",
138167
FailureMode: probe.FailureModeIgnore,
168+
PackageConstrainsts: []probe.PackageConstrainst{
169+
otelWithoutAutoSDK,
170+
},
139171
},
140172
{
141173
Sym: "go.opentelemetry.io/otel/internal/global.(*nonRecordingSpan).SetStatus",
142174
EntryProbe: "uprobe_SetStatus",
143175
FailureMode: probe.FailureModeIgnore,
176+
PackageConstrainsts: []probe.PackageConstrainst{
177+
otelWithoutAutoSDK,
178+
},
144179
},
145180
{
146181
Sym: "go.opentelemetry.io/otel/internal/global.(*nonRecordingSpan).SetName",
147182
EntryProbe: "uprobe_SetName",
148183
FailureMode: probe.FailureModeIgnore,
184+
PackageConstrainsts: []probe.PackageConstrainst{
185+
otelWithoutAutoSDK,
186+
},
149187
},
150188
},
151189
SpecFn: loadBpf,

0 commit comments

Comments
 (0)