Skip to content

Commit 30f098c

Browse files
committed
Update conventions import to v1.27.0 and adjust exception handling in tests
1 parent fa3dd17 commit 30f098c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

exporter/azuremonitorexporter/log_to_envelope.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/microsoft/ApplicationInsights-Go/appinsights/contracts"
1010
"go.opentelemetry.io/collector/pdata/pcommon"
1111
"go.opentelemetry.io/collector/pdata/plog"
12-
conventions "go.opentelemetry.io/collector/semconv/v1.12.0"
12+
conventions "go.opentelemetry.io/otel/semconv/v1.27.0"
1313
"go.uber.org/zap"
1414

1515
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/traceutil"
@@ -184,18 +184,18 @@ func isEventData(attrMap pcommon.Map) bool {
184184
}
185185

186186
func isExceptionData(attributes pcommon.Map) bool {
187-
return hasOneOfKeys(attributes, conventions.AttributeExceptionType, conventions.AttributeExceptionMessage)
187+
return hasOneOfKeys(attributes, string(conventions.ExceptionTypeKey), string(conventions.ExceptionMessageKey))
188188
}
189189

190190
func mapIncomingAttributeMapExceptionDetail(attributemap pcommon.Map) *contracts.ExceptionDetails {
191191
exceptionDetails := contracts.NewExceptionDetails()
192-
if message, exists := attributemap.Get(conventions.AttributeExceptionMessage); exists {
192+
if message, exists := attributemap.Get(string(conventions.ExceptionMessageKey)); exists {
193193
exceptionDetails.Message = message.Str()
194194
}
195-
if typeName, exists := attributemap.Get(conventions.AttributeExceptionType); exists {
195+
if typeName, exists := attributemap.Get(string(conventions.ExceptionTypeKey)); exists {
196196
exceptionDetails.TypeName = typeName.Str()
197197
}
198-
if stackTrace, exists := attributemap.Get(conventions.AttributeExceptionStacktrace); exists {
198+
if stackTrace, exists := attributemap.Get(string(conventions.ExceptionStacktraceKey)); exists {
199199
exceptionDetails.HasFullStack = true
200200
exceptionDetails.Stack = stackTrace.Str()
201201
}

exporter/azuremonitorexporter/logexporter_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ func TestHandleExceptionDataWithDetails(t *testing.T) {
370370
exceptionMessage: "Cannot read property 'undefined'",
371371
stackTrace: "at Object.method (/path/file.js:10)\nat Object.method2 (/path/file2.js:20)",
372372
resourceAttrs: map[string]any{
373-
conventions.AttributeServiceName: "testService",
374-
"custom.attr": "value",
373+
string(conventions.ServiceNameKey): "testService",
374+
"custom.attr": "value",
375375
},
376376
},
377377
{
@@ -395,10 +395,10 @@ func TestHandleExceptionDataWithDetails(t *testing.T) {
395395
logRecord.SetSeverityText(tt.severityText)
396396

397397
attrs := logRecord.Attributes()
398-
attrs.PutStr(conventions.AttributeExceptionType, tt.exceptionType)
399-
attrs.PutStr(conventions.AttributeExceptionMessage, tt.exceptionMessage)
398+
attrs.PutStr(string(conventions.ExceptionTypeKey), tt.exceptionType)
399+
attrs.PutStr(string(conventions.ExceptionMessageKey), tt.exceptionMessage)
400400
if tt.stackTrace != "" {
401-
attrs.PutStr(conventions.AttributeExceptionStacktrace, tt.stackTrace)
401+
attrs.PutStr(string(conventions.ExceptionStacktraceKey), tt.stackTrace)
402402
}
403403

404404
resource := pcommon.NewResource()

0 commit comments

Comments
 (0)