Skip to content

Commit 52b9227

Browse files
committed
update
1 parent 8d9b764 commit 52b9227

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

internal/lightstep_pb/transform.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ func (r *Request) ToOtel(ctx context.Context) (*lightstepCommon.ProjectTraces, e
5353

5454
result := &lightstepCommon.ProjectTraces{}
5555

56-
if r.orig.Auth != nil && r.orig.Auth.AccessToken != "" {
56+
if r.orig.Auth == nil || r.orig.Auth.AccessToken == "" {
57+
span.SetStatus(codes.Error, lightstepCommon.ErrNoAccessToken.Error())
58+
} else {
5759
result.AccessToken = r.orig.Auth.AccessToken
5860
}
5961

@@ -68,11 +70,12 @@ func (r *Request) ToOtel(ctx context.Context) (*lightstepCommon.ProjectTraces, e
6870
}
6971

7072
serviceName, ok := rAttr.Get(lightstepConstants.ComponentNameKey)
71-
if !ok {
73+
if ok {
74+
result.ServiceName = serviceName.Str()
75+
rAttr.PutStr("service.name", serviceName.Str())
76+
} else {
7277
span.SetStatus(codes.Error, lightstepCommon.ErrNoServiceName.Error())
7378
}
74-
result.ServiceName = serviceName.Str()
75-
rAttr.PutStr("service.name", serviceName.Str())
7679

7780
if r.orig.InternalMetrics != nil {
7881
for _, m := range r.orig.InternalMetrics.Counts {

internal/lightstep_thrift/transform.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ func (tr *Request) ToOtel(ctx context.Context) (*lightstepCommon.ProjectTraces,
4747

4848
result := &lightstepCommon.ProjectTraces{}
4949

50-
if tr.auth != nil && tr.auth.AccessToken != nil {
50+
if tr.auth == nil || tr.auth.AccessToken == nil {
51+
span.SetStatus(codes.Error, lightstepCommon.ErrNoAccessToken.Error())
52+
} else {
5153
result.AccessToken = tr.auth.GetAccessToken()
5254
}
5355

@@ -57,11 +59,12 @@ func (tr *Request) ToOtel(ctx context.Context) (*lightstepCommon.ProjectTraces,
5759

5860
tr.kvToAttr(tr.orig.Runtime.Attrs, &rAttr)
5961
serviceName, ok := rAttr.Get(lightstepConstants.ComponentNameKey)
60-
if !ok {
62+
if ok {
63+
result.ServiceName = serviceName.Str()
64+
rAttr.PutStr("service.name", serviceName.Str())
65+
} else {
6166
span.SetStatus(codes.Error, lightstepCommon.ErrNoServiceName.Error())
6267
}
63-
result.ServiceName = serviceName.Str()
64-
rAttr.PutStr("service.name", serviceName.Str())
6568

6669
if tr.orig.InternalMetrics != nil {
6770
for _, m := range tr.orig.InternalMetrics.Counts {

0 commit comments

Comments
 (0)