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

Prefix SQL URLs with scheme #667

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

dwickr
Copy link
Contributor

@dwickr dwickr commented Jul 26, 2024

Description of changes:

Currently the database URLs provided in SQL data are formatted like:

{host}:{port}/{database}

However, most (maybe all?) of the other X-Ray SDKs1 2 3 format these URLs with the scheme prefixed in front, so:

{scheme}://{host}:{port}/{database}

This format is also enforced on the opentelemetry collector 4, and results in the following error when receiving traces with SQL data from this library:

failed to parse out the database name in the "sql.url" field

When this happens, traces are dropped by the opentelemetry collector and are not sent to AWS X-Ray. This change addresses these issues by prefixing the SQL data URLs with the scheme for both MySQL (mysql://) and Postgres (postgresql://).


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Currently the database URLs provided in SQL data are formatted like:

    {host}:{port}/{database}

However, most (maybe all?) of the other X-Ray SDKs[1][2][3] format these
URLs with the scheme prefixed in front, so:

    {scheme}://{host}:{port}/{database}

This format is also enforced on the opentelemetry collector[4], and
results in the following error when receiving traces with SQL data from
this library:

    failed to parse out the database name in the "sql.url" field

When this happens, traces are dropped by the opentelemetry collector and
are not sent to AWS X-Ray.

This change addresses these issues by prefixing the SQL data URLs with
the scheme for both MySQL (`mysql://`) and Postgres (`postgresql://`).

[1]: https://github.com/aws/aws-xray-sdk-python/blob/d3a202719e659968fe6dcc04fe14c7f3045b53e8/aws_xray_sdk/ext/sqlalchemy_core/patch.py#L30
[2]: https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-sql-mysql/src/main/java/com/amazonaws/xray/sql/mysql/TracingInterceptor.java#L119
[3]: https://github.com/aws/aws-xray-sdk-ruby/blob/b2fce0c1f4ada747ebe16b973e1ed7069013a9a2/lib/aws-xray-sdk/facets/rails/active_record.rb#L50
[4]: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/awsxrayreceiver/internal/translator/sql.go#L38-L39
@dwickr dwickr requested a review from a team as a code owner July 26, 2024 15:26
@mxiamxia mxiamxia merged commit f1ae71b into aws:master Aug 1, 2024
13 checks passed
@dwickr dwickr deleted the prefix-sql-url-with-scheme branch August 1, 2024 16:40
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.

2 participants