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

WIP: Better span events serialization when supported #4279

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Jan 10, 2025

What does this PR do?

Motivation:

Change log entry

Additional Notes:

How to test the change?

Copy link

👋 Hey @marcotc, please fill "Change log entry" section in the pull request description.

If changes need to be present in CHANGELOG.md you can state it this way

**Change log entry**

Yes. A brief summary to be placed into the CHANGELOG.md

(possible answers Yes/Yep/Yeah)

Or you can opt out like that

**Change log entry**

None.

(possible answers No/Nope/None)

Visited at: 2025-01-10 23:31:10 UTC

@github-actions github-actions bot added core Involves Datadog core libraries tracing labels Jan 10, 2025
allow(trace_encoder).to receive(:encode_trace).with(encoder, traces[0]).and_return('1')
allow(trace_encoder).to receive(:encode_trace).with(encoder, traces[1]).and_return('22')
allow(trace_encoder).to receive(:encode_trace).with(encoder, traces[2]).and_return('333')
allow(trace_encoder).to receive(:encode_trace).with(encoder, traces[0], native_events_supported).and_return('1')
Copy link
Contributor

Choose a reason for hiding this comment

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

Code Quality Violation

Suggested change
allow(trace_encoder).to receive(:encode_trace).with(encoder, traces[0], native_events_supported).and_return('1')
allow(trace_encoder).to receive(:encode_trace).with(encoder, traces.first, native_events_supported).and_return('1')
Improve readability with first (...read more)

This rule encourages the use of first and last methods over array indexing to access the first and last elements of an array, respectively. The primary reason behind this rule is to improve code readability. Using first and last makes it immediately clear that you are accessing the first or last element of the array, which might not be immediately obvious with array indexing, especially for developers who are new to Ruby.

The use of these methods also helps to make your code more idiomatic, which is a crucial aspect of writing effective Ruby code. Idiomatic code is easier to read, understand, and maintain. It also tends to be more efficient, as idioms often reflect patterns that are optimized for the language.

To adhere to this rule, replace the use of array indexing with first or last methods when you want to access the first and last elements of an array. For instance, instead of arr[0] use arr.first and instead of arr[-1] use arr.last. However, note that this rule should be applied only when reading values. When modifying the first or last elements, array indexing should still be used. For example, arr[0] = 'new_value' and arr[-1] = 'new_value'.

View in Datadog  Leave us feedback  Documentation

@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Jan 10, 2025

Datadog Report

Branch report: span-events-writer
Commit report: 73d1168
Test service: dd-trace-rb

✅ 0 Failed, 22148 Passed, 1476 Skipped, 5m 21.53s Total Time

@pr-commenter
Copy link

pr-commenter bot commented Jan 10, 2025

Benchmarks

Benchmark execution time: 2025-01-11 00:19:36

Comparing candidate commit 73d1168 in PR branch span-events-writer with baseline commit aff0f7c in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 31 metrics, 2 unstable metrics.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 99.10714% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.75%. Comparing base (aff0f7c) to head (73d1168).
Report is 27 commits behind head on master.

Files with missing lines Patch % Lines
lib/datadog/core/encoding.rb 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4279      +/-   ##
==========================================
+ Coverage   97.73%   97.75%   +0.01%     
==========================================
  Files        1354     1355       +1     
  Lines       82449    82543      +94     
  Branches     4236     4241       +5     
==========================================
+ Hits        80584    80686     +102     
+ Misses       1865     1857       -8     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants