Skip to content

fix(semconv): avoid duplicate metric recording without attributes - #8849

Merged
MrAlias merged 6 commits into
open-telemetry:mainfrom
jstar0:fix/8780-semconv-empty-attrs
Sep 9, 2026
Merged

MrAlias merged 6 commits into
open-telemetry:mainfrom
jstar0:fix/8780-semconv-empty-attrs

Conversation

@jstar0

@jstar0 jstar0 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #8780

The retained v1.32.0-v1.34.0 generated metric helpers record through the empty-attributes fast path and then fall through to the general attribute path. This causes histogram helpers to export duplicate count/sum observations and invokes gauge helpers twice.

This updates all 60 affected helpers across the three retained semantic-convention versions and adds a semconvkit AST regression check so generated metric helpers must return after their no-attribute fast path.

Validation:

  • go test ./semconv/v1.32.0/...
  • go test ./semconv/v1.33.0/...
  • go test ./semconv/v1.34.0/...
  • go test ./semconvkit from internal/tools
  • make precommit completed generation, lint, README, and module checks, then stopped at the existing bridge/opentracing gRPC test with a server preface EOF; the changed semconv scopes pass.

@codecov

codecov Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

Codecov Report

โœ… All modified and coverable lines are covered by tests.
โœ… Project coverage is 88.6%. Comparing base (9f01e1e) to head (c4f3b00).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8849   +/-   ##
=====================================
  Coverage   88.6%   88.6%           
=====================================
  Files        333     333           
  Lines      21279   21279           
=====================================
  Hits       18863   18863           
  Misses      2416    2416           

see 2 files with indirect coverage changes

๐Ÿš€ New features to boost your workflow:
  • โ„๏ธ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jstar0

jstar0 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

The remaining check-links failure appears to be baseline-only, not caused by this PR.

  • Base: 736a14fcdca28b8cf5237e6b9b166ec6ed832bf7
  • Head: 37b816049b598997524f21847cf7e0322772a5c1
  • The six failing 403 URLs are unchanged in semconv/v1.32.0, v1.33.0, and v1.34.0 systemconv/metric.go.
  • The PR diff for those files only adds the no-attributes early return to Uptime.Record; it does not modify the referenced URLs.
  • The base branch's preceding check-links runs also reported unrelated 403 failures, confirming the checker is sensitive to existing external link availability.

All code-relevant checks for this head are passing. No unrelated generated-document link edits are proposed in this PR.

@MrAlias MrAlias left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The production change is focused, but the regression coverage needs to establish the one-call behavior before this is ready.

Comment thread internal/tools/semconvkit/main_test.go Resolved
@jstar0

jstar0 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the requested regression coverage in 5e0020a35.

  • Added a counting-instrument regression for semconv/v1.34.0/goconv.ScheduleDuration.Record without attributes; one helper call now must produce exactly one underlying Record call.
  • Tightened the generator test to enumerate all 60 affected Record methods across v1.32.0-v1.34.0 and require exactly one empty-attribute fast path for each.

Verification:

  • go test ./semconvkit from internal/tools: passed.
  • go test -race ./semconv/v1.34.0/goconv: passed.
  • make precommit reached the repository test phase, but is currently blocked by bridge/opentracing/TestBridgeTracer_ExtractAndInject_gRPC, which fails with error reading server preface: EOF in both race and non-race runs. No production code is changed by this follow-up.

@jstar0

jstar0 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the CHANGELOG.md conflict with current main via signed merge commit 2a1366e6e. The #8849 entry is kept under [Unreleased] > Fixed (the released sections are unchanged) and ./verify_released_changelog.sh main passes. No implementation files changed; the branch is mergeable again.

@jstar0

jstar0 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

The branch is now up to date with upstream main via signed merge commit c4f3b00. The refreshed checks are green for the Go test/race/coverage matrix, compatibility matrix, lint, govulncheck, CodeQL security checks, codecov, EasyCLA, changelog, and codespell. The remaining check-links failure reports the same six 403 responses from the existing Oracle and Superuser URLs in semconv/v1.32.0-v1.34.0/systemconv/metric.go; this PR only adds the empty-attributes early return and does not modify those URLs. CodeQL-Build is still running.

@MrAlias MrAlias added this to the v1.47.0 milestone Sep 9, 2026
@MrAlias
MrAlias merged commit 26c5b27 into open-telemetry:main Sep 9, 2026
50 of 51 checks passed
pellared added a commit that referenced this pull request Oct 2, 2026
This release contains the first stable release of the OpenTelemetry Go
Logs API and SDK.
Our project stability guarantees now apply to the following modules:

- `go.opentelemetry.io/otel/log`
- `go.opentelemetry.io/otel/sdk/log`

See our [versioning
policy](https://github.com/open-telemetry/opentelemetry-go/blob/main/VERSIONING.md)
for more information about these stability guarantees.

### Added

- Add `String` method for `KeyValue` type in
`go.opentelemetry.io/otel/attribute`. (#8205)
- Add `String` method for `Set` type in
`go.opentelemetry.io/otel/attribute`. (#8347)
- Add `WithMaxExportBatchSize` to `go.opentelemetry.io/otel/sdk/metric`
to configure the maximum export batch size for `PeriodicReader`. (#8960)
- Add `WithAttributeValueDepthLimit`, `DefaultAttributeValueDepthLimit`,
and `SpanLimits.AttributeValueDepthLimit` in
`go.opentelemetry.io/otel/sdk/trace` to configure the maximum depth of
span, event, link, and instrumentation scope attribute values. (#8938)
- Add `WithAttributeValueDepthLimit` in
`go.opentelemetry.io/otel/sdk/log` to configure the maximum depth of log
record and instrumentation scope attribute values. (#8938)
- Add `WithMaxResponseSize` to
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`,
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`, and
  `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#8941)
- Add experimental `ProbabilitySampler` in
`go.opentelemetry.io/otel/sdk/trace/x` that conforms to the
[OpenTelemetry specification's threshold-based sampling
algorithm](https://opentelemetry.io/docs/specs/otel/trace/sdk/#probabilitysampler).
(#8123)
- Add experimental `*Binder` extension interfaces in
`go.opentelemetry.io/otel/metric/x` for instruments that support binding
attributes ahead of time. (#8760)
- Add the experimental `Finisher` synchronous metric instrument
extension interface to `go.opentelemetry.io/otel/metric/x`. (#8906)

### Changed

- Use the [OpenTelemetry Attribute Collection representation for
non-OTLP
protocols](https://opentelemetry.io/docs/specs/otel/common/#attribute-collection-representation-for-non-otlp)
for metric data diffs in
`go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest`. (#8993)
- Apply a maximum depth of 64 by default to span, event, link, log
record, and instrumentation scope attribute values in
`go.opentelemetry.io/otel/sdk/trace` and
`go.opentelemetry.io/otel/sdk/log`. (#8938)
- Reduce allocations when applying attribute value length limits in
`go.opentelemetry.io/otel/sdk/trace` and
`go.opentelemetry.io/otel/sdk/log` by rebuilding composite values only
when truncation is needed. (#8912)
- Decode `traceparent` using a hex lookup table in
`go.opentelemetry.io/otel/propagation`, which rejects the
specification-disallowed upper-case characters without a separate scan
of the header. (#8739)
- Decode all characters at constant indices in `TraceIDFromHex` and
`SpanIDFromHex` in `go.opentelemetry.io/otel/trace` to eliminate bounds
checks. (#8740)

### Fixed

- Count valid U+FFFD replacement characters toward attribute value
length limits in `go.opentelemetry.io/otel/trace`,
`go.opentelemetry.io/otel/sdk/trace`, and
`go.opentelemetry.io/otel/sdk/log`.
- Truncate string attribute values to empty strings when the configured
length limit is zero, including malformed UTF-8, in
`go.opentelemetry.io/otel/trace`, `go.opentelemetry.io/otel/sdk/trace`,
and `go.opentelemetry.io/otel/sdk/log`. (#9054)
- Fix a data race in `NewPeriodicReader` where `r.inst` was assigned
after the background goroutine was launched in
`go.opentelemetry.io/otel/sdk/metric`. (#9028)
- Prevent precision loss for large `int64` values in `Sum`, `Histogram`,
and `ExponentialHistogram` aggregations in
`go.opentelemetry.io/otel/sdk/metric`. (#8981)
- Ensure `grpc.DialOption` values passed via `WithDialOption` take
precedence over conflicting internally-computed defaults in
  `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`,
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`, and
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`.
(#8805, #8834, #8836)
- Treat overflowing `OTEL_METRIC_EXPORT_INTERVAL` and
`OTEL_METRIC_EXPORT_TIMEOUT` values as invalid in
`go.opentelemetry.io/otel/sdk/metric`. (#8800)
- Prevent a panic in `NewFixedSizeReservoir` and
`FixedSizeReservoirProvider` when given a negative size in
`go.opentelemetry.io/otel/sdk/metric/exemplar`; negative sizes are now
clamped to zero, consistent with a size of zero. (#8832)
- Preserve exponential histogram `ZeroThreshold` during OTLP metric
export in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric`. (#8801)
- Ensure metric helpers in `go.opentelemetry.io/otel/semconv/v1.32.0`,
`go.opentelemetry.io/otel/semconv/v1.33.0`, and
`go.opentelemetry.io/otel/semconv/v1.34.0` record measurements only once
when no attributes are provided. (#8849)
- Treat empty `OTEL_TRACES_SAMPLER` and `OTEL_TRACES_SAMPLER_ARG` values
as unset in `go.opentelemetry.io/otel/sdk/trace`. (#8873)
- Normalize global `OTEL_EXPORTER_OTLP_ENDPOINT` path joining in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` so
trailing-slash base URLs do not produce double-slash log export paths.
(#8864)
- Prevent a deadlock when formatting an error passed to `RecordError`
calls back into the span in `go.opentelemetry.io/otel/sdk/trace`.
(#8815)
- Prevent `SimpleSpanProcessor.Shutdown` from panicking when constructed
with a nil exporter in `go.opentelemetry.io/otel/sdk/trace`. (#8844)
- Propagate invalid exponential histogram scale errors to Prometheus
exporter self-observability metrics in
`go.opentelemetry.io/otel/exporters/prometheus`. (#8839)
- Retain instrument advisory attributes configured with
`go.opentelemetry.io/otel/metric/x.WithDefaultAttributes` when a
matching View in `go.opentelemetry.io/otel/sdk/metric` does not specify
an attribute filter. (#8859)
- Ignore HTTP URL paths when building OTLP/gRPC metric exporter targets
from `OTEL_EXPORTER_OTLP_ENDPOINT` and
`OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`, while preserving `unix://` and
`unix-abstract://` targets; treat `unix-abstract://` endpoints as
insecure in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc` and
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#8862)
- Ignore HTTP(S) paths when deriving gRPC trace exporter endpoints from
`OTEL_EXPORTER_OTLP_ENDPOINT` and `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`
in `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`.
(#8852)
- Bound memory used while parsing dense W3C property metadata by storing
it compactly and materializing `Property` values on demand in
`go.opentelemetry.io/otel/baggage` and
`go.opentelemetry.io/otel/propagation`.

### Removed

- Remove the experimental `OTEL_GO_X_METRIC_EXPORT_BATCH_SIZE`
environment variable in `go.opentelemetry.io/otel/sdk/metric`.
  Use the `WithMaxExportBatchSize` option instead. (#8960)
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.

Semconv v1.32.0-v1.34.0 metric helpers record twice without attributes

3 participants