|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "encoding/json" |
| 6 | + "go.amzn.com/lambda/appctx" |
| 7 | + "go.amzn.com/lambda/interop" |
| 8 | +) |
| 9 | + |
| 10 | +type LocalStackTracer struct { |
| 11 | + invoke *interop.Invoke |
| 12 | +} |
| 13 | + |
| 14 | +func (t *LocalStackTracer) Configure(invoke *interop.Invoke) { |
| 15 | + t.invoke = invoke |
| 16 | +} |
| 17 | + |
| 18 | +func (t *LocalStackTracer) CaptureInvokeSegment(ctx context.Context, criticalFunction func(context.Context) error) error { |
| 19 | + return criticalFunction(ctx) |
| 20 | +} |
| 21 | + |
| 22 | +func (t *LocalStackTracer) CaptureInitSubsegment(ctx context.Context, criticalFunction func(context.Context) error) error { |
| 23 | + return criticalFunction(ctx) |
| 24 | +} |
| 25 | + |
| 26 | +func (t *LocalStackTracer) CaptureInvokeSubsegment(ctx context.Context, criticalFunction func(context.Context) error) error { |
| 27 | + return criticalFunction(ctx) |
| 28 | +} |
| 29 | + |
| 30 | +func (t *LocalStackTracer) CaptureOverheadSubsegment(ctx context.Context, criticalFunction func(context.Context) error) error { |
| 31 | + return criticalFunction(ctx) |
| 32 | +} |
| 33 | + |
| 34 | +func (t *LocalStackTracer) RecordInitStartTime() {} |
| 35 | +func (t *LocalStackTracer) RecordInitEndTime() {} |
| 36 | +func (t *LocalStackTracer) SendInitSubsegmentWithRecordedTimesOnce(ctx context.Context) {} |
| 37 | +func (t *LocalStackTracer) SendRestoreSubsegmentWithRecordedTimesOnce(ctx context.Context) {} |
| 38 | +func (t *LocalStackTracer) MarkError(ctx context.Context) {} |
| 39 | +func (t *LocalStackTracer) AttachErrorCause(ctx context.Context, errorCause json.RawMessage) {} |
| 40 | + |
| 41 | +func (t *LocalStackTracer) WithErrorCause(ctx context.Context, appCtx appctx.ApplicationContext, criticalFunction func(ctx context.Context) error) func(ctx context.Context) error { |
| 42 | + return criticalFunction |
| 43 | +} |
| 44 | +func (t *LocalStackTracer) WithError(ctx context.Context, appCtx appctx.ApplicationContext, criticalFunction func(ctx context.Context) error) func(ctx context.Context) error { |
| 45 | + return criticalFunction |
| 46 | +} |
| 47 | +func (t *LocalStackTracer) BuildTracingHeader() func(context.Context) string { |
| 48 | + // extract root trace ID and parent from context and build the tracing header |
| 49 | + return func(ctx context.Context) string { |
| 50 | + return t.invoke.TraceID |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +func (t *LocalStackTracer) BuildTracingCtxForStart() *interop.TracingCtx { |
| 55 | + return nil |
| 56 | +} |
| 57 | +func (t *LocalStackTracer) BuildTracingCtxAfterInvokeComplete() *interop.TracingCtx { |
| 58 | + return nil |
| 59 | +} |
| 60 | + |
| 61 | +func NewLocalStackTracer() *LocalStackTracer { |
| 62 | + return &LocalStackTracer{} |
| 63 | +} |
0 commit comments