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

Support SELECT/INSERT/UPDATE/DELETE db operation + span names #1253

Merged
merged 9 commits into from
Dec 9, 2024

Conversation

damemi
Copy link
Contributor

@damemi damemi commented Nov 7, 2024

Ref #743

From the semconv for db spans:

Database spans MUST follow the overall [guidelines for span names](https://github.com/open-telemetry/opentelemetry-specification/tree/v1.37.0/specification/trace/api.md#span).

The span name SHOULD be {db.query.summary} if a summary is available.

If no summary is available, the span name SHOULD be {db.operation.name} {target} provided that a (low-cardinality) db.operation.name is available (see below for the exact definition of the [{target}](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/database/database-spans.md#target-placeholder) placeholder).

If a (low-cardinality) db.operation.name is not available, database span names SHOULD default to the [{target}](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/database/database-spans.md#target-placeholder).

If neither {db.operation.name} nor {target} are available, span name SHOULD be {db.system}.

Semantic conventions for individual database systems MAY specify different span name format.

The {target} SHOULD describe the entity that the operation is performed against and SHOULD adhere to one of the following values, provided they are accessible:

db.collection.name SHOULD be used for data manipulation operations or operations on a database collection.
db.namespace SHOULD be used for operations on a specific database namespace.
server.address:server.port SHOULD be used for other operations not targeting any specific database(s) or collection(s)
If a corresponding {target} value is not available for a specific operation, the instrumentation SHOULD omit the {target}. For example, for an operation describing SQL query on an anonymous table like SELECT * FROM (SELECT * FROM table) t, span name should be SELECT.

We don't have collection (table), namespace, or server.address readily available (right now), but we can at least parse certain operations. We can also support more over time. So this gets us at least a couple useful span names besides DB (fallback for unsupported operations)

This means we can also set db.operation.name with that same value when it is available.

@damemi damemi requested a review from a team as a code owner November 7, 2024 19:37
@damemi damemi force-pushed the sql-semconv branch 3 times, most recently from 8f0e456 to 5340675 Compare November 7, 2024 19:53
@damemi damemi force-pushed the sql-semconv branch 2 times, most recently from 89e64c7 to 7116a06 Compare November 8, 2024 19:49
@damemi damemi force-pushed the sql-semconv branch 3 times, most recently from c809878 to 97ccfaf Compare November 20, 2024 16:23
internal/pkg/instrumentation/bpf/database/sql/probe.go Outdated Show resolved Hide resolved
internal/pkg/instrumentation/bpf/database/sql/probe.go Outdated Show resolved Hide resolved
go.mod Show resolved Hide resolved
@damemi damemi force-pushed the sql-semconv branch 3 times, most recently from cccbf66 to 264081d Compare December 2, 2024 21:15
Copy link
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

This looks like an exciting change. Mainly small comments outside of the compatibility policy issue.

Do we need to support older versions of Go? Would that break any downstream users of go.opentelemetry.io/auto?

docs/configuration.md Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
internal/test/e2e/databasesql/main.go Outdated Show resolved Hide resolved
LICENSES/libbpf/bpf.h Outdated Show resolved Hide resolved
@damemi damemi force-pushed the sql-semconv branch 2 times, most recently from 76511c5 to cc00965 Compare December 5, 2024 14:12
@damemi
Copy link
Contributor Author

damemi commented Dec 5, 2024

Update from the SIG call feedback this week, I pinned Vitess to v0.20.2 which is on Go 1.22.7 (our version) and this is the error: https://github.com/open-telemetry/opentelemetry-go-instrumentation/actions/runs/12181495669/job/33978276098?pr=1253#step:6:434

link: vitess.io/vitess/go/hack: invalid reference to runtime.roundupsize

This is probably because we build our image on go 1.23 (which makes sense, we ship an artifact based on that so it should use the latest runtime).

Based on that, I think the only option is to undo the vitess work and revert this to just the basic command parsing I originally had. Which is a bummer, because vitess is a lot richer :\ @MrAlias does that sound good to you?

@MrAlias
Copy link
Contributor

MrAlias commented Dec 5, 2024

I agree with the revert to the other sql parsing package. I think we should still be able to support table parsing though based on #1253 (comment)

@damemi damemi force-pushed the sql-semconv branch 3 times, most recently from 472c686 to 2bc5aa8 Compare December 6, 2024 20:02
@damemi
Copy link
Contributor Author

damemi commented Dec 6, 2024

@MrAlias @RonFed this is ready for another round of review, I reverted back to the other library and we'll just support basic statements + collection when available

Copy link
Contributor

@RonFed RonFed left a comment

Choose a reason for hiding this comment

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

left 2 non-blocking comments

internal/pkg/instrumentation/bpf/database/sql/probe.go Outdated Show resolved Hide resolved
internal/pkg/instrumentation/bpf/database/sql/probe.go Outdated Show resolved Hide resolved
Copy link
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

🏅

@MrAlias MrAlias merged commit 7e712a6 into open-telemetry:main Dec 9, 2024
27 checks passed
@MrAlias MrAlias added this to the v0.20.0-alpha milestone Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants