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

fix: return error if target binary is not set #339

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -8,6 +8,10 @@ OpenTelemetry Go Automatic Instrumentation adheres to [Semantic Versioning](http

## [Unreleased]

### Changed

- Fix runtime panic if OTEL_GO_AUTO_TARGET_EXE is not set. ([#339](https://github.com/open-telemetry/opentelemetry-go-instrumentation/pull/339))

### Deprecated

- The `go.opentelemetry.io/auto/examples/rolldice` module is deprecated.
Expand Down
10 changes: 10 additions & 0 deletions instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package auto

import (
"context"
"fmt"
"os"

"go.opentelemetry.io/auto/internal/pkg/instrumentors"
Expand All @@ -36,6 +37,12 @@ type Instrumentation struct {
manager *instrumentors.Manager
}

var (
// Error message returned when instrumentation is launched without a taget
rogercoll marked this conversation as resolved.
Show resolved Hide resolved
// binary.
errUndefinedTarget = fmt.Errorf("undefined target Go binary, consider setting the %s environment variable pointing to the target binary to instrument", envTargetExeKey)
)

// NewInstrumentation returns a new [Instrumentation] configured with the
// provided opts.
func NewInstrumentation(opts ...InstrumentationOption) (*Instrumentation, error) {
Expand Down Expand Up @@ -119,6 +126,9 @@ func (c instConfig) applyEnv() instConfig {
}

func (c instConfig) validate() error {
if c.target == nil {
return errUndefinedTarget
}
return c.target.Validate()
}

Expand Down
Loading