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

Add an option to dynamically add custom span attribute #1

Merged
merged 4 commits into from
Jul 5, 2023

Conversation

tigerwill90
Copy link
Owner

@tigerwill90 tigerwill90 commented Jul 5, 2023

This PR introduces a new option that allows customization of span attributes based on the incoming request.

mw := New("foobar", WithTracerProvider(provider), WithSpanAttributes(func(r *http.Request) []attribute.KeyValue {
    attrs := make([]attribute.KeyValue, 1)
    attrs[0] = attribute.String("http.target", r.URL.String())
    return attrs
}))

This enhancement provides the ability to include non-standard attributes, such as http.target, in the span information. This can be particularly useful for capturing additional contextual information specific to the request.

@tigerwill90 tigerwill90 changed the title Feat/options/span attribute Add an option to dynamically add custom span attribute Jul 5, 2023
@codecov
Copy link

codecov bot commented Jul 5, 2023

Codecov Report

Merging #1 (f45b85a) into master (5a40de2) will increase coverage by 2.63%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master       #1      +/-   ##
==========================================
+ Coverage   67.77%   70.40%   +2.63%     
==========================================
  Files           3        3              
  Lines          90       98       +8     
==========================================
+ Hits           61       69       +8     
  Misses         25       25              
  Partials        4        4              
Flag Coverage Δ
coverage.txt 70.40% <100.00%> (+2.63%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
foxtrace.go 75.86% <100.00%> (+1.78%) ⬆️
option.go 63.88% <100.00%> (+4.51%) ⬆️

@tigerwill90 tigerwill90 marked this pull request as ready for review July 5, 2023 10:42
@tigerwill90 tigerwill90 self-assigned this Jul 5, 2023
@tigerwill90 tigerwill90 merged commit 873f39f into master Jul 5, 2023
@tigerwill90 tigerwill90 deleted the feat/options/span-attribute branch July 5, 2023 11:11
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