From 6266e07afd0124e28b45d3ffb21ba4c24c5931d0 Mon Sep 17 00:00:00 2001 From: Gabriel Darbord Date: Sun, 14 Jul 2024 11:28:13 +0200 Subject: [PATCH] Instru: follow span specs for status and errors --- .../OTSpan.class.st | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/OpenTelemetry-Instrumentation/OTSpan.class.st b/src/OpenTelemetry-Instrumentation/OTSpan.class.st index 1f6d7ea..0a6bf29 100644 --- a/src/OpenTelemetry-Instrumentation/OTSpan.class.st +++ b/src/OpenTelemetry-Instrumentation/OTSpan.class.st @@ -272,8 +272,23 @@ OTSpan >> printOn: aStream [ { #category : 'recording' } OTSpan >> recordException: anException [ - self status: 'ERROR'. - self attributeAt: 'error' put: anException description + self setErrorStatus. + self attributeAt: 'exception' put: anException description +] + +{ #category : 'recording' } +OTSpan >> setErrorStatus [ + "Specification: https://opentelemetry.io/docs/specs/otel/trace/api/#set-status + Status values form a total order: Ok > Error > Unset. + This means that setting Status with Ok will override any prior or future attempts to set span Status with Error or Unset." + + status == #OK ifFalse: [ status := #ERROR ] +] + +{ #category : 'recording' } +OTSpan >> setOkStatus [ + + status := #OK ] { #category : 'accessing' } @@ -307,12 +322,6 @@ OTSpan >> status [ ^ status ] -{ #category : 'accessing' } -OTSpan >> status: aString [ - - status := aString -] - { #category : 'ston persistence' } OTSpan >> stonOn: stonWriter [