8000 Arguments not passed to span attributes · Issue #316 · equinix-labs/otel-cli · GitHub
[go: up one dir, main page]

Skip to content

Arguments not passed to span attributes #316

Closed

Description

@tbrockman

Hey! Was just testing the tool, not sure if my expectations are incorrect or I've configured something incorrectly, but my spans don't appear to contain any attributes for the arguments passed to the command being executed, for example:

export OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317
otel-cli exec --service "otel-cli" --name "echo" --attrs test.attr=abc -- echo "a" "b" "test"
a b test

And in a locally running otel-collector-contrib with debug logs enabled:

otel-collector-1  | 2024-03-30T16:39:11.684Z    info    TracesExporter  {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 1, "spans": 1} 
otel-collector-1  | 2024-03-30T16:39:11.684Z    info    ResourceSpans #0
otel-collector-1  | Resource SchemaURL: https://opentelemetry.io/schemas/1.17.0    
otel-collector-1  | Resource attributes:
otel-collector-1  |      -> service.name: Str(otel-cli)
otel-collector-1  | ScopeSpans #0
otel-collector-1  | ScopeSpans SchemaURL: https://opentelemetry.io/schemas/1.17.0  
otel-collector-1  | InstrumentationScope github.com/equinix-labs/otel-cli unknown  
otel-collector-1  | Span #0
otel-collector-1  |     Trace ID       : 1ff0a8598155a3557e3a5e1cc7cc85b7
otel-collector-1  |     Parent ID      :
otel-collector-1  |     ID             : a1b90937c0f99e17
otel-collector-1  |     Name           : echo
otel-collector-1  |     Kind           : Client
otel-collector-1  |     Start time     : 2024-03-30 16:39:11.675027667 +0000 UTC   
otel-collector-1  |     End time       : 2024-03-30 16:39:11.676319855 +0000 UTC   
otel-collector-1  |     Status code    : Unset
otel-collector-1  |     Status message :
otel-collector-1  | Attributes:
otel-collector-1  |      -> test.attr: Str(abc)
otel-collector-1  |     {"kind": "exporter", "data_type": "traces", "name": "debug"}
otel-collector-1  | 2024-03-30T16:39:11.686Z    info    zapgrpc/zapgrpc.go:178  [transport] [server-transport 0xc00076d1e0] Closing: EOF   {"grpc_log": true}
otel-collector-1  | 2024-03-30T16:39:11.686Z    info    zapgrpc/zapgrpc.go:178  [transport] [server-transport 0xc00076d1e0] loopyWriter exiting with error: connection error: desc = "transport is closing"   {"grpc_log": true}

Which only seems to contain the manually specified attribute (and will contains no attributes at all without it).

Is this expected?

No --version to share, but I installed it today with:

go install github.com/equinix-labs/otel-cli@latest

Activity

  1. tobert commented on Mar 31, 2024

    @tobert
    Contributor

    Looks like it's there?

    otel-collector-1  | Attributes:
    otel-collector-1  |      -> test.attr: Str(abc)
    

    Is that not where you expect to see them?

    I will double check the test suite in the morning to make sure there is good coverage. If it's not working right and/or there is a testing gap I will fix it right away.

  2. tobert commented on Apr 1, 2024

    @tobert
    Contributor

    Looks like --attrs is effectively integration tested, but could use a couple dedicated tests in case I missed something:

    CliArgs: []string{"span", "event", "--name", "an event happened", "--attrs", "ima=now,mondai=problem", "--sockdir", "."},

    CliArgs: []string{"span", "background", "--timeout", "1s", "--sockdir", ".", "--attrs", "abc=def"},

    "--attrs", "ghi=jkl,abc=def",

  3. tbrockman commented on Apr 1, 2024

    @tbrockman
    Author

    @tobert Okay so it seems like my expectation was wrong? I assumed that in my example above that with -- echo "a" "b" "test" the CLI would automatically add "a","b", and "test" as span attributes, something like:

    otel-collector-1  | Attributes:
    otel-collector-1  |      -> test.attr: Str(abc)
    otel-collector-1  |      -> process.command_args: List(Str(a), Str(b), Str(test)) # I'm not sure off-hand if this is how a string list would be output, but you get the idea
    # see: https://opentelemetry.io/docs/specs/semconv/attributes-registry/process/
  4. added a commit that references this issue on Apr 1, 2024
  5. tobert commented on Apr 1, 2024

    @tobert
    Contributor

    @tobert Okay so it seems like my expectation was wrong? I assumed that in my example above that with -- echo "a" "b" "test" the CLI would automatically add "a","b", and "test" as span attributes, something like:

    otel-collector-1  | Attributes:
    otel-collector-1  |      -> test.attr: Str(abc)
    otel-collector-1  |      -> process.command_args: List(Str(a), Str(b), Str(test)) # I'm not sure off-hand if this is how a string list would be output, but you get the idea
    # see: https://opentelemetry.io/docs/specs/semconv/attributes-registry/process/

    Yeah, it should be sending command and arguments (as CSV) attributes per https://github.com/equinix-labs/otel-cli/blob/c3f7dc6e92ff1a9896a845c14ad510f48afd84ea/otelcli/exec.go#L112C1-L113C1

    That might not be tested right now. Will add coverage and see what's up.

    The attributes & format should also get updated to match semconv. That at least calls for a minor version IMO. First I'll make sure what's there works as expected, then change the names with a minor release.

  6. tobert commented on Apr 1, 2024

    @tobert
    Contributor

    OK, those attributes haven't worked in a while, so I'll fix up the semconv along with the testing & code.

    Thanks for the bug report!

  7. tobert commented on Apr 1, 2024

    @tobert
    Contributor

    I've released 0.4.5 to fix both sending attributes and aligning with the semantics spec.

    There's a specific regression test for this issue: https://github.com/equinix-labs/otel-cli/blob/main/data_for_test.go#L552

    Release: https://github.com/equinix-labs/otel-cli/releases/tag/v0.4.5

  8. tbrockman commented on Apr 1, 2024

    @tbrockman
    Author

    Thanks for the quick turn-around! Glad I took the time to bring it up 😬

  9. tobert commented on Apr 2, 2024

    @tobert
    Contributor

    Please let me know if you run into any more trouble and thanks again for the report and dialogue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata 4023

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0