Skip to content

Commit

Permalink
feat: add instance_id to metrics label (#4614)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kavinjsir authored Apr 16, 2024
1 parent 954ddb6 commit c74d403
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
10 changes: 6 additions & 4 deletions runtime/drivers/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@ func (d driver) TertiarySourceConnectors(ctx context.Context, src map[string]any
}

type connection struct {
db *sqlx.DB
config *configProperties
logger *zap.Logger
activity *activity.Client
db *sqlx.DB
config *configProperties
logger *zap.Logger
activity *activity.Client
instanceID string

// logic around this copied from duckDB driver
// This driver may issue both OLAP and "meta" queries (like catalog info) against DuckDB.
Expand Down Expand Up @@ -182,6 +183,7 @@ func (c *connection) AsAI(instanceID string) (drivers.AIService, bool) {

// OLAP implements drivers.Connection.
func (c *connection) AsOLAP(instanceID string) (drivers.OLAPStore, bool) {
c.instanceID = instanceID
return c, true
}

Expand Down
1 change: 1 addition & 0 deletions runtime/drivers/clickhouse/olap.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ func (c *connection) Execute(ctx context.Context, stmt *drivers.Statement) (res
attrs := []attribute.KeyValue{
attribute.Bool("cancelled", errors.Is(outErr, context.Canceled)),
attribute.Bool("failed", outErr != nil),
attribute.String("instance_id", c.instanceID),
}

attrSet := attribute.NewSet(attrs...)
Expand Down
3 changes: 3 additions & 0 deletions runtime/drivers/duckdb/duckdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ type connection struct {
cancel context.CancelFunc
// registration should be unregistered on close
registration metric.Registration

instanceID string
}

var _ drivers.OLAPStore = &connection{}
Expand Down Expand Up @@ -362,6 +364,7 @@ func (c *connection) AsOLAP(instanceID string) (drivers.OLAPStore, bool) {
// duckdb olap is instance specific
return nil, false
}
c.instanceID = instanceID
return c, true
}

Expand Down
1 change: 1 addition & 0 deletions runtime/drivers/duckdb/olap.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (c *connection) Execute(ctx context.Context, stmt *drivers.Statement) (res
attribute.String("db", c.config.DBFilePath),
attribute.Bool("cancelled", errors.Is(outErr, context.Canceled)),
attribute.Bool("failed", outErr != nil),
attribute.String("instance_id", c.instanceID),
}

attrSet := attribute.NewSet(attrs...)
Expand Down

0 comments on commit c74d403

Please sign in to comment.