-
Notifications
You must be signed in to change notification settings - Fork 974
Add code attributes for log4j1 #13947
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
Open
oliver-zhang
wants to merge
23
commits into
open-telemetry:main
Choose a base branch
from
oliver-zhang:log4j-appender
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+83
−2
Open
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
442a9e0
Create sync.yml
oliver-zhang 9dc2d2f
Delete .github/workflows/sync.yml
oliver-zhang 1f7de02
Create sync.yml
oliver-zhang 8c704f8
Update sync.yml
oliver-zhang 356f36b
Update sync.yml
oliver-zhang 2994158
Merge branch 'open-telemetry:main' into main
oliver-zhang e56fd19
capture code attributes
oliver-zhang 41f3d84
delete sync.yml
oliver-zhang 1b9194f
add unit test
oliver-zhang 857cc02
add unit test
oliver-zhang ac48be6
Merge branch 'open-telemetry:main' into main
oliver-zhang fdc97a7
capture code attributes
oliver-zhang 51494f9
delete sync.yml
oliver-zhang ba2fd50
add unit test
oliver-zhang e865995
add unit test
oliver-zhang 7560a51
semconv stable code
oliver-zhang 8cc0987
Merge remote-tracking branch 'origin/log4j-appender' into log4j-appender
oliver-zhang fdb78cb
Merge branch 'main' into log4j-appender
oliver-zhang e6aa3ef
code review
oliver-zhang 21f7825
Merge remote-tracking branch 'origin/log4j-appender' into log4j-appender
oliver-zhang ab2efb8
Merge branch 'main' into log4j-appender
SylvainJuge d39a7eb
Merge branch 'main' into log4j-appender
trask 73d71a9
Merge branch 'main' into log4j-appender
oliver-zhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,16 @@ | |
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_MESSAGE; | ||
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_STACKTRACE; | ||
import static io.opentelemetry.semconv.ExceptionAttributes.EXCEPTION_TYPE; | ||
import static io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes.THREAD_ID; | ||
import static io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes.THREAD_NAME; | ||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
|
||
import io.opentelemetry.api.common.AttributeKey; | ||
import io.opentelemetry.api.logs.Severity; | ||
import io.opentelemetry.api.trace.SpanContext; | ||
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; | ||
import io.opentelemetry.instrumentation.testing.junit.code.SemconvCodeStabilityUtil; | ||
import io.opentelemetry.sdk.common.InstrumentationScopeInfo; | ||
import io.opentelemetry.sdk.logs.data.LogRecordData; | ||
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; | ||
|
@@ -38,6 +41,7 @@ | |
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
@SuppressWarnings("deprecation") // using deprecated semconv | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [minor] probably not needed anymore |
||
class Log4j1Test { | ||
|
||
static { | ||
|
@@ -67,6 +71,26 @@ private static Stream<Arguments> provideParameters() { | |
Arguments.of(true, true)); | ||
} | ||
|
||
@Test | ||
public void testCodeAttributes() { | ||
logger.info("this is test message"); | ||
List<AttributeAssertion> assertions = | ||
SemconvCodeStabilityUtil.codeFileAndLineAssertions("Log4j1Test.java"); | ||
assertions.addAll( | ||
SemconvCodeStabilityUtil.codeFunctionAssertions(Log4j1Test.class, "testCodeAttributes")); | ||
assertions.add(equalTo(THREAD_NAME, Thread.currentThread().getName())); | ||
assertions.add(equalTo(THREAD_ID, Thread.currentThread().getId())); | ||
|
||
testing.waitAndAssertLogRecords( | ||
logRecord -> | ||
logRecord | ||
.hasBody("this is test message") | ||
.hasInstrumentationScope(InstrumentationScopeInfo.builder("abc").build()) | ||
.hasSeverity(Severity.INFO) | ||
.hasSeverityText("INFO") | ||
.hasAttributesSatisfyingExactly(assertions)); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("provideParameters") | ||
public void test(boolean logException, boolean withParent) throws InterruptedException { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.