forked from elastic/apm-agent-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spancontext.go
46 lines (37 loc) · 1011 Bytes
/
spancontext.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package elasticapm
import (
"github.com/elastic/apm-agent-go/model"
)
// SpanContext provides methods for setting span context.
type SpanContext struct {
model model.SpanContext
database model.DatabaseSpanContext
}
// DatabaseSpanContext holds database span context.
type DatabaseSpanContext struct {
// Instance holds the database instance name.
Instance string
// Statement holds the statement executed in the span,
// e.g. "SELECT * FROM foo".
Statement string
// Type holds the database type, e.g. "sql".
Type string
// User holds the username used for database access.
User string
}
func (c *SpanContext) build() *model.SpanContext {
switch {
case c.model.Database != nil:
default:
return nil
}
return &c.model
}
func (c *SpanContext) reset() {
*c = SpanContext{}
}
// SetDatabase sets the span context for database-related operations.
func (c *SpanContext) SetDatabase(db DatabaseSpanContext) {
c.database = model.DatabaseSpanContext(db)
c.model.Database = &c.database
}