Skip to content

Commit

Permalink
#108 fix span background attrs (#116)
Browse files Browse the repository at this point in the history
* add a failing test for span background --attrs

Actually modifying an existing test to use the feature.

* add missing func to support span background --attrs

test still fails but fails less badly, next to fix the map[string]string
translations

* fix test data so test passes

The test was getting the right data but failing becaues of a TODO in
`otlpserver/server.go`. That TODO involves building a type switch and
supporting at least a subset of otel types so rather than doing that
right now, just have the test accept the format with the type in it.

* is_sampled was never available in span data

This never should have worked. Next commit will fix the span data
checker.

* rework checkSpanData for correctness

Working on a test for #109 it became clear there were some faults in how
checkSpanData worked. For one it wasn't validating that an expected
'is_sampled' was actually in the received span. It turns out that field
was never available for comparison. That check was added.

Also only the regex fields were being checked because of looping over
that map so I moved it up to a global map and now loop over received
fields and compare against instead of the other way around. This should
be more exhaustive.

* add failing test for #109

* update test

The type tags leaking through in strings was fixed in #120 so
it doesn't have to be in the fixture strings anymore.
  • Loading branch information
tobert authored Jan 26, 2023
1 parent 99c9242 commit 4256644
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions data_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ var suites = []FixtureSuite{
{
Name: "otel-cli span background (recording)",
Config: FixtureConfig{
CliArgs: []string{"span", "background", "--timeout", "1s", "--sockdir", "."},
CliArgs: []string{"span", "background", "--timeout", "1s", "--sockdir", ".", "--attrs", "abc=def"},
Env: map[string]string{"OTEL_EXPORTER_OTLP_ENDPOINT": "{{endpoint}}"},
TestTimeoutMs: 2000,
Background: true,
Expand All @@ -336,8 +336,9 @@ var suites = []FixtureSuite{
Expect: Results{
Config: otelcli.DefaultConfig(),
SpanData: map[string]string{
"span_id": "*",
"trace_id": "*",
"span_id": "*",
"trace_id": "*",
"attributes": `abc=def`, // weird format because of limitation in OTLP server
},
Spans: 1,
Events: 1,
Expand Down
1 change: 1 addition & 0 deletions otelcli/span_background.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func init() {
addCommonParams(spanBgCmd)
addSpanParams(spanBgCmd)
addClientParams(spanBgCmd)
addAttrParams(spanBgCmd)
}

// spanBgSockfile returns the full filename for the socket file under the
Expand Down

0 comments on commit 4256644

Please sign in to comment.