Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added segment synthesis for db client otel spans to db trace #2820

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

bizob2828
Copy link
Member

Description

The transformation rules key off of client as span kind and db.system to do its matching. However some of the required attributes for naming do not exist in Node.js opentelemetry instrumetation. Most db.sql.table. For traditional sql database libs we must parse the SQL to extract the operation and table. I also cross referenced our instrumentation to determine how we name segments for databases:

Segment naming for all dbs:

  • mysql/mysql2 - Datastore/statement/MySQL/<table>/<operation>
  • pg - Datastore/statement/Postgres/<table>/<operation>
  • redis - Datastore/operation/Redis/<operation>
  • mongodb - Datastore/statement/MongoDB/<collection or Datastore/operation/MongoDB/<operation>
  • elasticsearch - Datastore/statement/ElasticSearch/<index>/<operation> or Datastore/operation/ElasticSearch/<operation>
  • prisma - out of scope
  • cassandra - Datastore/statement/Cassandra/<keyspace>.<table>/<operation> or Datastore/operation/Cassandra/<operation>
  • ioredis - same as redis
  • memcached - Datastore/operation/Memcache/<operation>

The only difference here will be mongodb/elasticsearch as all will be prefixed with Datastore/statement

How to Test

node test/until/lib/otel/segment-synthesizer.test.js

Related Issues

Closes #2647

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.27%. Comparing base (ed11c39) to head (0ba8afa).
Report is 2 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #2820   +/-   ##
=======================================
  Coverage   97.26%   97.27%           
=======================================
  Files         297      299    +2     
  Lines       46907    46983   +76     
=======================================
+ Hits        45626    45702   +76     
  Misses       1281     1281           
Flag Coverage Δ
integration-tests-cjs-18.x 73.33% <ø> (+<0.01%) ⬆️
integration-tests-cjs-20.x 73.34% <ø> (ø)
integration-tests-cjs-22.x 73.37% <ø> (ø)
unit-tests-18.x 89.10% <93.33%> (+0.06%) ⬆️
unit-tests-20.x 89.10% <93.33%> (+0.06%) ⬆️
unit-tests-22.x 89.11% <93.33%> (+0.06%) ⬆️
versioned-tests-18.x 79.12% <96.24%> (+<0.01%) ⬆️
versioned-tests-20.x 79.15% <96.24%> (+0.03%) ⬆️
versioned-tests-22.x 79.13% <96.24%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jsumners-nr jsumners-nr left a comment

Choose a reason for hiding this comment

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

Seems straightforward enough.

return this.createExternalSegment(otelSpan)
} else if (rule.type === 'db') {
return this.createDatabaseSegment(otelSpan)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this file is going to become difficult to understand if we keep adding methods to it. We'll probably want to split things out after we PoC everything to stuff like return new DatabaseSegment(otelSpan).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea. Ive already noted that for the next story I do

@bizob2828 bizob2828 merged commit 6e9245e into next Dec 6, 2024
52 checks passed
@bizob2828 bizob2828 deleted the db-client-spans-to-trace-segments branch December 6, 2024 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants