Skip to content

Commit

Permalink
update db sysystem filter
Browse files Browse the repository at this point in the history
Signed-off-by: Jared Tan <[email protected]>
  • Loading branch information
JaredTan95 committed Aug 25, 2024
1 parent 15a75a2 commit 14c3069
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions connector/slowsqlconnector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type Exemplars struct {
type Config struct {
// Threshold of slow sql. unit is seconds, default 1s.
Threshold float64 `mapstructure:"threshold"`
// Filter specific db systems, default "h2", "mongodb", "mssql", "mysql", "oracle", "progress", "postgresql", "mariadb", ref: https://opentelemetry.io/docs/specs/semconv/attributes-registry/db/
DBSystem []string `mapstructure:"db_system"`
// Dimensions defines the list of additional dimensions on top of the provided:
// - service.name
// - span.name
Expand Down
6 changes: 4 additions & 2 deletions connector/slowsqlconnector/connector_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ func (c *logsConnector) ConsumeTraces(ctx context.Context, traces ptrace.Traces)
case ptrace.SpanKindClient:
// through db.Statement exists represents db client
if _, dbSystem := findAttributeValue(dbSystemKey, span.Attributes()); dbSystem {
if spanDuration(span) >= c.config.Threshold {
c.attrToLogRecord(sl, serviceName, span, resourceAttr)
for _, db := range c.config.DBSystem {
if db == getValue(span.Attributes(), dbSystemKey) && spanDuration(span) >= c.config.Threshold {
c.attrToLogRecord(sl, serviceName, span, resourceAttr)
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions connector/slowsqlconnector/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func NewFactory() connector.Factory {
func createDefaultConfig() component.Config {
return &Config{
Threshold: 1,
DBSystem: []string{"h2", "mongodb", "mssql", "mysql", "oracle", "progress", "postgresql", "mariadb"},
Dimensions: []Dimension{},
}
}
Expand Down

0 comments on commit 14c3069

Please sign in to comment.