@@ -18,7 +18,6 @@ import (
1818 "github.com/stretchr/testify/require"
1919 config "go.opentelemetry.io/contrib/otelconf/v0.3.0"
2020 "go.opentelemetry.io/otel/attribute"
21- semconv "go.opentelemetry.io/otel/semconv/v1.37.0"
2221 "go.uber.org/zap"
2322 "go.uber.org/zap/zapcore"
2423 "go.uber.org/zap/zaptest/observer"
@@ -185,9 +184,9 @@ func TestCreateLoggerWithResource(t *testing.T) {
185184 },
186185 resourceConfig : map [string ]* string {},
187186 wantFields : map [string ]string {
188- string ( semconv . ServiceNameKey ): "mycommand" ,
189- string ( semconv . ServiceVersionKey ): "1.0.0" ,
190- string ( semconv . ServiceInstanceIDKey ) : "" ,
187+ "service.name" : "mycommand" ,
188+ "service.version" : "1.0.0" ,
189+ "service.instance.id" : "" ,
191190 },
192191 },
193192 {
@@ -197,12 +196,12 @@ func TestCreateLoggerWithResource(t *testing.T) {
197196 Version : "1.0.0" ,
198197 },
199198 resourceConfig : map [string ]* string {
200- string ( semconv . ServiceNameKey ) : ptr ("custom-service" ),
199+ "service.name" : ptr ("custom-service" ),
201200 },
202201 wantFields : map [string ]string {
203- string ( semconv . ServiceNameKey ): "custom-service" ,
204- string ( semconv . ServiceVersionKey ): "1.0.0" ,
205- string ( semconv . ServiceInstanceIDKey ) : "" ,
202+ "service.name" : "custom-service" ,
203+ "service.version" : "1.0.0" ,
204+ "service.instance.id" : "" ,
206205 },
207206 },
208207 {
@@ -212,12 +211,12 @@ func TestCreateLoggerWithResource(t *testing.T) {
212211 Version : "1.0.0" ,
213212 },
214213 resourceConfig : map [string ]* string {
215- string ( semconv . ServiceVersionKey ) : ptr ("2.0.0" ),
214+ "service.version" : ptr ("2.0.0" ),
216215 },
217216 wantFields : map [string ]string {
218- string ( semconv . ServiceNameKey ): "mycommand" ,
219- string ( semconv . ServiceVersionKey ): "2.0.0" ,
220- string ( semconv . ServiceInstanceIDKey ) : "" ,
217+ "service.name" : "mycommand" ,
218+ "service.version" : "2.0.0" ,
219+ "service.instance.id" : "" ,
221220 },
222221 },
223222 {
@@ -230,10 +229,10 @@ func TestCreateLoggerWithResource(t *testing.T) {
230229 "custom.field" : ptr ("custom-value" ),
231230 },
232231 wantFields : map [string ]string {
233- string ( semconv . ServiceNameKey ): "mycommand" ,
234- string ( semconv . ServiceVersionKey ): "1.0.0" ,
235- string ( semconv . ServiceInstanceIDKey ) : "" , // Just check presence
236- "custom.field" : "custom-value" ,
232+ "service.name" : "mycommand" ,
233+ "service.version" : "1.0.0" ,
234+ "service.instance.id" : "" , // Just check presence
235+ "custom.field" : "custom-value" ,
237236 },
238237 },
239238 {
@@ -242,7 +241,7 @@ func TestCreateLoggerWithResource(t *testing.T) {
242241 resourceConfig : nil ,
243242 wantFields : map [string ]string {
244243 // A random UUID is injected for service.instance.id by default
245- string ( semconv . ServiceInstanceIDKey ) : "" , // Just check presence
244+ "service.instance.id" : "" , // Just check presence
246245 },
247246 },
248247 {
@@ -308,7 +307,7 @@ func TestCreateLoggerWithResource(t *testing.T) {
308307
309308 // Verify all expected fields
310309 for k , v := range tt .wantFields {
311- if k == string ( semconv . ServiceInstanceIDKey ) {
310+ if k == "service.instance.id" {
312311 // For service.instance.id just verify it exists since it's auto-generated
313312 assert .Contains (t , enc .Fields , k )
314313 } else {
@@ -368,16 +367,16 @@ func TestLogger_OTLP(t *testing.T) {
368367 rl := logs .ResourceLogs ().At (0 )
369368
370369 resourceAttrs := rl .Resource ().Attributes ().AsRaw ()
371- assert .Equal (t , service , resourceAttrs [string ( semconv . ServiceNameKey ) ])
372- assert .Equal (t , version , resourceAttrs [string ( semconv . ServiceVersionKey ) ])
370+ assert .Equal (t , service , resourceAttrs ["service.name" ])
371+ assert .Equal (t , version , resourceAttrs ["service.version" ])
373372 assert .Equal (t , testValue , resourceAttrs [testAttribute ])
374373
375374 // Check that the resource attributes are not duplicated in the log records
376375 sl := rl .ScopeLogs ().At (0 )
377376 logRecord := sl .LogRecords ().At (0 )
378377 attrs := logRecord .Attributes ().AsRaw ()
379- assert .NotContains (t , attrs , string ( semconv . ServiceNameKey ) )
380- assert .NotContains (t , attrs , string ( semconv . ServiceVersionKey ) )
378+ assert .NotContains (t , attrs , "service.name" )
379+ assert .NotContains (t , attrs , "service.version" )
381380 assert .NotContains (t , attrs , testAttribute )
382381
383382 receivedLogs ++
@@ -417,9 +416,9 @@ func newOTLPLogger(t *testing.T, level zapcore.Level, handler func(plogotlp.Expo
417416 // written to the OTLP processor
418417 },
419418 Resource : map [string ]* string {
420- string ( semconv . ServiceNameKey ) : ptr (service ),
421- string ( semconv . ServiceVersionKey ) : ptr (version ),
422- testAttribute : ptr (testValue ),
419+ "service.name" : ptr (service ),
420+ "service.version" : ptr (version ),
421+ testAttribute : ptr (testValue ),
423422 },
424423 }
425424
0 commit comments