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

add tests for attrs at end of bg trace #269

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
120 changes: 120 additions & 0 deletions data_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,126 @@ var suites = []FixtureSuite{
Expect: Results{Config: otelcli.DefaultConfig()},
},
},
// otel-cli span background, add attrs on span end
{
{
Name: "otel-cli span background (recording) with attrs added on end",
Config: FixtureConfig{
CliArgs: []string{"span", "background", "--timeout", "1s", "--sockdir", "."},
Env: map[string]string{"OTEL_EXPORTER_OTLP_ENDPOINT": "{{endpoint}}"},
TestTimeoutMs: 2000,
Background: true,
Foreground: false,
},
Expect: Results{
Config: otelcli.DefaultConfig(),
SpanData: map[string]string{
"span_id": "*",
"trace_id": "*",
"attributes": `abc=def,ghi=jkl`, // weird format because of limitation in OTLP server
},
SpanCount: 1,
},
},
{
Name: "otel-cli span end",
Config: FixtureConfig{
CliArgs: []string{
"span", "end",
"--sockdir", ".",
"--attrs", "ghi=jkl,abc=def",
},
},
Expect: Results{Config: otelcli.DefaultConfig()},
},
{
Name: "otel-cli span background (recording) with attrs added on end",
Config: FixtureConfig{
Foreground: true, // fg
},
Expect: Results{Config: otelcli.DefaultConfig()},
},
},
// otel-cli span background with attrs, append attrs on span end
{
{
Name: "otel-cli span background (recording) with attrs append on end",
Config: FixtureConfig{
CliArgs: []string{"span", "background", "--timeout", "1s", "--sockdir", ".", "--attrs", "abc=def"},
Env: map[string]string{"OTEL_EXPORTER_OTLP_ENDPOINT": "{{endpoint}}"},
TestTimeoutMs: 2000,
Background: true,
Foreground: false,
},
Expect: Results{
Config: otelcli.DefaultConfig(),
SpanData: map[string]string{
"span_id": "*",
"trace_id": "*",
"attributes": `abc=def,ghi=jkl`, // weird format because of limitation in OTLP server
},
SpanCount: 1,
},
},
{
Name: "otel-cli span end",
Config: FixtureConfig{
CliArgs: []string{
"span", "end",
"--sockdir", ".",
"--attrs", "ghi=jkl",
},
},
Expect: Results{Config: otelcli.DefaultConfig()},
},
{
Name: "otel-cli span background (recording) with attrs append on end",
Config: FixtureConfig{
Foreground: true, // fg
},
Expect: Results{Config: otelcli.DefaultConfig()},
},
},
// otel-cli span background, modify and add attrs on span end
{
{
Name: "otel-cli span background (recording) with attrs modified and added on end",
Config: FixtureConfig{
CliArgs: []string{"span", "background", "--timeout", "1s", "--sockdir", ".", "--attrs", "abc=123"},
Env: map[string]string{"OTEL_EXPORTER_OTLP_ENDPOINT": "{{endpoint}}"},
TestTimeoutMs: 2000,
Background: true,
Foreground: false,
},
Expect: Results{
Config: otelcli.DefaultConfig(),
SpanData: map[string]string{
"span_id": "*",
"trace_id": "*",
"attributes": `abc=def,ghi=jkl`, // weird format because of limitation in OTLP server
},
SpanCount: 1,
},
},
{
Name: "otel-cli span end",
Config: FixtureConfig{
CliArgs: []string{
"span", "end",
"--sockdir", ".",
"--attrs", "ghi=jkl,abc=def",
},
},
Expect: Results{Config: otelcli.DefaultConfig()},
},
{
Name: "otel-cli span background (recording) with attrs modified and added on end",
Config: FixtureConfig{
Foreground: true, // fg
},
Expect: Results{Config: otelcli.DefaultConfig()},
},
},
// otel-cli exec runs echo
{
{
Expand Down
1 change: 1 addition & 0 deletions otelcli/span_background_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ func (bgs *bgServer) Run() {
// Shutdown does a controlled shutdown of the background server. Blocks until
// the server is turned down cleanly and it's safe to exit.
func (bgs *bgServer) Shutdown() {
os.Remove(bgs.sockfile)
close(bgs.quit)
bgs.listener.Close()
bgs.wg.Wait()
Expand Down