Skip to content

Commit ef59c8d

Browse files
authored
fix(instrumentation-cucumber): switch from deprecated attributes to stable (#2959)
1 parent 532c9f6 commit ef59c8d

File tree

3 files changed

+19
-24
lines changed

3 files changed

+19
-24
lines changed

packages/instrumentation-cucumber/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@ This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which i
5353

5454
Attributes collected:
5555

56-
| Attribute | Short Description |
57-
| ---------------- | -------------------------------------------------------------------------------- |
58-
| `code.filepath` | The source code file name that identifies the code unit as uniquely as possible. |
59-
| `code.function` | The method or function name, or equivalent. |
60-
| `code.lineno` | The line number in `code.filepath` best representing the operation. |
61-
| `code.namespace` | The "namespace" within which `code.function` is defined. |
56+
| Attribute | Short Description |
57+
| -------------------- | -------------------------------------------------------------------------------- |
58+
| `code.file.path` | The source code file name that identifies the code unit as uniquely as possible. |
59+
| `code.function.name` | The method or function fully-qualified name without arguments. |
60+
| `code.line.number` | The line number in `code.file.path` best representing the operation. |
6261

6362
## Useful links
6463

packages/instrumentation-cucumber/src/instrumentation.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ import {
2222
isWrapped,
2323
} from '@opentelemetry/instrumentation';
2424
import {
25-
SEMATTRS_CODE_FILEPATH,
26-
SEMATTRS_CODE_FUNCTION,
27-
SEMATTRS_CODE_LINENO,
28-
SEMATTRS_CODE_NAMESPACE,
25+
ATTR_CODE_FILE_PATH,
26+
ATTR_CODE_FUNCTION_NAME,
27+
ATTR_CODE_LINE_NUMBER,
2928
} from '@opentelemetry/semantic-conventions';
3029

3130
import type * as cucumber from '@cucumber/cucumber';
@@ -182,10 +181,9 @@ export class CucumberInstrumentation extends InstrumentationBase<CucumberInstrum
182181
{
183182
kind: SpanKind.CLIENT,
184183
attributes: {
185-
[SEMATTRS_CODE_FILEPATH]: gherkinDocument.uri,
186-
[SEMATTRS_CODE_LINENO]: scenario.location.line,
187-
[SEMATTRS_CODE_FUNCTION]: scenario.name,
188-
[SEMATTRS_CODE_NAMESPACE]: feature.name,
184+
[ATTR_CODE_FILE_PATH]: gherkinDocument.uri,
185+
[ATTR_CODE_LINE_NUMBER]: scenario.location.line,
186+
[ATTR_CODE_FUNCTION_NAME]: `${feature.name} ${scenario.name}`,
189187
[AttributeNames.FEATURE_TAGS]: CucumberInstrumentation.mapTags(
190188
feature.tags
191189
),

packages/instrumentation-cucumber/test/cucumber.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ import {
2222
SimpleSpanProcessor,
2323
} from '@opentelemetry/sdk-trace-base';
2424
import {
25-
SEMATTRS_CODE_FILEPATH,
26-
SEMATTRS_CODE_FUNCTION,
27-
SEMATTRS_CODE_LINENO,
28-
SEMATTRS_CODE_NAMESPACE,
29-
SEMRESATTRS_SERVICE_NAME,
25+
ATTR_CODE_FILE_PATH,
26+
ATTR_CODE_FUNCTION_NAME,
27+
ATTR_CODE_LINE_NUMBER,
28+
ATTR_SERVICE_NAME,
3029
} from '@opentelemetry/semantic-conventions';
3130
import { resourceFromAttributes } from '@opentelemetry/resources';
3231

@@ -57,7 +56,7 @@ describe('CucumberInstrumentation', () => {
5756
const spanProcessor = new SimpleSpanProcessor(memoryExporter);
5857
const provider = new NodeTracerProvider({
5958
resource: resourceFromAttributes({
60-
[SEMRESATTRS_SERVICE_NAME]: 'CucumberInstrumentation',
59+
[ATTR_SERVICE_NAME]: 'CucumberInstrumentation',
6160
}),
6261
spanProcessors: [spanProcessor],
6362
});
@@ -169,10 +168,9 @@ describe('CucumberInstrumentation', () => {
169168
assert(parent, 'Expected a parent span');
170169

171170
assert.deepEqual(parent.attributes, {
172-
[SEMATTRS_CODE_FILEPATH]: path.join('test', 'current.feature'),
173-
[SEMATTRS_CODE_LINENO]: 7,
174-
[SEMATTRS_CODE_FUNCTION]: 'Button pushing',
175-
[SEMATTRS_CODE_NAMESPACE]: 'Basic',
171+
[ATTR_CODE_FILE_PATH]: path.join('test', 'current.feature'),
172+
[ATTR_CODE_LINE_NUMBER]: 7,
173+
[ATTR_CODE_FUNCTION_NAME]: 'Basic Button pushing',
176174
[AttributeNames.FEATURE_DESCRIPTION]:
177175
' A very basic feature file with a single scenario',
178176
[AttributeNames.FEATURE_LANGUAGE]: 'en',

0 commit comments

Comments
 (0)