Update go.uuid and swallow errors from NewV4(), should fix #20

This commit is contained in:
JJ Jordan 2018-05-07 18:08:31 -07:00
Родитель cb36923515
Коммит a65aea2e2a
3 изменённых файлов: 19 добавлений и 4 удалений

Просмотреть файл

@ -405,10 +405,19 @@ func NewRequestTelemetry(method, uri string, duration time.Duration, responseCod
nameUri = parsedUrl.String()
}
// We probably shouldn't crash if we can't get a UUID. Just emit a warning, and set it to blank.
// The telemetry will be rejected, but there will be plenty of logging about that.
var id string
if requestId, err := uuid.NewV4(); err != nil {
diagnosticsWriter.Printf("Failed to generate request ID: %s", err.Error())
} else {
id = requestId.String()
}
return &RequestTelemetry{
Name: fmt.Sprintf("%s %s", method, nameUri),
Url: uri,
Id: uuid.NewV4().String(),
Id: id,
Duration: duration,
ResponseCode: responseCode,
Success: success,
@ -440,7 +449,11 @@ func (request *RequestTelemetry) TelemetryData() TelemetryData {
data.Source = request.Source
if request.Id == "" {
data.Id = uuid.NewV4().String()
if id, err := uuid.NewV4(); err != nil {
diagnosticsWriter.Printf("Failed to generate request ID: %s", err.Error())
} else {
data.Id = id.String()
}
} else {
data.Id = request.Id
}

Просмотреть файл

@ -85,7 +85,9 @@ func (context *TelemetryContext) envelop(item Telemetry) *contracts.Envelope {
// Create operation ID if it does not exist
if _, ok := envelope.Tags[contracts.OperationId]; !ok {
envelope.Tags[contracts.OperationId] = uuid.NewV4().String()
if oid, err := uuid.NewV4(); err == nil {
envelope.Tags[contracts.OperationId] = oid.String()
}
}
// Sanitize.

2
vendor/github.com/satori/go.uuid сгенерированный поставляемый

@ -1 +1 @@
Subproject commit 5bf94b69c6b68ee1b541973bb8e1144db23a194b
Subproject commit 36e9d2ebbde5e3f13ab2e25625fd453271d6522e