Skip to content

ec2 detector does not respect context timeout #5635

Open
@OrHayat

Description

@OrHayat

Description

ec2 detector does not respect context timeout and it wait ~30 seconds on non-ec2 machines(default)

Environment

any env that is not on ec2 machine

Steps To Reproduce

  1. Using this code snippet
    ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
    defer cancel()
    ctx:=context.WithTimeOut(ctx)
    ec2detector.NewResourceDetector().Detect(ctx)
  2. Run this code on any machine that is NOT in aws ec2

Expected behavior

expected the code to stop the detection attempt much much faster(2 seconds) but there issues in the ec2 detector code that dont allow this to work as expected

  1. it uses the soon to be deprecated aws v1 sdk that dont force you to pass context to aws operation(you can still but the code didnt did that)

  2. also if this will be fixed then there is issue in the opentelemtry resource.detect function(in the
    opentelemetry-go/sdk/resource package)
    that will mean that every detector that was specified after this detector when creating new resource will get context that expired because they dont run in parallel.
    but that issue is for the main open-telemetry repo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions