Skip to content

Commit 7fd1569

Browse files
authored
chore: add code.function.name to junit spans (#710)
This is the OpenTelemetry key defined as the one that should be used for the "fully qualified function name" of the test.
1 parent a187f2a commit 7fd1569

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

mergify_cli/ci/junit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ async def junit_to_spans(
159159
attributes = {
160160
"test.scope": "case",
161161
"test.case.name": test_name,
162+
"code.function.name": test_name,
162163
}
163164

164165
if (filename := testcase.get("file")) is not None:

mergify_cli/tests/ci/test_junit.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ async def test_parse(
127127
{
128128
"attributes": {
129129
"test.case.name": "Tests.Registration.testCase1",
130+
"code.function.name": "Tests.Registration.testCase1",
130131
"test.case.result.status": "passed",
131132
"test.scope": "case",
132133
"test.framework": "unittest",
@@ -155,6 +156,7 @@ async def test_parse(
155156
{
156157
"attributes": {
157158
"test.case.name": "Tests.Registration.testCase2",
159+
"code.function.name": "Tests.Registration.testCase2",
158160
"test.case.result.status": "skipped",
159161
"test.scope": "case",
160162
"test.framework": "unittest",
@@ -186,6 +188,7 @@ async def test_parse(
186188
"exception.stacktrace": "bip, bip, bip, error!",
187189
"exception.type": "ValueError",
188190
"test.case.name": "Tests.Registration.testCase3",
191+
"code.function.name": "Tests.Registration.testCase3",
189192
"test.case.result.status": "failed",
190193
"test.scope": "case",
191194
"test.framework": "unittest",
@@ -241,6 +244,7 @@ async def test_parse(
241244
{
242245
"attributes": {
243246
"test.case.name": "Tests.Authentication.testCase7",
247+
"code.function.name": "Tests.Authentication.testCase7",
244248
"test.case.result.status": "passed",
245249
"test.scope": "case",
246250
"test.framework": "unittest",
@@ -269,6 +273,7 @@ async def test_parse(
269273
{
270274
"attributes": {
271275
"test.case.name": "Tests.Authentication.testCase8",
276+
"code.function.name": "Tests.Authentication.testCase8",
272277
"test.case.result.status": "passed",
273278
"test.scope": "case",
274279
"test.framework": "unittest",
@@ -300,6 +305,7 @@ async def test_parse(
300305
"exception.stacktrace": "Such a mess, the failure is unrecoverable",
301306
"exception.type": "AssertionError",
302307
"test.case.name": "Tests.Authentication.testCase9",
308+
"code.function.name": "Tests.Authentication.testCase9",
303309
"test.case.result.status": "failed",
304310
"test.scope": "case",
305311
"test.framework": "unittest",
@@ -332,6 +338,7 @@ async def test_parse(
332338
"With a second line!",
333339
"exception.type": "ZeroDivisionError",
334340
"test.case.name": "Tests.Permission.testCase10",
341+
"code.function.name": "Tests.Permission.testCase10",
335342
"test.case.result.status": "failed",
336343
"test.scope": "case",
337344
"test.framework": "unittest",
@@ -387,6 +394,7 @@ async def test_parse(
387394
{
388395
"attributes": {
389396
"test.case.name": "Tests.Authentication.Login.testCase4",
397+
"code.function.name": "Tests.Authentication.Login.testCase4",
390398
"test.case.result.status": "passed",
391399
"test.scope": "case",
392400
"test.framework": "unittest",
@@ -418,6 +426,7 @@ async def test_parse(
418426
"exception.stacktrace": "bad syntax, bad!",
419427
"exception.type": "SyntaxError",
420428
"test.case.name": "Tests.Authentication.Login.testCase5",
429+
"code.function.name": "Tests.Authentication.Login.testCase5",
421430
"test.case.result.status": "failed",
422431
"test.scope": "case",
423432
"test.framework": "unittest",
@@ -446,6 +455,7 @@ async def test_parse(
446455
{
447456
"attributes": {
448457
"test.case.name": "Tests.Authentication.Login.testCase6",
458+
"code.function.name": "Tests.Authentication.Login.testCase6",
449459
"test.case.result.status": "passed",
450460
"test.scope": "case",
451461
"test.framework": "unittest",

0 commit comments

Comments
 (0)