Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Add opencensus integration #396

Merged
merged 5 commits into from
Sep 7, 2020
Merged

Add opencensus integration #396

merged 5 commits into from
Sep 7, 2020

Conversation

taddari
Copy link
Contributor

@taddari taddari commented Aug 27, 2020

Fixes #267

Proposed Changes

Release Note

After this PR SQL metrics should be available to view in metrics exporter https://opencensus.io/integrations/sql/go_sql/

@googlebot googlebot added the cla: yes Auto: added by CLA bot when all committers have signed a CLA. label Aug 27, 2020
@google-oss-robot
Copy link

Hi @taddari. Thanks for your PR.

I'm waiting for a google member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@taddari
Copy link
Contributor Author

taddari commented Aug 27, 2020

/ok-to-test

@google-oss-robot
Copy link

@taddari: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/ok-to-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sethvargo
Copy link
Member

@taddari try again - added you to the triage permission which should let you control the bot

// OpenWithCacher creates a database connection with the cacher. This should
// only be called once.
func (db *Database) OpenWithCacher(ctx context.Context, cacher cache.Cacher) error {
c := db.config

rawDB, err := gorm.Open("postgres", c.ConnectionString())
driver := ocsql.Wrap(&postgres.Driver{}, ocsql.WithAllTraceOptions())
Copy link
Member

@sethvargo sethvargo Aug 27, 2020

Choose a reason for hiding this comment

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

Two things here:

  1. This feels like a lot of code, and I'm not entirely sure why it's all necessary. Can we just register the callback?

  2. I'm concerned that this observability might allow a server operator to correlate specific database events (e.g. an insert) which a TEK upload. It's the same problem as the network observer, but since our chaff requests don't hit the database, it would be easy to separate chaff from non-chaff /cc @mikehelmick

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Seth,

About your first point, the callbacks will actually emit only gorm specific metrics. https://github.com/sagikazarmark/go-gin-gorm-opencensus/blob/master/pkg/ocgorm/stats.go.

For postgres specific metrics, we need to override the driver. Following are the metrics that are emitted by https://github.com/opencensus-integrations/ocsql#recorded-metrics.

For point 2, I think we should disable tracing in that case and that should prevent the server operator to correlate anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed the code to remove traceability. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

I think we're gonna need to hold off until we hear from the privacy team (I pinged them).

Copy link
Contributor

@icco icco Aug 31, 2020

Choose a reason for hiding this comment

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

Also worth remembering, we're sampling traces at 40%.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sethvargo any update from the privacy team?

Copy link
Member

Choose a reason for hiding this comment

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

@taddari
Copy link
Contributor Author

taddari commented Aug 27, 2020

/ok-to-test

@icco
Copy link
Contributor

icco commented Sep 5, 2020

/lgtm
/approve

Fix merge conflict tho.

@taddari
Copy link
Contributor Author

taddari commented Sep 7, 2020

/retest

@taddari
Copy link
Contributor Author

taddari commented Sep 7, 2020

Done the changes.
FYI, increased the time of "TestIssueToken" from 2 to 5 seconds, as 2 seconds seems not to be enough for github server although it is okay in local machine.

Copy link
Contributor

@icco icco left a comment

Choose a reason for hiding this comment

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

/lgtm

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: icco, taddari

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit 342d2f5 into google:main Sep 7, 2020
sethvargo added a commit that referenced this pull request Sep 7, 2020
google-oss-robot pushed a commit that referenced this pull request Sep 7, 2020
@google google locked and limited conversation to collaborators Oct 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Auto: added by CLA bot when all committers have signed a CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Open Census for Postgresql
5 participants