Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DO $$
ALTER TABLE IF EXISTS event_sourcing_light ADD COLUMN IF NOT EXISTS ddspan JSONB;
END $$;
16 changes: 14 additions & 2 deletions pkg/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,17 @@ func (h *DBHandler) DBWriteEslEventInternal(ctx context.Context, eventType Event
span.Finish(tracer.WithError(err))
}()

carrier := make(map[string]string)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also add the part where we read from the db

err = tracer.Inject(span.Context(), carrier)
if err != nil {
logger.FromContext(ctx).Sugar().Warnf("Unable to serialize trace context into carrier map: %v", err)
}
jsonTraceContext, err := json.Marshal(carrier)
if err != nil {
logger.FromContext(ctx).Sugar().Warnf("Unable to serialize trace context into json: %v", err)
jsonTraceContext = []byte("{}") // Store empty JSON on failure
}

dataMap, err := convertObjectToMap(data)

if err != nil {
Expand All @@ -326,7 +337,7 @@ func (h *DBHandler) DBWriteEslEventInternal(ctx context.Context, eventType Event
return fmt.Errorf("could not marshal combined json data: %w", err)
}

insertQuery := h.AdaptQuery("INSERT INTO event_sourcing_light (created, event_type, json) VALUES (?, ?, ?);")
insertQuery := h.AdaptQuery("INSERT INTO event_sourcing_light (created, event_type, json, ddspan) VALUES (?, ?, ?, ?);")

now, err := h.DBReadTransactionTimestamp(ctx, tx)
if err != nil {
Expand All @@ -337,7 +348,8 @@ func (h *DBHandler) DBWriteEslEventInternal(ctx context.Context, eventType Event
insertQuery,
*now,
eventType,
jsonToInsert)
jsonToInsert,
jsonTraceContext)

if err != nil {
return fmt.Errorf("could not write internal esl event into DB. Error: %w", err)
Expand Down
Loading