opentelemetry-erlang icon indicating copy to clipboard operation
opentelemetry-erlang copied to clipboard

feat: setup code attributes in Elixir macros

Open btkostner opened this issue 1 year ago • 6 comments

This replaces #550. It adds code attributes to all Elixir macro calls. This information is gathered at compile time, and then merged with the start opt attributes at runtime. I created a new public function to format these attributes in case down the line we want to format them differently (like removing the "Elixir" prefix from namespace) and in case other libraries need them while not using the macros.

The end result is you get these attributes for the Elixir Tracer macros: code.filepath, code.function, code.lineno, code.namespace.

btkostner avatar Dec 05 '24 00:12 btkostner

Codecov Report

:x: Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 18.45%. Comparing base (9f7affe) to head (543b8c0). :warning: Report is 142 commits behind head on main.

Files with missing lines Patch % Lines
...pps/opentelemetry_api/lib/open_telemetry/tracer.ex 60.00% 2 Missing :warning:
...opentelemetry_api/lib/open_telemetry/attributes.ex 88.88% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #808      +/-   ##
==========================================
+ Coverage   17.32%   18.45%   +1.13%     
==========================================
  Files          24       25       +1     
  Lines         710      726      +16     
==========================================
+ Hits          123      134      +11     
- Misses        587      592       +5     
Flag Coverage Δ
api 18.45% <78.57%> (+1.13%) :arrow_up:
elixir 18.45% <78.57%> (+1.13%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Dec 05 '24 00:12 codecov[bot]

Sorry, I missed that there was a new PR. I'll get this reviewed soon.

tsloughter avatar Feb 13 '25 13:02 tsloughter

I'm still torn on if this needs a configuration option. @bryannaegele thoughts?

I don't like the idea of having to check an option everytime a span is made, but not sure people wouldn't prefer to be able to turn this off for some reason. Nothing else adds attributes to your spans automatically right now, right?

I suppose we could make it optional later if anyone actually cares.

tsloughter avatar Feb 19 '25 11:02 tsloughter

Let me see if I can pull some examples from other ecosystems and see what they do 👀

btkostner avatar Feb 19 '25 18:02 btkostner

@btkostner thanks!

tsloughter avatar Feb 23 '25 12:02 tsloughter

Oh and last I checked, I think months ago, no one else implemented these attributes at all :)

tsloughter avatar Feb 23 '25 12:02 tsloughter