open-telemetry / opentelemetry-sqlcommenter

SQLCommenter components for various languages
Apache License 2.0
27 stars 12 forks source link

Golang: sqlcommenter or otelsql or both? #34

Open StevenACoffman opened 2 years ago

StevenACoffman commented 2 years ago

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?

StevenACoffman commented 2 years ago

After some research, currently in Go, you need to use two different libraries to instrument the database client to have support for both regular traces and metrics and sqlcommenter.

In general, with otel telematics are exported as either traces (spans) or as metrics. Below these abstractions, you will find otel clients are exporting using technologies like Jaeger (for tracing) or Prometheus (for metrics).

This is quite different from Sqlcommenter. Sqlcommenter works on the driver/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.

See XSAM/otelsql#109 and https://github.com/jbub/sqlcommenter