Skip to content

semconv stable code #13860

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
wants to merge 98 commits into
base: main
Choose a base branch
from

Conversation

SylvainJuge
Copy link
Contributor

@SylvainJuge SylvainJuge commented May 15, 2025

Semconv 1.33.0 brings stable definitions for code.* namespace, which includes the following changes:

  • code.namespace is removed
  • code.function is renamed to code.function.name and needs to include fully-qualified name of the class in addition to the function
  • code.lineno has been renamed code.line.number
  • code.column has been renamed code.column.number
  • code.filepath has been renamed code.file.path

This PR might have to be updated if merged after the update to semconv 1.33.0 is merged first. EDIT: updated after 1.34.0 semconv update

EDIT: the existing code.* semantic conventions are still produced, the stable ones are opt-in by setting the otel.semconv-stability.opt-in config option to include code (only stable) or code/dup (both stable + old).

@SylvainJuge SylvainJuge self-assigned this May 15, 2025
@github-actions github-actions bot added the test native This label can be applied to PRs to trigger them to run native tests label May 15, 2025
@laurit
Copy link
Contributor

laurit commented Jun 13, 2025

I have started working on making the switch to stable code semconv opt-in, but it requires a bit of tedious work that I haven't finished and is not ready to be pushed yet. I plan to add something similar to https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java#L39 but for the code semantic conventions.

You really don't need to do this, see #13860 (comment). You can convert tests to use the new assertion and enable the opt-in flag for all tests and run only selected tests with both new and old assertions to reduce the amount of work needed.

@SylvainJuge
Copy link
Contributor Author

It's not needed to be able to test everything but I would just sleep better if it is :-).

For example I found that the logging instrumentation would also benefit from being exhaustively tested like the annotations, if I understand it correctly just adding this to the gradle module file should allow to properly test it.

  val testStableSemconv by registering(Test::class) {
    jvmArgs("-Dotel.semconv-stability.opt-in=code")
  }

  val testBothSemconv by registering(Test::class) {
    jvmArgs("-Dotel.semconv-stability.opt-in=code/dup")
  }

  check {
    dependsOn(testStableSemconv)
    dependsOn(testBothSemconv)
  }

@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.

@SylvainJuge
Copy link
Contributor Author

I have updated this PR to only emit the deprecated semantic convention attributes by default.
Most instrumentation remain tested with unstable attributes, but some (like log appenders) are tested with both.

Using otel.semconv-stability.opt-in configuration allows to opt-in for the new stable semantic conventions with code or code/dup like we have for the database attributes, so it means we could merge this PR without altering the current behavior.

Then, we could then later remove the support for the unstable code attributes when preparing for the 3.0 release.

Is there already an issue that contains a list of breaking changes that we are planning to include in this major release to track progress on their respective implementations ? If no, please let me know and I can create one so we don't forget about this (and also the database semconv).

@trask
Copy link
Member

trask commented Jun 18, 2025

Is there already an issue that contains a list of breaking changes that we are planning to include in this major release to track progress on their respective implementations ?

https://github.com/open-telemetry/opentelemetry-java-instrumentation/milestone/41

@SylvainJuge
Copy link
Contributor Author

Is there already an issue that contains a list of breaking changes that we are planning to include in this major release to track progress on their respective implementations ?

https://github.com/open-telemetry/opentelemetry-java-instrumentation/milestone/41

Thanks, I've opened #14059.

@trask your review status is still "requested change", do you think there are still things to change before we could merge this ?

@trask trask dismissed their stale review June 18, 2025 16:22

stale

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

thanks!

Comment on lines +200 to +201

// using deprecated semconv
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// using deprecated semconv

@@ -191,6 +189,13 @@ void shouldHandleAsyncResponse(AsyncResponseTestKind testKind) throws Exception
assertThat(response.status().code()).isEqualTo(testKind.statusCode);
testKind.assertBody(response.contentUtf8());

List<AttributeAssertion> attributeAssertions =
codeFunctionInfixAssertions("test.JaxRsTestResource", "asyncOp");
Copy link
Member

Choose a reason for hiding this comment

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

I think?

Suggested change
codeFunctionInfixAssertions("test.JaxRsTestResource", "asyncOp");
codeFunctionSuffixAssertions("test.JaxRsTestResource", "asyncOp");

CODE_NAMESPACE,
"io.opentelemetry.instrumentation.jaxrs.v2_0.test.JaxRsTestResource"),
equalTo(CODE_FUNCTION, "jaxRs21Async"));
codeFunctionInfixAssertions(".JaxRsTestResource", "jaxRs21Async"));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
codeFunctionInfixAssertions(".JaxRsTestResource", "jaxRs21Async"));
codeFunctionSuffixAssertions(".JaxRsTestResource", "jaxRs21Async"));

@@ -319,7 +315,6 @@ protected SpanDataAssert assertHandlerSpan(
return span.hasName("JaxRsTestResource." + methodName)
.hasKind(SpanKind.INTERNAL)
.hasAttributesSatisfyingExactly(
satisfies(CODE_NAMESPACE, name -> name.endsWith("JaxRsTestResource")),
equalTo(CODE_FUNCTION, methodName));
codeFunctionInfixAssertions(".JaxRsTestResource", methodName));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
codeFunctionInfixAssertions(".JaxRsTestResource", methodName));
codeFunctionSuffixAssertions(".JaxRsTestResource", methodName));

Comment on lines -149 to +159
dependsOn(testing.suites)
dependsOn(testStableSemconv)
dependsOn(testBothSemconv)
Copy link
Member

Choose a reason for hiding this comment

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

I suspect we still need dependsOn(testing.suites)

@@ -57,8 +61,7 @@ public void captureSpanForCompletedCompletable() {
.hasKind(SpanKind.INTERNAL)
.hasNoParent()
.hasAttributesSatisfyingExactly(
satisfies(CODE_NAMESPACE, val -> val.endsWith(".TracedWithSpan")),
equalTo(CODE_FUNCTION, "completable"))));
codeFunctionSuffixAssertions("TracedWithSpan", "completable"))));
Copy link
Member

Choose a reason for hiding this comment

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

(and other places below, to stay consistent with other places)

Suggested change
codeFunctionSuffixAssertions("TracedWithSpan", "completable"))));
codeFunctionSuffixAssertions(".TracedWithSpan", "completable"))));

Comment on lines -176 to -182
v ->
assertThat(v)
.isEqualTo(
"org.springframework.security.web.firewall.FirewalledResponse"),
v ->
assertThat(v)
.isEqualTo("jakarta.servlet.http.HttpServletResponseWrapper"))),
Copy link
Member

Choose a reason for hiding this comment

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

interesting, just confirming these seem no longer needed?

satisfies(CODE_NAMESPACE, v -> v.endsWith(".BasicErrorController")),
equalTo(CODE_FUNCTION, "error")));
SemconvCodeStabilityUtil.codeFunctionSuffixAssertions(
"BasicErrorController", "error")));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"BasicErrorController", "error")));
".BasicErrorController", "error")));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants