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

use some collection expressions #6106

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

SimonCropp
Copy link
Contributor

Fixes #
Design discussion issue #

Changes

IMO they are more readable. and in many scenarios result in better perf

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@SimonCropp SimonCropp requested a review from a team as a code owner January 27, 2025 00:10
@github-actions github-actions bot added documentation Documentation related pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry.Extensions.Propagators Issues related to OpenTelemetry.Extensions.Propagators NuGet package pkg:OpenTelemetry.Shims.OpenTracing Issues related to OpenTelemetry.Shims.OpenTracing NuGet package perf Performance related pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package labels Jan 27, 2025
Copy link
Contributor

@ysolomchenko ysolomchenko left a comment

Choose a reason for hiding this comment

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

I also think that collection expressions are more readable.

Copy link
Contributor

@TimothyMothra TimothyMothra left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -29,19 +29,19 @@ public static void Main()
.AddView(instrumentName: "MyCounter", name: "MyCounterRenamed")

// Change Histogram boundaries using the Explicit Bucket Histogram aggregation.
.AddView(instrumentName: "MyHistogram", new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 } })
.AddView(instrumentName: "MyHistogram", new ExplicitBucketHistogramConfiguration() { Boundaries = [10, 20] })
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to highlight that we are creating double's array. It affects couple of other places.

Suggested change
.AddView(instrumentName: "MyHistogram", new ExplicitBucketHistogramConfiguration() { Boundaries = [10, 20] })
.AddView(instrumentName: "MyHistogram", new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0] })

Copy link
Contributor

Choose a reason for hiding this comment

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

You need to fix other places.

Copy link
Contributor

Choose a reason for hiding this comment

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

I checked this and Boundaries is a double array so I think this is safe. The compiler will reject an int array.

However since this is a doc example, I'm good if we want to insist on specifying the types here.

Copy link
Contributor

@Kielek Kielek left a comment

Choose a reason for hiding this comment

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

All places using double should follow xy.0 notation

@SimonCropp SimonCropp marked this pull request as draft January 31, 2025 09:31
Copy link
Contributor

github-actions bot commented Feb 8, 2025

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Feb 8, 2025
Copy link

codecov bot commented Feb 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.37%. Comparing base (89ea5c6) to head (acf1791).
Report is 5 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6106      +/-   ##
==========================================
- Coverage   86.39%   86.37%   -0.02%     
==========================================
  Files         257      257              
  Lines       11640    11625      -15     
==========================================
- Hits        10056    10041      -15     
  Misses       1584     1584              
Files with missing lines Coverage Δ
...nTelemetry.Api/Context/Propagation/B3Propagator.cs 85.86% <ø> (-0.16%) ⬇️
...metry.Api/Context/Propagation/BaggagePropagator.cs 84.48% <ø> (-0.52%) ⬇️
...nTelemetry.Api/Logs/LogRecordSeverityExtensions.cs 100.00% <ø> (ø)
...TelemetryProtocol/OtlpExporterOptionsExtensions.cs 96.80% <ø> (-0.10%) ⬇️
...heus.HttpListener/PrometheusHttpListenerOptions.cs 100.00% <ø> (ø)
....Exporter.Zipkin/ZipkinExporterHelperExtensions.cs 98.21% <ø> (-0.04%) ⬇️
...enTelemetry.Extensions.Propagators/B3Propagator.cs 85.86% <ø> (-0.16%) ⬇️
...lemetry.Extensions.Propagators/JaegerPropagator.cs 95.31% <ø> (-0.08%) ⬇️
src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs 91.42% <ø> (-0.24%) ⬇️

@SimonCropp SimonCropp marked this pull request as ready for review February 12, 2025 20:29
@github-actions github-actions bot removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Feb 13, 2025
Copy link
Contributor

@Kielek Kielek left a comment

Choose a reason for hiding this comment

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

2 minor changes related to int vs long.
Other parts LGTM

test/OpenTelemetry.Api.Tests/Trace/SpanAttributesTest.cs Outdated Show resolved Hide resolved
test/OpenTelemetry.Tests/Trace/LinkTest.cs Outdated Show resolved Hide resolved
@Kielek
Copy link
Contributor

Kielek commented Feb 13, 2025

@SimonCropp, sorry, it needs to be L.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation related perf Performance related pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Prometheus.HttpListener Issues related to OpenTelemetry.Exporter.Prometheus.HttpListener NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry.Extensions.Hosting Issues related to OpenTelemetry.Extensions.Hosting NuGet package pkg:OpenTelemetry.Extensions.Propagators Issues related to OpenTelemetry.Extensions.Propagators NuGet package pkg:OpenTelemetry.Shims.OpenTracing Issues related to OpenTelemetry.Shims.OpenTracing NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants