Skip to content
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

use upstream span stacktrace #239

Merged
merged 21 commits into from
Jun 7, 2024

Conversation

SylvainJuge
Copy link
Member

@SylvainJuge SylvainJuge commented May 2, 2024

Depends on PR to be merged + released to avoid relying on a local snapshot.

Final step of #172

Fixes #172

Checklist


# otel contrib
# updated from upstream agent with .ci/update-upstream.sh
opentelemetryContribAlpha = "1.34.0-alpha"
opentelemetryContribAlpha = "1.36.0-alpha"
Copy link
Member Author

Choose a reason for hiding this comment

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

[for reviewer] this is the first version where the contrib artifact is published

@@ -10,11 +10,11 @@ opentelemetryProto = "1.3.1-alpha"

# otel agent, we rely on the '*-alpha' and get the non-alpha dependencies transitively
# updated from upstream agent with .ci/update-upstream.sh
opentelemetryJavaagentAlpha = "2.3.0-alpha"
opentelemetryJavaagentAlpha = "2.4.0-alpha"
Copy link
Member Author

Choose a reason for hiding this comment

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

[for reviewer] updating to the latest version allows to also bump the latest SDK and align with the version used for contrib (maybe a further improvement would be to ensure that we don't have any mismatch).

@SylvainJuge SylvainJuge marked this pull request as ready for review May 29, 2024 13:45
@v1v v1v closed this May 30, 2024
@SylvainJuge SylvainJuge reopened this May 30, 2024
@jackshirazi jackshirazi reopened this May 30, 2024
@v1v v1v reopened this May 30, 2024
@v1v v1v closed this May 30, 2024
@SylvainJuge SylvainJuge reopened this May 31, 2024
@v1v v1v reopened this Jun 3, 2024
@@ -19,6 +19,7 @@
package co.elastic.otel.common;

import io.opentelemetry.api.trace.Span;
import io.opentelemetry.contrib.stacktrace.internal.MutableSpan;
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like replacing our MutableSpan from the distro with the copy from contrib is a bad idea:

  • In contrib, it is not available as a "public" type in a shared library, it is only an implementation detail of the span-stacktrace processor at the moment. As soon as the SDK allows span processors to modify spans on end, it will be gone, though we will still need it for the profiling correlation
  • It will make our live a lot harder maintaining extensions which won't be contributed (yet) upstream: We'll have to go to contrib, update the utility there, wait for a release and then only have the changes available

implementation(project(":resources"))
compileOnly("io.opentelemetry:opentelemetry-sdk")
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")
compileOnly(libs.bundles.semconv)

implementation(libs.contribSpanStacktrace)
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried excluding the transitive dependencies here instead of having to deal with it in the packaging code?
Seems cleaner to me:
https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps

Copy link
Member Author

Choose a reason for hiding this comment

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

Excluding transitive dependencies is close to use compileOnly instead of implementation: we compile against the API, but don't pull transitive dependencies when used.

The downside of this approach is that we then have to pull back needed dependencies again, for example with tests in this module require an extra testImplementation, and all the modules that depend on custom will have to do the same.

In a sense we need to have the ability to express "use this for implementation, but some transitive dependencies need to be filtered-out in packaging", and I don't know if we can do that with a custom dependency type.

Copy link
Contributor

Choose a reason for hiding this comment

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

The downside of this approach is that we then have to pull back needed dependencies again, for example with tests in this module require an extra testImplementation, and all the modules that depend on custom will have to do the same.

My understanding is that custom is not intended to be used by anyone but as an aggregator for building our agent-distro and the extension. both of those don't want to have the transitive dependencies.

For having to pull in the transitive dependencies for tests:
Simply adding testImplementation(libsContribSpanStacktrace) should pull in everything that has been excluded.
Alternatively, the commonly used OpenTelemetry modules for tests could be added to the test classpath via our testing-common module or an convention.

The main downside I see with manually removing the "bad" classes at packaging time is that it makes the build process depend on package names, which are neither public nor guaranteed to be stable (e.g. io/opentelemetry/extension/incubator/), making the build potentially prone to errors which are hard to find.

In my opinion the extension (e.g. span-stacktrace) should not be pulling in SDK dependencies via implementation anyway and use compileOnly , because it doesn't make just our live harder: It also makes the life harder for people who want to package those extensions as their own agent-extension fatJar, becuase they have to do the same exclusions.
For people who use the SDK directly I'd expect them to add the SDK to their classpath explicitly and not rely on transitive dependencies of an SDK-extension, which is kind of the wrong way around.

Copy link
Contributor

@JonasKunz JonasKunz Jun 6, 2024

Choose a reason for hiding this comment

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

This might also be something to discuss with the Otel Java SIG to see if they have any opinion on it. Looking at the contrib repo, most extensions there pull in the SDK + API as api(...), which has the downsides (and IMO no upsides) explained above.

common/build.gradle.kts Outdated Show resolved Hide resolved
@SylvainJuge SylvainJuge merged commit 428cff0 into elastic:main Jun 7, 2024
9 checks passed
@SylvainJuge SylvainJuge deleted the upstream-stacktrace branch June 7, 2024 09:39
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.

Contribute upstream: span stacktrace
4 participants