Able to see traces with Java, but no trace with Scala (same code)
Les mainteneurs répondent en général sous 3 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
- Type d'issue
- Bug
- Clarté
- À clarifier
- Activité
- À l'abandon
- Domaine
- observability, stream-processing
Piste de recherche
Commencez par le point d’entrée Issue.call et comparez les extraits Java et Scala, notamment les valeurs de trace-parent, la configuration du span et la configuration de l’exporter. Reproduisez le problème avec OpenTelemetry 1.49.0 et vérifiez si le chemin Scala exporte un span qui apparaît dans les backends de tracing listés ; le travail est terminé lorsque le chemin de streaming Scala produit une trace visible.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Describe the bug
A clear and concise description of what the bug is.
=> I am able to send traces with below Java code, I can even see the traces in our tracing back-ends.
However, what seems to be the same code (can be discussed) in Scala will yield no trace at all.
Both are using the same OpenTelemetry API, SDK and exporter OTLP
Steps to reproduce
If possible, provide a recipe for reproducing the error.
Here is the java code.
I hope it is as minimal and as descriptive as possible.
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.trace.*;
import io.opentelemetry.context.Context;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
public class AAA {
public String call(String traceParent) throws Exception {
//String traceParent = "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"; //for testing
OtlpGrpcSpanExporter spanExporter = OtlpGrpcSpanExporter.builder()
.setEndpoint("https://tempo-prod-04-prod-us-east-0.grafana.net:443")
.addHeader("Authorization", "Basic ODEwNzcxOmdsY19leUp2SWpvaU1[...]luQnliMlF0ZFhNdFpXRnpkQzB3SW4xOQ==")
.build();
Resource myResource = Resource.create(Attributes.of(AttributeKey.stringKey("service.name"), "javaservice"));
SdkTracerProvider tracerProvider = SdkTracerProvider.builder().addSpanProcessor(SimpleSpanProcessor.create(spanExporter)).build();
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder().setTracerProvider(tracerProvider).build();
String[] traceSplit = traceParent.split("-");
SpanContext remoteContext = SpanContext.createFromRemoteParent(traceSplit[1], traceSplit[2], TraceFlags.getSampled(), TraceState.getDefault());
Tracer tracer = openTelemetry.getTracer("from-java");
SpanBuilder sb= tracer.spanBuilder("java-name").setSpanKind(SpanKind.CONSUMER);
sb.setParent(Context.current().with(Span.wrap(remoteContext)));
sb.setAttribute("testattributejava", "testattributejava");
Span serverSpan = sb.startSpan();
try {
Thread.sleep(100); // mock our operation
System.out.println("This is an example operation." + traceSplit[1] + traceSplit[2] + serverSpan + serverSpan.isRecording() + remoteContext);
return serverSpan + " " + remoteContext;
} finally {
serverSpan.end();
}
}
}
And here is the Scala counterpart, not working.
import io.opentelemetry.api.common.Attributes
import io.opentelemetry.api.trace._
import io.opentelemetry.context.Context
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter
import io.opentelemetry.sdk.OpenTelemetrySdk
import io.opentelemetry.sdk.resources.Resource
import io.opentelemetry.sdk.trace.SdkTracerProvider
import io.opentelemetry.sdk.trace.`export`.SimpleSpanProcessor
import org.apache.spark.sql.Row
class Issue {
def call(traceParent: (String, String)): String = {
val spanExporter = OtlpGrpcSpanExporter.builder().setEndpoint("https://tempo-prod-04-prod-us-east-0.grafana.net:443").addHeader("Authorization", "Basic ODEwNzcxOmdsY19leUp2SWpvaU1UQTFOVFV4T1NJc0ltNGlPaUp6ZEdGamF5MDROVGcyTnpJdG[...]npkQzB3SW4xOQ==").build()
val myResource = Resource.create(Attributes.builder().put("service.name", "scalaservice").build())
val tracerProvider = SdkTracerProvider.builder().addSpanProcessor(SimpleSpanProcessor.create(spanExporter)).build()
val openTelemetry = OpenTelemetrySdk.builder().setTracerProvider(tracerProvider).build()
val remoteContext = SpanContext.createFromRemoteParent(traceParent._1, traceParent._2, TraceFlags.getSampled, TraceState.getDefault)
val tracer = openTelemetry.getTracer("from-scala")
val spanBuilder = tracer.spanBuilder("scala-name").setSpanKind(SpanKind.CONSUMER)
spanBuilder.setParent(Context.current().`with`(Span.wrap(remoteContext)))
spanBuilder.setAttribute("testAttributeScala1", "testAttributeScala2")
val mySpan = spanBuilder.startSpan()
try {
Thread.sleep(400) //mock our work
println(traceParent._1 + traceParent._2 + mySpan.toString + mySpan.isRecording + remoteContext)
mySpan.toString
} finally {
mySpan.end()
}
}
What did you expect to see?
A clear and concise description of what you expected to see.
=> For both Java and Scala, I was hoping to see the trace in our tracing back ends. (Tested with Tempo, Lightstep, Datadog, Elastic APM)
What did you see instead?
=> We see the trace being sent for the Java code, but not for the Scala counterpart.
What version and what artifacts are you using?
Artifacts: => opentelemetry-api, opentelemetry-sdk, 1.49.0 which exporters => OTLP
Version: => 1.49.0
How did you reference these artifacts? (excerpt from your build.gradle, pom.xml, etc)
=> Here is the part from SBT
"io.opentelemetry" % "opentelemetry-api" % "1.49.0",
"io.opentelemetry" % "opentelemetry-sdk" % "1.49.0",
"io.opentelemetry" % "opentelemetry-exporter-otlp" % "1.49.0",
Environment
Compiler: GraalVM 24, but we are not building native image
OS: The latest Noble
Additional context
Hello team,
This is my first issue in this repo.
If not anything else, just wanted to say thanks for the work.
Just wanted to reach out with a small issue.
We have a Java Spark Structured Streaming pipeline with kafka, where we would like to trace calls between Kafka producers (from different sources and languages) to our Spark job.
The above Java code is one step of the map reduce from Spark.
It is working. We can see traces in the different tracing backend.
However, a similar Spark Streaming job in Scala, with the similar map function (tracing) will not work.
No matter what, we cannot see the trace in any of the back end systems.
Could you please help on this issue?
Good day!
- Langage dominant
- Java
- Étoiles
- 2.5k
- Forks
- 1.1k
- Merge moyen
- 5 j 11 h
- PR mergées (30 j)
- 41
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de open-telemetry/opentelemetry-java
-
`B3PropagatorExtractorMultipleHeaders` allocates when headers are missingPeut-être pris @Eliot5566 l’a pris aujourd’hui. OuverteBug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
open-telemetry/opentelemetry-java#9065 ·
Les mainteneurs répondent en général sous 3 jours
-
[incubator] ComposableProbabilitySampler does not validate ratio rangePeut-être pris @eminfikret l’a pris il y a 4 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
open-telemetry/opentelemetry-java#9046 · 2 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 3 jours
-
PrometheusComponentProvider promotes all resource attributes when resource_constant_labels is empty ({})Peut-être pris @rooks-ns l’a pris il y a 19 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
open-telemetry/opentelemetry-java#9014 · 1 commentaire ·
Les mainteneurs répondent en général sous 3 jours
-
Fix `otel.sdk.log.created` counting semanticsPeut-être pris @anuraaga l’a pris il y a 112 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
open-telemetry/opentelemetry-java#8688 ·
Les mainteneurs répondent en général sous 3 jours
-
SdkSpanBuilder drops invalid parent TraceState when IdGenerator.generatesRandomTraceIds() is truePeut-être pris @Eliot5566 l’a pris aujourd’hui. OuverteBug SDK
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
open-telemetry/opentelemetry-java#9062 · 1 commentaire ·
Les mainteneurs répondent en général sous 3 jours
Toutes les issues de open-telemetry/opentelemetry-java
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
micronaut-projects/micronaut-core#14585 ·
Les mainteneurs répondent en général sous 1 jour
-
Mend: dependency security vulnerability untriaged
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
opensearch-project/cross-cluster-replication#1805 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 3 jours
-
feature request needs triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 66/100
TeamNewPipe/NewPipe#14083 ·
Les mainteneurs répondent en général sous 1 jour
-
NeoForge 安装任务的子任务描述有误Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 68/100
PCL-Community/PCL-CE#3907 ·
Les mainteneurs répondent en général sous 1 jour