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(@opentelemetry-instrumentation-http): support adding custom attributes before a span is started #2332

Merged

Conversation

echoontheway
Copy link
Contributor

@echoontheway echoontheway commented Jul 7, 2021

Which problem is this PR solving?

  • support adding custom attributes before a span is started for opentelemetry-instrumentation-http
  • help to use some custom fields to make the sample decision
  • help to report some custom fields before a request/response

Short description of the changes

  • add startIncomingSpanHook,startOutgoingSpanHook and corresponding test for opentelemetry-instrumentation-http

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 7, 2021

CLA Signed

The committers are authorized under a signed CLA.

Copy link
Member

@vmarchaud vmarchaud left a comment

Choose a reason for hiding this comment

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

lgtm

@vmarchaud vmarchaud requested a review from Flarna July 11, 2021 07:59
@vmarchaud vmarchaud added the enhancement New feature or request label Jul 11, 2021
@codecov
Copy link

codecov bot commented Jul 11, 2021

Codecov Report

Merging #2332 (0d393d9) into main (9c10bd7) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 0d393d9 differs from pull request most recent head c637254. Consider uploading reports for the commit c637254 to get more accurate results

@@            Coverage Diff             @@
##             main    #2332      +/-   ##
==========================================
- Coverage   92.77%   92.76%   -0.02%     
==========================================
  Files         145      145              
  Lines        5221     5226       +5     
  Branches     1070     1071       +1     
==========================================
+ Hits         4844     4848       +4     
- Misses        377      378       +1     
Impacted Files Coverage Δ
...ges/opentelemetry-instrumentation-http/src/http.ts 94.98% <100.00%> (+0.09%) ⬆️
...es/opentelemetry-instrumentation-http/src/utils.ts 99.02% <100.00%> (ø)
...emetry-api-metrics/src/platform/node/globalThis.ts 0.00% <0.00%> (-100.00%) ⬇️

Copy link
Member

@Flarna Flarna left a comment

Choose a reason for hiding this comment

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

Please describe the new options in the readme of the package.

export interface StartOutgoingSpanCustomAttributeFunction {
(request: RequestOptions ): SpanAttributes;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

In the specs meeting it looks like there will be a different way to doing this (if I'm reading and listening correctly)

https://github.com/open-telemetry/oteps/blob/8335c9a53cdf3398075dd9523d3752522c0ece28/text/0165-instrumentation-api.md

Copy link
Member

Choose a reason for hiding this comment

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

I believe i read it the same as you, this is welcome as a lot of instrumentation had some kind of system like this already. I believe this should be handled in the base instrumentation class though. I think it make sense to create a dedicated issue for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍
Before it's handled in the base instrumentation, will these startHooks for http be accepted? For I wanna use some custom fields to make the sample decision in my project. :)

Copy link
Member

Choose a reason for hiding this comment

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

I think so

@echoontheway
Copy link
Contributor Author

Please describe the new options in the readme of the package.

done :)

@vmarchaud
Copy link
Member

@echoontheway Could you fix the conflicts ?

@echoontheway echoontheway force-pushed the feature/echo_addStartSpanHook branch from 774d8d9 to bcd3206 Compare July 26, 2021 06:39
@echoontheway echoontheway force-pushed the feature/echo_addStartSpanHook branch from bcd3206 to 1c5221a Compare July 26, 2021 06:56
@echoontheway echoontheway changed the title feat(opentelemetry-instrumentation-http): support adding custom attri… feat(@opentelemetry-instrumentation-http): support adding custom attributes before a span is started Jul 26, 2021
@echoontheway
Copy link
Contributor Author

@echoontheway Could you fix the conflicts ?

done,sorry for late :)

@dyladan dyladan requested a review from rauno56 as a code owner July 26, 2021 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants