Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(HMS-2785): pass otel spans properly #711

Merged
merged 1 commit into from
Oct 16, 2023
Merged

Conversation

ezr-ondrej
Copy link
Member

@ezr-ondrej ezr-ondrej commented Oct 11, 2023

Otel needs a root spans, if that is not passed from external service, we should start one ourselves.
Also jobs shall retrieve these spans and not start new one.

For Jobs:
Screenshot from 2023-10-13 12-50-48

And for Kafka messages:
Screenshot from 2023-10-13 17-24-42

Copy link
Member

@lzap lzap left a comment

Choose a reason for hiding this comment

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

Great idea, let’s merge my PR first where I want to modify the contextLogger function in worker package to pass trace_id into logs so you can continue on this.

internal/logging/ctx.go Show resolved Hide resolved
internal/middleware/telemetry.go Show resolved Hide resolved
accountId := job.AccountID
id := job.Identity
logger := zerolog.Ctx(ctx).With().
Str("trace_id", span.SpanContext().TraceID().String()).
Str("job_id", job.ID.String()).
Int64("account_id", accountId).
Str("account_number", id.Identity.AccountNumber).
Copy link
Member

Choose a reason for hiding this comment

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

Yeah this makes a lot of sense. In my patch, I put trace_id at reservation level but I think this is much better place. I will move it here but I will not add any otel related stuff and leave this to you so you can further develop this.

Great idea, in the end, we will have one trace (aka transaction in GlitchTip) and spans for api pod then one big span for the worker pod and additional spans for individual functions.

@ezr-ondrej ezr-ondrej changed the title wip: pass spans properly fix(HMS-2785): pass otel spans properly Oct 13, 2023
Otel needs a root spans, if that is not passed from external service,
we should start one ourselves, instead of starting span once we decide there is one needed internally.
Also jobs and kafka shall retrieve these spans and continue, not start new spans.
@ezr-ondrej ezr-ondrej marked this pull request as ready for review October 13, 2023 15:28
@ezr-ondrej
Copy link
Member Author

/retest

@ezr-ondrej
Copy link
Member Author

/retest

@lzap
Copy link
Member

lzap commented Oct 16, 2023

/retest

"event_type", "availability_status",
),
}, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

I am assuming no changes were made here.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is the one additional header.

Copy link
Member

@lzap lzap left a comment

Choose a reason for hiding this comment

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

This is so much better than what I came up with. Great work.

@lzap
Copy link
Member

lzap commented Oct 16, 2023

Image problem again.

Comment on lines +125 to +131
if config.Telemetry.Enabled {
var traceHeaders propagation.MapCarrier = make(map[string]string)
otel.GetTextMapPropagator().Inject(ctx, traceHeaders)
for name, value := range traceHeaders {
headers = append(headers, GenericHeader{Key: name, Value: value})
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only change in the function, we are not adding the otel header, so we can continue the trace.

@ezr-ondrej
Copy link
Member Author

Image problem again.

My fault this time, working on a fix

@ezr-ondrej
Copy link
Member Author

/retest

@lzap lzap merged commit 0f3abc7 into RHEnVision:main Oct 16, 2023
6 checks passed
@lzap
Copy link
Member

lzap commented Oct 16, 2023

Merged thanks.

@ezr-ondrej ezr-ondrej deleted the root_spans branch October 16, 2023 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants