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

Clarify differences between sqlcomment and otelsql #4

Open
StevenACoffman opened this issue Jul 30, 2022 · 5 comments
Open

Clarify differences between sqlcomment and otelsql #4

StevenACoffman opened this issue Jul 30, 2022 · 5 comments
Assignees

Comments

@StevenACoffman
Copy link

I read that Sqlcommenter merged into OpenTelemetry.

I have database connection code that I have already instrumented with https://github.com/XSAM/otelsql

	wrappedDriverName, err := otelsql.Register(
		"pgx",
		semconv.DBSystemPostgreSQL.Value.AsString(),
	)

and I am wondering if adding sqlcomment is redundant or if it would provide additional value?

@giautm
Copy link
Member

giautm commented Jul 31, 2022

Is redundant or if it would provide additional value?

I think it provides additional value to track where the request comes from, from apiv1, GraphQL, or gRPC functions. The merge in Google's term applied to the spec, the trace collector, and the cloud service.

For client instruction, it's fine if we have two separate packages to provide the functions.

Link the issue: XSAM/otelsql#109

@rotemtam rotemtam self-assigned this Jul 31, 2022
@rotemtam
Copy link
Member

hey @StevenACoffman
thanks for reaching out. I have self-assigned the issue and will respond soon

@rotemtam
Copy link
Member

rotemtam commented Aug 3, 2022

hey @StevenACoffman!

Sqlcommenter is a standard created at Google and recently accepted into OpenTelemetry. It's an interesting addition, and I'm curious to see how the integration will take place. In general, with otel telematics are exported as either traces (spans) or as metrics. Below these abstractions, you will find technologies like Jaeger (for tracing) or Prometheus (for metrics).

Sqlcommenter works quite differently. It works on the ORM layer, by injecting metadata containing comments as part of the SQL statements that are sent to the database. These logs are then ingested on the database side (with support from Cloud SQL Insights, a proprietary Google Cloud offering). I am not aware of OSS solutions that do this ingestion and expose this data to the user. yet, but I'm sure with this becoming part of otel we will begin seeing something like that.

To answer your question:

  • sqlcomment - is an Ent driver for adding Sqlcommenter compatible comments to the SQL statements that are generated by Ent and executed against the database. It does not integrate directly with otel/opencensus/prometheus/jaeger etc. To consume this data you must have some APM product that can ingest and expose that metadata.
  • otelsql wraps Go database/sql drivers and produces OpenTelemtry telematics (metrics+traces) that can be exported to Jaeger/Prometheus and the likes.

HTH

@StevenACoffman
Copy link
Author

StevenACoffman commented Aug 3, 2022

Thanks! That's very helpful. I was hoping to get sqlcomment to add the de facto standardized fields traceparent and tracestate. For example:

select * from widgets /*traceparent='00-5bd66ef5095369c7b0d1f8f4bd33716a-c532cb4098ac3dd2-01',tracestate='congo%3Dt61rcWkgMzE%2Crojo%3D00f067aa0ba902b7'*/

I'd like to be able to use both Cloud SQL Insights and Cloud Trace in my application.

Does ariga/sqlcomment and NewOTELTagger() do that?

@StevenACoffman
Copy link
Author

Oh, nevermind, it looks like it does just that:

func NewOTELTagger() OTELTagger {

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

No branches or pull requests

3 participants