-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Link RabbitMQ receive span with the producer span (open-telemetry#6808)
Similar to open-telemetry#6804, but for RabbitMQ. Also changed the span kind of the receive span to `CONSUMER`, to match the spec.
- Loading branch information
Showing
4 changed files
with
156 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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 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
40 changes: 40 additions & 0 deletions
40
...java/io/opentelemetry/javaagent/instrumentation/rabbitmq/ReceiveRequestTextMapGetter.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.rabbitmq; | ||
|
||
import com.rabbitmq.client.AMQP; | ||
import com.rabbitmq.client.GetResponse; | ||
import io.opentelemetry.context.propagation.TextMapGetter; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import javax.annotation.Nullable; | ||
|
||
enum ReceiveRequestTextMapGetter implements TextMapGetter<ReceiveRequest> { | ||
INSTANCE; | ||
|
||
@Override | ||
public Iterable<String> keys(ReceiveRequest carrier) { | ||
return Optional.of(carrier) | ||
.map(ReceiveRequest::getResponse) | ||
.map(GetResponse::getProps) | ||
.map(AMQP.BasicProperties::getHeaders) | ||
.map(Map::keySet) | ||
.orElse(Collections.emptySet()); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String get(@Nullable ReceiveRequest carrier, String key) { | ||
return Optional.ofNullable(carrier) | ||
.map(ReceiveRequest::getResponse) | ||
.map(GetResponse::getProps) | ||
.map(AMQP.BasicProperties::getHeaders) | ||
.map(headers -> headers.get(key)) | ||
.map(Object::toString) | ||
.orElse(null); | ||
} | ||
} |
Oops, something went wrong.