Skip to content

Commit

Permalink
Update the otelglobal e2e test
Browse files Browse the repository at this point in the history
Verify the auto/sdk probe is being used.
  • Loading branch information
MrAlias committed Dec 19, 2024
1 parent 6098f3f commit 53bf8d3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
16 changes: 14 additions & 2 deletions internal/test/e2e/otelglobal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package main

import (
"context"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -33,11 +34,22 @@ func innerFunction(ctx context.Context) {
span.SetAttributes(attribute.String("inner.key", "inner.value"))
span.SetAttributes(attribute.Bool("cat.on_keyboard", true))
span.SetName("child override")
span.SetStatus(codes.Error, "i deleted the prod db sry")

err := errors.New("i deleted the prod db sry")
span.SetStatus(codes.Error, err.Error())
span.RecordError(err)

span.AddLink(trace.Link{
SpanContext: trace.NewSpanContext(trace.SpanContextConfig{
TraceID: trace.TraceID{0x2},
SpanID: trace.SpanID{0x1},
TraceFlags: trace.FlagsSampled,
}),
})
}

func createMainSpan(ctx context.Context) {
ctx, span := tracer.Start(ctx, "parent")
ctx, span := tracer.Start(ctx, "parent", trace.WithSpanKind(trace.SpanKindServer))
defer span.End()

innerFunction(ctx)
Expand Down
30 changes: 28 additions & 2 deletions internal/test/e2e/otelglobal/traces.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,34 @@
}
}
],
"events": [
{
"attributes": [
{
"key": "exception.type",
"value": {
"stringValue": "*errors.errorString"
}
},
{
"key": "exception.message",
"value": {
"stringValue": "i deleted the prod db sry"
}
}
],
"name": "exception"
}
],
"flags": 256,
"kind": 3,
"kind": 1,
"links": [
{
"flags": 256,
"spanId": "xxxxx",
"traceId": "xxxxx"
}
],
"name": "child override",
"parentSpanId": "xxxxx",
"spanId": "xxxxx",
Expand Down Expand Up @@ -110,7 +136,7 @@
}
],
"flags": 256,
"kind": 3,
"kind": 2,
"name": "parent",
"parentSpanId": "",
"spanId": "xxxxx",
Expand Down

0 comments on commit 53bf8d3

Please sign in to comment.