You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
d5f403cab5
## Description Address issue #7808 by plumbing `context.Context` through `resource.Environment` and `resource.Default`. Currently, these functions hardcode `context.Background()`, which prevents detectors (especially those that might perform network lookups or OS calls) from respecting timeouts or cancellations provided by the caller. ## Changes - Adds `EnvironmentWithContext(ctx context.Context)` as a new public function. - Adds `DefaultWithContext(ctx context.Context)` as a new public function. - Maintains backward compatibility by making `Environment()` and `Default()` thin wrappers around the new WithContext variants. ## Testing - Added unit tests in `sdk/resource/resource_test.go` to verify the new functions. - Verified that all `sdk/resource` tests pass. - Verified that make `golangci-lint` passes repository-wide. Fixes #7808 --------- Co-authored-by: Damien Mathieu <42@dmathieu.com>