Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

How to start trace with custom trace-id and parent-id?

Aperta
#9,155 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
java, kafka

Direzione di ricerca

Inizia dagli entry point Java mostrati nell’esempio—GlobalTracer.get(), buildSpan(...).asChildOf() e CustomSpanContext—e confronta il modo in cui gli header Kafka memorizzati vengono utilizzati nel container outbox. Determina quale API supportata, se ce n’è una, accetta il trace-id e il parent-id mantenendo il distributed tracing. È completato quando uno span da publishFromOutbox appare nella trace esistente con log correlati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

type: feature request
Library Name

micronaut

Library Version(s)

dd-trace:1.50.1

Describe the feature you'd like

Hi,

We are storing outbox events for Kafka in the database with current span context headers:

headers={
x-datadog-parent-id=1425649086485655485,
x-datadog-sampling-priority=1,
tracestate=dd=s:1;
o:rum;
p:13c8ec4a6e566fbd,
x-datadog-origin=rum,
traceparent=00-000000000000000024fefac4c68ae928-13c8ec4a6e566fbd-01,
x-datadog-trace-id=2665843752501438760
}

and when these outbox events are picked (by a different container), we want to trace that operation but attach those spans to an already existing trace so that we can have support for:

  • distributed tracing
  • distributed logs
Is your feature request related to a problem?

No response

Describe alternatives you've considered

This is what we tried

  void publishFromOutbox(final Outbox outboxEvent) {
    final var tracer = GlobalTracer.get();
    final Span span = tracer.buildSpan(JOBS)
      .withTag(DDTags.RESOURCE_NAME, OUTBOX_SCHEDULER_PUBLISH)
      .ignoreActiveSpan()
      .asChildOf(new CustomSpanContext(
        outboxEvent.headers().get(X_DATADOG_TRACE_ID), outboxEvent.headers().get(X_DATADOG_PARENT_ID)))
      .start();
    tracer.activateSpan(span);
    publish(outboxEvent);
    tracer.activeSpan().finish();
  }

but we can see this doesn't work. Trace is not created or attached to any existing trace.

How can we accomplish starting trace with custom trace-id and parent-id? For PHP services we are using this handy method that you provide

    /**
     * Apply the distributed tracing information on the current and future spans. That API can be called if there is no
     * other currently active span.
     *
     * The distributed tracing context can be reset by calling 'set_distributed_tracing_context("0", "0")'
     *
     * @param string $traceId The unique integer (128-bit unsigned) ID of the trace containing this span
     * @param string $parentId The span integer ID of the parent span
     * @param string|null $origin The distributed tracing origin
     * @param array|string|null $propagated_tags If provided, propagated tags from the root span will be cleared and
     * replaced by the given tags and applied to existing spans
     * @return bool 'true' if the distributed tracing context was properly set, else 'false' if an error occurred
     */
    function set_distributed_tracing_context(
        string $traceId,
        string $parentId,
        ?string $origin = null,
        array|string|null $propagated_tags = null
    ): bool {}
Additional context

No response

Lingua principale
Java
Stelle
737
Fork
361
Merge medio
3g 20h
PR unite (30g)
173

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DataDog/dd-trace-java

Tutte le issue di DataDog/dd-trace-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.