Skip to content

fix: Fix an issue where logging configuration could over-match for log records without a message or severity.#261

Merged
kinyoklion merged 6 commits intomainfrom
rlamb/fix-sampling-over-matching-for-empty-records
Oct 6, 2025
Merged

fix: Fix an issue where logging configuration could over-match for log records without a message or severity.#261
kinyoklion merged 6 commits intomainfrom
rlamb/fix-sampling-over-matching-for-empty-records

Conversation

@kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Oct 3, 2025

Summary

The CustomSampler errantly checked if message and severity were of the correct type before attempting to match them. If they were not, then they matched. The simplest solutions is to not do the check. Alternatively it could do the check, and when the type is not string they do not match.

How did you test this change?

Unit tests.

Other

After this PR is non-js SDKs should have their JSON files updated. I did not update in this PR because I didn't want to trigger a release of those SDKs.


Note

Ensure log rules requiring message/severity only match when the record has a string message/severity; add scenarios and test helpers across SDKs.

  • Sampling logic:
    • Go (go/internal/otel/custom_sampler.go): In matchesLogConfig, require record.Body() to be KindString for message matching; return false otherwise.
    • JS/TS (Node, Shared, Highlight Run): Simplify matchesLogConfig by removing permissive typeof gates; Shared explicitly rejects non-string record.body for message matching.
  • Tests:
    • Add log scenarios that verify configs with both message and severityText do not match when logs are empty, only have message, or only have severity (in Go/Node/Shared/Highlight Run JSONs).
    • Introduce helper to construct ReadableLogRecord from scenario input in Node/Shared tests and update usages.

Written by Cursor Bugbot for commit 67c9367. This will update automatically on new commits. Configure here.

@kinyoklion
Copy link
Member Author

bugbot review

cursor[bot]

This comment was marked as outdated.

@kinyoklion kinyoklion force-pushed the rlamb/fix-sampling-over-matching-for-empty-records branch from 00fcf18 to ec85e60 Compare October 3, 2025 22:40
@kinyoklion kinyoklion marked this pull request as ready for review October 3, 2025 22:59
@kinyoklion kinyoklion requested a review from a team as a code owner October 3, 2025 22:59
…github.com:launchdarkly/observability-sdk into rlamb/fix-sampling-over-matching-for-empty-records
@kinyoklion kinyoklion merged commit 500a6bf into main Oct 6, 2025
22 checks passed
@kinyoklion kinyoklion deleted the rlamb/fix-sampling-over-matching-for-empty-records branch October 6, 2025 17:20
kinyoklion pushed a commit that referenced this pull request Oct 6, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>launchdarkly-observability-android: 0.10.0</summary>

##
[0.10.0](launchdarkly-observability-android-0.9.0...launchdarkly-observability-android-0.10.0)
(2025-10-06)


### Features

* Cache OpenTelemetry metric instruments
([#256](#256))
([db67867](db67867))
</details>

<details><summary>go: 0.3.1</summary>

##
[0.3.1](go/v0.3.0...go/v0.3.1)
(2025-10-06)


### Bug Fixes

* Fix an issue where logging configuration could over-match for log
records without a message or severity.
([#261](#261))
([500a6bf](500a6bf))
</details>

<details><summary>observability: 0.4.5</summary>

##
[0.4.5](observability-0.4.4...observability-0.4.5)
(2025-10-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * highlight.run bumped to 9.22.2
</details>

<details><summary>observability-node: 0.3.1</summary>

##
[0.3.1](observability-node-0.3.0...observability-node-0.3.1)
(2025-10-06)


### Bug Fixes

* Fix an issue where logging configuration could over-match for log
records without a message or severity.
([#261](#261))
([500a6bf](500a6bf))
</details>

<details><summary>session-replay: 0.4.5</summary>

##
[0.4.5](session-replay-0.4.4...session-replay-0.4.5)
(2025-10-06)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * highlight.run bumped to 9.22.2
</details>

<details><summary>highlight.run: 9.22.2</summary>

##
[9.22.2](highlight.run-9.22.1...highlight.run-9.22.2)
(2025-10-06)


### Bug Fixes

* Fix an issue where logging configuration could over-match for log
records without a message or severity.
([#261](#261))
([500a6bf](500a6bf))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Release updates across Go, Android, Node, and web packages with a
logging bug fix, Android metric instrument caching, and dependency bump
to highlight.run 9.22.2.
> 
> - **Releases**:
>   - `go` → `0.3.1`
> - Bug fix: prevent logging config over-matching for records without
message/severity.
> - Update `go/internal/metadata/metadata.go` InstrumentationVersion to
`0.3.1`.
>   - `sdk/@launchdarkly/observability-node` → `0.3.1`
>     - Bug fix: same logging over-match fix.
>   - `sdk/@launchdarkly/observability-android` → `0.10.0`
>     - Feature: cache OpenTelemetry metric instruments.
>   - `sdk/@launchdarkly/observability` → `0.4.5`
>     - Dependency: bump `highlight.run` to `9.22.2`.
>   - `sdk/@launchdarkly/session-replay` → `0.4.5`
>     - Dependency: bump `highlight.run` to `9.22.2`.
>   - `sdk/highlight-run` → `9.22.2`
>     - Bug fix: logging over-match.
> - **Manifest**: update `.release-please-manifest.json` versions
accordingly.
> - **Packages**: update related `package.json` versions to match.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
7ae2ff1. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Vadman97 added a commit that referenced this pull request Jan 28, 2026
🤖 I have created a release *beep* *boop*
  ---


  <details><summary>go: 1.0.0</summary>

##
[1.0.0](go/v0.4.0...go/v1.0.0)
(2026-01-28)


  ### Features

* Add configuration to allow adjusting the batch and queue sizes for
logs and spans.
([abecbb6](abecbb6))
* Add export samplers.
([#143](#143))
([76fd41e](76fd41e))
* Add query for sampling config.
([#140](#140))
([6800fb1](6800fb1))
* Add trace based sampling for go plugin.
([#170](#170))
([dacbe76](dacbe76))
* Adjust the default export and queue batch sizes for logs and spans to
match the otel defaults.
([abecbb6](abecbb6))
* Basic go plugin implementation.
([#139](#139))
([48badda](48badda))
* Client-side event sampling custom sampler.
([#142](#142))
([82df812](82df812))
* Sample out children of spans that have been sampled out.
([#155](#155))
([a2d1d6e](a2d1d6e))
* Support Go observability initialization independent of plugins.
([#230](#230))
([ddd6d4b](ddd6d4b))


  ### Bug Fixes

* Fix an issue where logging configuration could over-match for log
records without a message or severity.
([#261](#261))
([500a6bf](500a6bf))
* Fix prealloc lint warning by preallocating slice capacity for error
attributes.
* **go:** configure default logger provider
([#192](#192))
([b97854d](b97854d))
  </details>

  <details><summary>launchdarkly-observability-dotnet: 1.0.0</summary>

##
[1.0.0](launchdarkly-observability-dotnet-0.3.0...launchdarkly-observability-dotnet-1.0.0)
(2026-01-28)


  ### Features

* Add basic config for dotnet plugin.
([#167](#167))
([3203e82](3203e82))
* Add custom sampler for dotnet.
([#175](#175))
([de74b20](de74b20))
* Add export/processor samplers.
([#178](#178))
([2431886](2431886))
* Add graphql query to get sampling config.
([#181](#181))
([ee51f80](ee51f80))
* Add initial plugin for dotnet.
([#173](#173))
([564536d](564536d))
* Add singleton for dotnet.
([#185](#185))
([c32cf1c](c32cf1c))
* Add support for environment variable configuration.
([#205](#205))
([5e3b1e1](5e3b1e1))
* Add support for non-core ASP.Net.
([#199](#199))
([b215109](b215109))
* Allow custom configuration of otel.
([#187](#187))
([54e7214](54e7214))
* Extend logging configuration. Format logs by default.
([#242](#242))
([2003517](2003517))


  ### Bug Fixes

* Make attributes optional for RecordLog.
([#202](#202))
([806ce08](806ce08))
  </details>

  <details><summary>launchdarkly-observability-python: 1.0.0</summary>

##
[1.0.0](launchdarkly-observability-python-0.1.1...launchdarkly-observability-python-1.0.0)
(2026-01-28)


  ### Features

* Add observability plugin support.
([#109](#109))
([7bc32bb](7bc32bb))
* Add sampling exporters.
([#99](#99))
([86a4612](86a4612))


  ### Bug Fixes

* Create span when no active span for error.
([#191](#191))
([0341b0f](0341b0f))
  </details>

  <details><summary>observability-node: 1.0.0</summary>

##
[1.0.0](observability-node-0.3.1...observability-node-1.0.0)
(2026-01-28)


  ### Features

* Update instrumentation configuration for ease of use.
([#112](#112))
([011032f](011032f))


  ### Bug Fixes

* Fix an issue where logging configuration could over-match for log
records without a message or severity.
([#261](#261))
([500a6bf](500a6bf))
  </details>

  <details><summary>observability: 1.0.0</summary>

##
[1.0.0](observability-0.5.2...observability-1.0.0)
(2026-01-28)


  ### Features

* publish umd for browser environments
([#334](#334))
([3e90673](3e90673))
* Version Packages
([#136](#136))
([c271dc8](c271dc8))
  </details>

  <details><summary>session-replay: 1.0.0</summary>

##
[1.0.0](session-replay-0.5.2...session-replay-1.0.0)
(2026-01-28)


  ### Features

* publish umd for browser environments
([#334](#334))
([3e90673](3e90673))
* Version Packages
([#136](#136))
([c271dc8](c271dc8))
  </details>

  <details><summary>launchdarkly-observability-android: 0.25.0</summary>

##
[0.25.0](launchdarkly-observability-android-0.24.0...launchdarkly-observability-android-0.25.0)
(2026-01-28)


  ### Features

* O11Y-969 - Add runtime control for Session Replay capture
([#355](#355))
([1d4398e](1d4398e))
  </details>

  ---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Mostly version/changelog updates generated by release tooling; the
only code change is a minor Go allocation tweak in error recording with
minimal behavioral risk.
> 
> **Overview**
> Publishes new release versions across the monorepo, marking the Go,
.NET, Node, Python, Browser Observability, and `session-replay` SDKs as
**1.0.0 stable**, and bumping Android to **0.25.0** (Release Please
changelog + manifest/version file updates).
> 
> Includes one small Go runtime change: `recordSpanError` now
preallocates the attribute slice capacity before appending exception
fields and tags (lint/perf-only, no behavior change intended).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f343da8. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Vadim Korolik <vkorolik@gmail.com>
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.

2 participants