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

Adding gormtrace plugin #490

Closed
wants to merge 1 commit into from
Closed

Conversation

rizkybiz
Copy link

Wanted to add a plugin to ease the implementation of tracing around GORM ORM.

@rghetia
Copy link
Contributor

rghetia commented Feb 19, 2020

@rizkybiz thanks for writing the gorm plugin.

Given that we have more plugins like this in coming weeks/months, I am thinking of creating a contrib repo for such plugins.

@rizkybiz
Copy link
Author

@rghetia No problem. I think a contrib repo is a great idea, it will help keep the API/SDK more clean/manageable in the long run. Just let me know if you'd like me to move anything once you create it, I have some other stuff inspired by older OpenCensus and OpenTracing projects/wrappers I've found and reworked for Otel so I'll stay tuned.

@jmacd
Copy link
Contributor

jmacd commented Feb 19, 2020

@rghetia I've heard we are discussing a per-language contrib repository at the OTel governance level. Do you know if that has been decided?

@rghetia
Copy link
Contributor

rghetia commented Feb 19, 2020

@rghetia I've heard we are discussing a per-language contrib repository at the OTel governance level. Do you know if that has been decided?

I don't know the status of that discussion.
@lizthegrey do you have any insight?

@achew22
Copy link

achew22 commented Feb 20, 2020

Would it be better instead to add the tracer to the sql.DB? That would be generic to all the various ways people talk to databases.

@wingyplus
Copy link
Contributor

@achew22 i didn’t see any plugin around sql.DB but i remember that opencencus have this kind of plugin callled ocsql https://github.com/opencensus-integrations/ocsql/blob/master/README.md. I think it’s not too much hard to convert to otel.

@rizkybiz
Copy link
Author

I’d say people generally reach for either an ORM or they roll their own SQL using sql.DB. GORM implements it’s own DB type so it may be of merit to have both a GORM wrapper and a wrapper around the standard lib sql.DB

@achew22
Copy link

achew22 commented Feb 20, 2020

Under the covers gorm uses sql.DB and will even provide it back to you if you ask for it[1]. If we are looking to be inspired by ocsql, which is where I first ran into this delightfully clever idea, they provide ocsql.Wrap and ocsql.Register methods, which returns an object that embeds the normal sql.DB object and pass the calls through to that driver, after calling trace and then registers it under a new driver name. Then you can that driver name when you establish your connection. This means that ocsql is compatible with GORM out of the box.

Additionally, targeting a tracer to one of the stdlib interfaces seems, to me, like something that should be a part of the core opentelemetry-go instead of in a contrib which reduces the overhead of adding something like this in.

[1] Note: this only works for connections that actually go through sql.DB. It wouldn't work for, as an example, MongoDB. Due to this incompatibility it may be worth pursuing a GORM wrapper in addition.

@rghetia
Copy link
Contributor

rghetia commented Feb 21, 2020

@rizkybiz you can move this to Contrib repo.

@rizkybiz
Copy link
Author

@rghetia I'm assuming I'll have to pull in the master of the Go SDK and update to not be under that umbrella correct?

@glerchundi
Copy link

Additionally, targeting a tracer to one of the stdlib interfaces seems, to me, like something that should be a part of the core opentelemetry-go instead of in a contrib which reduces the overhead of adding something like this in.

I completely agree with this, otsql or something similar being part of the core implementation would be a step forward and would avoid incompatibility issues.

@rghetia
Copy link
Contributor

rghetia commented Feb 28, 2020

Closing this as it is moved to open-telemetry/opentelemetry-go-contrib#2

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.

6 participants