Skip to content

feat(integrations): AWS SDK v2 instrumentation + improved SQL tracing#29

Merged
karthikeyangs9 merged 4 commits intomainfrom
feat/aws-and-db-improvements
Apr 7, 2026
Merged

feat(integrations): AWS SDK v2 instrumentation + improved SQL tracing#29
karthikeyangs9 merged 4 commits intomainfrom
feat/aws-and-db-improvements

Conversation

@prathamesh-sonpatki
Copy link
Copy Markdown
Member

Summary

  • New: integrations/awsInstrumentSDK(&cfg) wraps otelaws.AppendMiddlewares; auto-starts agent; captures per-service attributes for DynamoDB, SQS, SNS automatically
  • Improved: integrations/database — every SQL span now carries db.statement, db.operation, and db.sql.table; span names become SELECT users instead of sql.query; opt-in IncludeQueryArgs for arg capture; TracePing() added to defaults
  • New: parseSQL helper — lightweight token-based extractor with 22 unit tests covering DML, DDL, subqueries, schema-qualified names, quoted identifiers

What spans look like now

Before After
span name: sql.query span name: SELECT users
attributes: db.system, server.address attributes: + db.statement, db.operation=SELECT, db.sql.table=users
no ping spans sql.ping spans captured

Test plan

  • go test ./integrations/database/... — 22 parseSQL tests + existing DSN tests
  • go test ./integrations/aws/... — middleware append, nil-safe, options passthrough
  • Run full CI

🤖 Generated with Claude Code

prathamesh-sonpatki and others added 4 commits March 30, 2026 00:50
…acing

AWS SDK v2 (integrations/aws):
- New InstrumentSDK() wraps otelaws.AppendMiddlewares with auto-agent init
- Per-service attributes (DynamoDB table, SQS queue URL, SNS topic ARN)
  captured automatically via otelaws built-in attribute builders
- Option type alias so callers avoid a direct otelaws import

SQL tracing improvements (integrations/database):
- Add TracePing() to default options for connection health spans
- Replace TraceQueryWithoutArgs with a custom queryTracer that stamps
  db.statement, db.operation (SELECT/INSERT/...), and db.sql.table
  onto every query span
- Add WithSpanNameFormatter producing "SELECT users"-style span names
  instead of the generic "sql.query"
- Add IncludeQueryArgs bool to Config for opt-in query arg capture
  (disabled by default to avoid PII exposure)
- New parseSQL() helper with 22 test cases covering DML, DDL, subqueries,
  schema-qualified names, and quoted identifiers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- aws: fall through on agent.Start() failure (matches integrations/ pattern)
  instead of returning without attaching middleware; fix log capitalisation
- database: replace double parseSQL() call per query with parseSQLCached()
  backed by sync.Map — SQL queries in production are a bounded, reused set
- database: fix over-allocation in buildQueryTracer when IncludeQueryArgs=false
  (was allocating 3+len(args) even when args would not be written)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@karthikeyangs9 karthikeyangs9 merged commit b2c13b2 into main Apr 7, 2026
10 checks passed
@prathamesh-sonpatki prathamesh-sonpatki deleted the feat/aws-and-db-improvements branch April 7, 2026 10:04
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.

2 participants