| 24 | } |
| 25 | |
| 26 | func (m *monitor) Started(ctx context.Context, evt *event.CommandStartedEvent) { |
| 27 | hostname, port := peerInfo(evt) |
| 28 | statement := evt.Command.String() |
| 29 | |
| 30 | span, _ := opentracing.StartSpanFromContextWithTracer(ctx, m.tracer, "mongodb.query") |
| 31 | ext.DBType.Set(span, "mongo") |
| 32 | ext.DBInstance.Set(span, evt.DatabaseName) |
| 33 | ext.PeerHostname.Set(span, hostname) |
| 34 | ext.PeerPort.Set(span, port) |
| 35 | ext.DBStatement.Set(span, statement) |
| 36 | ext.SpanKind.Set(span, ext.SpanKindEnum("client")) |
| 37 | key := spanKey{ |
| 38 | ConnectionID: evt.ConnectionID, |
| 39 | RequestID: evt.RequestID, |
| 40 | } |
| 41 | m.Lock() |
| 42 | m.spans[key] = span |
| 43 | m.Unlock() |
| 44 | } |
| 45 | |
| 46 | func (m *monitor) Succeeded(ctx context.Context, evt *event.CommandSucceededEvent) { |
| 47 | m.Finished(&evt.CommandFinishedEvent, nil) |