Skip to content
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
11 changes: 5 additions & 6 deletions packages/instrumentation-cucumber/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ This package uses `@opentelemetry/semantic-conventions` version `1.22+`, which i

Attributes collected:

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

## Useful links

Expand Down
14 changes: 6 additions & 8 deletions packages/instrumentation-cucumber/src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ import {
isWrapped,
} from '@opentelemetry/instrumentation';
import {
SEMATTRS_CODE_FILEPATH,
SEMATTRS_CODE_FUNCTION,
SEMATTRS_CODE_LINENO,
SEMATTRS_CODE_NAMESPACE,
ATTR_CODE_FILE_PATH,
ATTR_CODE_FUNCTION_NAME,
ATTR_CODE_LINE_NUMBER,
} from '@opentelemetry/semantic-conventions';

import type * as cucumber from '@cucumber/cucumber';
Expand Down Expand Up @@ -182,10 +181,9 @@ export class CucumberInstrumentation extends InstrumentationBase<CucumberInstrum
{
kind: SpanKind.CLIENT,
attributes: {
[SEMATTRS_CODE_FILEPATH]: gherkinDocument.uri,
[SEMATTRS_CODE_LINENO]: scenario.location.line,
[SEMATTRS_CODE_FUNCTION]: scenario.name,
[SEMATTRS_CODE_NAMESPACE]: feature.name,
[ATTR_CODE_FILE_PATH]: gherkinDocument.uri,
[ATTR_CODE_LINE_NUMBER]: scenario.location.line,
[ATTR_CODE_FUNCTION_NAME]: `${feature.name} ${scenario.name}`,
[AttributeNames.FEATURE_TAGS]: CucumberInstrumentation.mapTags(
feature.tags
),
Expand Down
18 changes: 8 additions & 10 deletions packages/instrumentation-cucumber/test/cucumber.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ import {
SimpleSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import {
SEMATTRS_CODE_FILEPATH,
SEMATTRS_CODE_FUNCTION,
SEMATTRS_CODE_LINENO,
SEMATTRS_CODE_NAMESPACE,
SEMRESATTRS_SERVICE_NAME,
ATTR_CODE_FILE_PATH,
ATTR_CODE_FUNCTION_NAME,
ATTR_CODE_LINE_NUMBER,
ATTR_SERVICE_NAME,
} from '@opentelemetry/semantic-conventions';
import { resourceFromAttributes } from '@opentelemetry/resources';

Expand Down Expand Up @@ -57,7 +56,7 @@ describe('CucumberInstrumentation', () => {
const spanProcessor = new SimpleSpanProcessor(memoryExporter);
const provider = new NodeTracerProvider({
resource: resourceFromAttributes({
[SEMRESATTRS_SERVICE_NAME]: 'CucumberInstrumentation',
[ATTR_SERVICE_NAME]: 'CucumberInstrumentation',
}),
spanProcessors: [spanProcessor],
});
Expand Down Expand Up @@ -169,10 +168,9 @@ describe('CucumberInstrumentation', () => {
assert(parent, 'Expected a parent span');

assert.deepEqual(parent.attributes, {
[SEMATTRS_CODE_FILEPATH]: path.join('test', 'current.feature'),
[SEMATTRS_CODE_LINENO]: 7,
[SEMATTRS_CODE_FUNCTION]: 'Button pushing',
[SEMATTRS_CODE_NAMESPACE]: 'Basic',
[ATTR_CODE_FILE_PATH]: path.join('test', 'current.feature'),
[ATTR_CODE_LINE_NUMBER]: 7,
[ATTR_CODE_FUNCTION_NAME]: 'Basic Button pushing',
[AttributeNames.FEATURE_DESCRIPTION]:
' A very basic feature file with a single scenario',
[AttributeNames.FEATURE_LANGUAGE]: 'en',
Expand Down
Loading