Skip to content

[chore] apply unkeyed literal initialization prevention #39832

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

Conversation

atoulme
Copy link
Contributor

@atoulme atoulme commented May 2, 2025

Adds a new check on checkapi that prevents the unkeyed initialization of literals. Unkeyed initialization breaks if the API exposed by the struct fields changes. Adding an anonymous _ struct{} field ensures all developers must use a named initialization.

This is explained in more detail in open-telemetry/opentelemetry-collector#12360

This PR needs #39830 and #39831 merged first.

@github-actions github-actions bot requested review from wangzlei and yanfeng1992 May 2, 2025 19:20
@atoulme atoulme marked this pull request as draft May 2, 2025 21:57
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label May 21, 2025
@atoulme atoulme force-pushed the apply_checkapi_unkeyed_literal_initialization branch from 45d4152 to 185c731 Compare May 22, 2025 02:19
@atoulme atoulme force-pushed the apply_checkapi_unkeyed_literal_initialization branch 2 times, most recently from 23379a6 to cb5bbf7 Compare May 22, 2025 02:34
@atoulme atoulme force-pushed the apply_checkapi_unkeyed_literal_initialization branch 2 times, most recently from fe2f529 to c486ab4 Compare May 22, 2025 03:04
@atoulme atoulme force-pushed the apply_checkapi_unkeyed_literal_initialization branch from c486ab4 to e9c8d0d Compare May 22, 2025 03:08
@atoulme atoulme marked this pull request as ready for review May 22, 2025 03:36
@github-actions github-actions bot removed the Stale label May 22, 2025
@songy23 songy23 merged commit 83443b7 into open-telemetry:main May 22, 2025
178 checks passed
@github-actions github-actions bot added this to the next release milestone May 22, 2025
dragonlord93 pushed a commit to dragonlord93/opentelemetry-collector-contrib that referenced this pull request May 23, 2025
…ry#39832)

Adds a new check on checkapi that prevents the unkeyed initialization of
literals. Unkeyed initialization breaks if the API exposed by the struct
fields changes. Adding an anonymous _ struct{} field ensures all
developers must use a named initialization.

This is explained in more detail in
open-telemetry/opentelemetry-collector#12360

This PR needs open-telemetry#39830 and open-telemetry#39831 merged first.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connector/datadog connector/exceptions connector/servicegraph connector/spanmetrics exporter/awss3 exporter/cassandra exporter/elasticsearch exporter/honeycombmarker exporter/loadbalancing exporter/logicmonitor exporter/prometheusremotewrite exporter/rabbitmq extension/azureauth extension/encoding/awscloudwatchmetricstreams extension/encoding/awslogsencoding extension/headerssetter extension/observer/cfgardenobserver extension/observer/hostobserver processor/datadogsemantics processor/deltatorate Delta To Rate processor processor/groupbyattrs Group By Attributes processor processor/k8sattributes k8s Attributes processor processor/metricsgeneration Metrics Generation processor processor/metricstransform Metrics Transform processor processor/remotetap processor/resource Resource processor receiver/apache receiver/apachespark receiver/awscloudwatchmetrics receiver/awsecscontainermetrics receiver/awss3 receiver/awsxray receiver/azuremonitor receiver/chrony receiver/cloudflare receiver/cloudfoundry receiver/datadog receiver/filelog receiver/filestats receiver/fluentforward receiver/gitlab receiver/httpcheck HTTP Check receiver receiver/jaeger receiver/journald receiver/libhoney receiver/loki receiver/mongodbatlas receiver/namedpipe receiver/nginx receiver/opencensus receiver/otelarrow receiver/purefa receiver/purefb receiver/snmp receiver/solace receiver/sqlquery SQL query receiver receiver/stef receiver/syslog receiver/tcpcheck receiver/tcplog receiver/tlscheck receiver/udplog receiver/wavefront receiver/windowseventlog receiver/zipkin Zipkin receiver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants