Add tests for feature custom resource attributes

This commit is contained in:
puhre 2024-05-28 14:35:09 +02:00
parent 158c55feff
commit c39f33420b
4 changed files with 32 additions and 4 deletions

View file

@ -47,6 +47,10 @@ http {
batch_count 1;
}
otel_resource_attr {
service.namespace test;
}
otel_service_name test_server;
otel_trace on;
@ -159,7 +163,7 @@ foreach my $name ('localhost') {
or die "Can't create certificate for $name: $!\n";
}
$t->try_run('no OTel module')->plan(69);
$t->try_run('no OTel module')->plan(70);
###############################################################################
@ -211,6 +215,9 @@ is(scalar keys %{$$batch1{scope_spans}}, 5, 'batch1 size - trace on');
is(get_attr("service.name", "string_value",
$$batch0{resource}),
'test_server', 'service.name - trace on');
is(get_attr("service.namespace", "string_value",
$$batch0{resource}),
'test', 'service.namespace - trace on');
is($$spans{span0}{name}, '"default_location"', 'span.name - trace on');
#validate http metrics

View file

@ -48,6 +48,10 @@ http {
batch_count 2;
}
otel_resource_attr {
service.namespace test;
}
otel_service_name test_server;
otel_trace on;
@ -159,7 +163,7 @@ foreach my $name ('localhost') {
or die "Can't create certificate for $name: $!\n";
}
$t->try_run('no OTel module')->plan(56);
$t->try_run('no OTel module')->plan(57);
###############################################################################
@ -211,6 +215,9 @@ is(scalar keys %{$$batch1{scope_spans}}, 5, 'batch1 size - trace on');
is(get_attr("service.name", "string_value",
$$batch0{resource}),
'test_server', 'service.name - trace on');
is(get_attr("service.namespace", "string_value",
$$batch0{resource}),
'test', 'service.namespace - trace on');
is($$spans{span0}{name}, '"default_location"', 'span.name - trace on');
#validate metrics

View file

@ -46,6 +46,10 @@ http {
batch_count 2;
}
otel_resource_attr {
service.namespace test;
}
otel_service_name test_server;
otel_trace on;
@ -156,7 +160,7 @@ foreach my $name ('localhost') {
or die "Can't create certificate for $name: $!\n";
}
$t->try_run('no OTel module')->plan(69);
$t->try_run('no OTel module')->plan(70);
###############################################################################
@ -203,6 +207,9 @@ is(scalar keys %{$$batch1{scope_spans}}, 5, 'batch1 size - trace on');
#validate general attributes
is(get_attr("service.name", "string_value",
$$batch0{resource}), 'test_server', 'service.name - trace on');
is(get_attr("service.namespace", "string_value",
$$batch0{resource}),
'test', 'service.namespace - trace on');
is($$spans{span0}{name}, '"default_location"', 'span.name - trace on');
#validate http metrics

View file

@ -48,6 +48,10 @@ http {
batch_count 2;
}
otel_resource_attr {
service.namespace test;
}
otel_service_name test_server;
otel_trace on;
@ -162,7 +166,7 @@ open STDERR, ">&", \*OLDERR;
$t->waitforsocket('127.0.0.1:' . port(4317)) or
die 'No otel collector open socket';
$t->try_run('no OTel module')->plan(69);
$t->try_run('no OTel module')->plan(70);
###############################################################################
@ -209,6 +213,9 @@ is(scalar @{${JSON::PP::decode_json($batches[1])}{"resourceSpans"}[0]
is(get_attr("service.name", "stringValue",
$$batch_json{resourceSpans}[0]{resource}),
'test_server', 'service.name - trace on');
is(get_attr("service.namespace", "stringValue",
$$batch_json{resourceSpans}[0]{resource}),
'test', 'service.namespace - trace on');
is($$spans[0]{name}, 'default_location', 'span.name - trace on');
#validate http metrics