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

feat: http client integration #876

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

aldy505
Copy link
Contributor

@aldy505 aldy505 commented Aug 27, 2024

An effort to implement this: https://develop.sentry.dev/sdk/telemetry/traces/modules/requests/

Since we already have tracing without performance, this should be good to go.

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.06%. Comparing base (a6acd05) to head (7d9555d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #876      +/-   ##
==========================================
+ Coverage   82.85%   83.06%   +0.21%     
==========================================
  Files          55       56       +1     
  Lines        4619     4677      +58     
==========================================
+ Hits         3827     3885      +58     
  Misses        636      636              
  Partials      156      156              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ribice
Copy link
Collaborator

ribice commented Sep 3, 2024

@aldy505 We should document this (in _examples, and perhaps sentry-docs?), and also update changelog accordingly.


span := sentry.StartSpan(ctx, "http.client", sentry.WithTransactionName(fmt.Sprintf("%s %s", request.Method, cleanRequestURL)))

for k, v := range s.tags {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we just set the span.Tags instead of ranging through these, and setting one by one?

This is the 'right' way to do it, but it involves checking for nil map and dealing with mutex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lol good catch. I was copying directly from this PR aldy505/sentry-integration#1

@aldy505 aldy505 requested a review from ribice September 3, 2024 14:04
Comment on lines 73 to 75
span := sentry.StartSpan(ctx, "http.client", sentry.WithTransactionName(fmt.Sprintf("%s %s", request.Method, cleanRequestURL)))
span.Tags = s.tags
defer span.Finish()
Copy link
Member

Choose a reason for hiding this comment

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

We do not want to always start transactions here. If one already exists, start a child span.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to be clear: http.client spans should only created if there is any parent span?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, Sentry does not work well with these kind of single span transactions. We can revisit this once span streaming is fully supported in the product, but this will take a few months.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah got it.

Copy link
Member

Choose a reason for hiding this comment

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

https://sentry.io/insights/http/ should also work with these spans fwiw, docs are here.

Copy link
Member

Choose a reason for hiding this comment

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

*which you already mentioned in the PR description, nvm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another question (unrelated): Does that also affects all the span op within the insights module? Meaning not only http.client, but db.sql and messaging.* also counts?

Copy link
Member

Choose a reason for hiding this comment

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

I guess technically we extract all the required fields from a transaction and store it into the span data set, though this is not how these modules where initially designed to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants