Skip to content

Conversation

trask
Copy link
Member

@trask trask commented Oct 11, 2025

Adds support for capturing Logstash StructuredArguments (e.g., StructuredArguments.v() and StructuredArguments.keyValue()) as OpenTelemetry log record attributes.

Key changes:

  • Adds new configuration option otel.instrumentation.logback-appender.experimental.capture-logstash-structured-arguments (defaults to false)
  • Renames existing capture-logstash-attributes config to capture-logstash-marker-attributes for clarity (with deprecation support)
  • Splits Logstash marker and structured arguments tests into separate test suites for better organization
  • Updates documentation with new configuration options

Resolves #14230

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask force-pushed the logstash-structured-args branch from ab6b5f7 to feda427 Compare October 11, 2025 18:54
@github-actions github-actions bot added the test native This label can be applied to PRs to trigger them to run native tests label Oct 11, 2025
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask force-pushed the logstash-structured-args branch from 1195199 to 9373335 Compare October 11, 2025 19:35
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask force-pushed the logstash-structured-args branch from df8dd85 to 25815fa Compare October 11, 2025 20:55
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask force-pushed the logstash-structured-args branch from 71f14a8 to 5d8517e Compare October 11, 2025 21:10
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

| `otel.instrumentation.logback-appender.experimental.capture-logger-context-attributes` | Boolean | `false` | Enable the capture of Logback logger context properties as attributes. |
| `otel.instrumentation.logback-appender.experimental.capture-arguments` | Boolean | `false` | Enable the capture of Logback logger arguments. |
| `otel.instrumentation.logback-appender.experimental.capture-logstash-attributes` | Boolean | `false` | Enable the capture of Logstash attributes, supported are those added to logs via `Markers.append()`, `Markers.appendEntries()`, `Markers.appendArray()` and `Markers.appendRaw()` methods. |
| `otel.instrumentation.logback-appender.experimental.capture-logstash-marker-attributes` | Boolean | `false` | Enable the capture of Logstash markers, supported are those added to logs via `Markers.append()`, `Markers.appendEntries()`, `Markers.appendArray()` and `Markers.appendRaw()` methods. |
Copy link
Member Author

Choose a reason for hiding this comment

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

renamed capture-logstash-attributes to be more specific: capture-logstash-marker-attributes

to avoid confusion with the new capture-logstash-structured-arguments

@trask trask force-pushed the logstash-structured-args branch 4 times, most recently from f52feeb to e8a2d89 Compare October 12, 2025 20:37
},
{
"name": "otel.instrumentation.logback-appender.experimental.capture-logstash-attributes",
"name": "otel.instrumentation.logback-appender.experimental.capture-logstash-marker-attributes",
Copy link
Member Author

Choose a reason for hiding this comment

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

@zeitlinger is it ok to remove deprecated property right away here?

@trask trask force-pushed the logstash-structured-args branch from e8a2d89 to 23c2f6d Compare October 12, 2025 20:40
* any time.
*/
@SuppressWarnings("unused") // keep around for next time even if not currently used
public final class DeprecatedConfigProperties {
Copy link
Member Author

@trask trask Oct 12, 2025

Choose a reason for hiding this comment

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

modified version of class from javaagent-extension-api

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask force-pushed the logstash-structured-args branch from 796011a to b69a47d Compare October 12, 2025 20:47
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LogstashMarkerTest {
Copy link
Member Author

Choose a reason for hiding this comment

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

these tests are just move here from Slf4j2Test.java

.hasInstrumentationScope(instrumentationScopeInfo)
.hasBody("log message 1")
.hasTotalAttributeCount(codeAttributesLogCount()));
}
Copy link
Member Author

Choose a reason for hiding this comment

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

these tests are just moved to LogstachMarkerTest.java

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LogstashStructuredArgsTest {
Copy link
Member Author

Choose a reason for hiding this comment

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

new tests for the new feature

}
implementation("net.logstash.logback:logstash-logback-encoder") {
version {
strictly("6.6")
Copy link
Member Author

Choose a reason for hiding this comment

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

StructuredArguments was introduced after LogstashMarker which is why separate test suite here

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask force-pushed the logstash-structured-args branch from 1b42518 to 4b770a0 Compare October 12, 2025 21:38
@trask trask marked this pull request as ready for review October 12, 2025 22:27
@trask trask requested a review from a team as a code owner October 12, 2025 22:27
| `otel.instrumentation.logback-appender.experimental.capture-logger-context-attributes` | Boolean | `false` | Enable the capture of Logback logger context properties as attributes. |
| `otel.instrumentation.logback-appender.experimental.capture-arguments` | Boolean | `false` | Enable the capture of Logback logger arguments. |
| `otel.instrumentation.logback-appender.experimental.capture-logstash-attributes` | Boolean | `false` | Enable the capture of Logstash attributes, supported are those added to logs via `Markers.append()`, `Markers.appendEntries()`, `Markers.appendArray()` and `Markers.appendRaw()` methods. |
| `otel.instrumentation.logback-appender.experimental.capture-logstash-marker-attributes` | Boolean | `false` | Enable the capture of Logstash markers, supported are those added to logs via `Markers.append()`, `Markers.appendEntries()`, `Markers.appendArray()` and `Markers.appendRaw()` methods. |
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this file needs a reformat

| `captureLoggerContext` | Boolean | `false` | Enable the capture of Logback logger context properties as attributes. |
| `captureArguments` | Boolean | `false` | Enable the capture of Logback logger arguments. |
| `captureLogstashAttributes` | Boolean | `false` | Enable the capture of Logstash attributes, supported are those added to logs via `Markers.append()`, `Markers.appendEntries()`, `Markers.appendArray()` and `Markers.appendRaw()` methods. |
| `captureLogstashMarkerAttributes` | Boolean | `false` | Enable the capture of Logstash markers, supported are those added to logs via `Markers.append()`, `Markers.appendEntries()`, `Markers.appendArray()` and `Markers.appendRaw()` methods. |
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this one also needs a reformat

trask and others added 3 commits October 13, 2025 12:22
…ashMarkerTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogstashMarkerTest.java

Co-authored-by: Lauri Tulmin <[email protected]>
…ashStructuredArgsTest/java/io/opentelemetry/instrumentation/logback/appender/v1_0/LogstashStructuredArgsTest.java

Co-authored-by: Lauri Tulmin <[email protected]>
@trask trask force-pushed the logstash-structured-args branch from 7c49c5a to aad7ecb Compare October 13, 2025 19:26
@trask trask added this to the v2.21.0 milestone Oct 13, 2025
@trask trask merged commit dbe4196 into open-telemetry:main Oct 13, 2025
83 checks passed
@trask trask deleted the logstash-structured-args branch October 13, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecation test native This label can be applied to PRs to trigger them to run native tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Capture Logback StructuredArguments (v()/keyValue()) as LogRecord Attributes

2 participants