Skip to content

feat: add neo4j instrumentation#3380

Open
t2t2 wants to merge 18 commits intoopen-telemetry:mainfrom
t2t2:neo4j
Open

feat: add neo4j instrumentation#3380
t2t2 wants to merge 18 commits intoopen-telemetry:mainfrom
t2t2:neo4j

Conversation

@t2t2
Copy link
Copy Markdown
Contributor

@t2t2 t2t2 commented Feb 10, 2026

Which problem is this PR solving?

Add neo4j instrumentation, originally created by aspecto. Compared to the original, the code has been updated to support newer versions of neo4j-driver package (versions 5.x and 6.x) and to match the latest semantic conventions.

@t2t2 t2t2 requested review from a team as code owners February 10, 2026 16:02
@github-actions github-actions bot requested review from mhennoch and seemk February 10, 2026 16:14
Comment thread packages/instrumentation-neo4j/src/neo4j.ts Outdated
Comment thread packages/instrumentation-neo4j/src/neo4j.ts Outdated
Comment thread packages/instrumentation-neo4j/src/utils.ts Outdated
Comment thread packages/instrumentation-neo4j/src/utils.ts Outdated
const auth = getAuth(connectionProvider);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const attributes: Record<string, any> = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add server.address/server.port

Comment thread packages/instrumentation-neo4j/README.md Outdated
Comment thread packages/instrumentation-neo4j/README.md Outdated

This module provides automatic instrumentation for the [`neo4j-driver`](https://github.com/neo4j/neo4j-javascript-driver) module, which may be loaded using the [`@opentelemetry/sdk-trace-node`](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node) package.

Compatible with OpenTelemetry JS API and SDK `1.0+`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SDK is 2.x now, is this valid?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a question for >half of the packages in this repo since most use the same readme text

t2t2 added 7 commits March 11, 2026 15:38
As pointed out in pr the db system supports multiple operations in non-batch ops so it shouldn't be fetched from query.text. Neo4j driver doesn't expose the operation name so nothing remains
}

const span = self.tracer.startSpan(
`${connectionAttributes[ATTR_DB_NAMESPACE]}`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://opentelemetry.io/docs/specs/semconv/db/database-spans/#generating-a-summary-of-the-query

I think it is ok to get the operation name from the query text. The [earlier comment] was valid only for db.operation.name attributes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Span name is constructed with the attribute if it is available https://opentelemetry.io/docs/specs/semconv/db/database-spans/#name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants