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

REL-1526 - Fix context propagation for async communication #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 32 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,36 @@
[![Build Status][ci-img]][ci] [![Coverage Status][cov-img]][cov] [![Released Version][maven-img]][maven] [![Apache-2.0 license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
# Purpose

Check notice on line 1 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L1

Expected: 1; Actual: 0; Below

Check notice on line 1 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L1

[final-newline] Missing newline character at end of file

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Expected: 1; Actual: 0; Below

Suggested change
# Purpose
# Purpose

This is overridden version of [opentracing-contrib/java-rabbitmq-client](https://github.com/opentracing-contrib/java-rabbitmq-client) that fixes library problems.
Library is deprecated and not maintained anymore.
It should replaced with OpenTelemetry.

# OpenTracing RabbitMQ Client Instrumentation
OpenTracing instrumentation for RabbitMQ Client.
In the meantime, all fixes for SmartRecruiters will reside here.

## Installation

pom.xml
# Publishing changes

Check notice on line 8 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L8

Expected: 1; Actual: 0; Below

Check notice on line 8 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L8

Multiple top-level headings in the same document

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Expected: 1; Actual: 0; Below

Suggested change
# Publishing changes
# Publishing changes

Choose a reason for hiding this comment

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

1. Adjust version in `pom.xml`

Check notice on line 9 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L9

Lists should be surrounded by blank lines

Check notice on line 9 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L9

[list-item-indent] Incorrect list-item indent: add 1 space

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Lists should be surrounded by blank lines

Suggested change
1. Adjust version in `pom.xml`
1. Adjust version in `pom.xml`

Choose a reason for hiding this comment

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

2. Replace `{SR Nexus URL}` in `pom.xml` with URL to nexus

Check notice on line 10 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L10

[list-item-indent] Incorrect list-item indent: add 1 space

Choose a reason for hiding this comment

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

3. Create settings for maven in `~/.m2/settings.xml

Check notice on line 11 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L11

Lists should be surrounded by blank lines

Check notice on line 11 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L11

[list-item-indent] Incorrect list-item indent: add 1 space

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Lists should be surrounded by blank lines

Suggested change
3. Create settings for maven in `~/.m2/settings.xml
3. Create settings for maven in `~/.m2/settings.xml

Choose a reason for hiding this comment

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

```xml
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-rabbitmq-client</artifactId>
<version>VERSION</version>
</dependency>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers>
<server>
<id>sr-nexus</id>
<username>*********************************************</username>
<password>*******************************</password>
</server>
</servers>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
```

## Usage


```java
// Instantiate tracer
Tracer tracer = ...

// Optionally register tracer with GlobalTracer
GlobalTracer.register(tracer);

// Decorate RabbitMQ Channel with TracingChannel
TracingChannel tracingChannel = new TracingChannel(channel, tracer);

// Send
tracingChannel.basicPublish(...);

// Get
GetResponse response = tracingChannel.basicGet(queueName, false);

// Consume
tracingChannel.basicConsume(...);

// Factory
ConnectionFactory factory = new TracingConnectionFactory(tracer);
Connection connection = factory.newConnection();

```

## License

[Apache 2.0 License](./LICENSE).

[ci-img]: https://travis-ci.org/opentracing-contrib/java-rabbitmq-client.svg?branch=master
[ci]: https://travis-ci.org/opentracing-contrib/java-rabbitmq-client
[cov-img]: https://coveralls.io/repos/github/opentracing-contrib/java-rabbitmq-client/badge.svg?branch=master
[cov]: https://coveralls.io/github/opentracing-contrib/java-rabbitmq-client?branch=master
[maven-img]: https://img.shields.io/maven-central/v/io.opentracing.contrib/opentracing-rabbitmq-client.svg
[maven]: http://search.maven.org/#search%7Cga%7C1%7Copentracing-rabbitmq-client
4. Run `mvn clean install`

Check notice on line 35 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L35

Expected: 1; Actual: 4; Style: 1/2/3

Check notice on line 35 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L35

Lists should be surrounded by blank lines

Check notice on line 35 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L35

[list-item-indent] Incorrect list-item indent: add 1 space

Choose a reason for hiding this comment

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

Codacy has a fix for the issue: Lists should be surrounded by blank lines

Suggested change
4. Run `mvn clean install`
4. Run `mvn clean install`

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Codacy found an issue: Expected: 1; Actual: 4; Style: 1/2/3

5. Run `mvn source:jar deploy`

Check notice on line 36 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L36

Expected: 2; Actual: 5; Style: 1/2/3

Check notice on line 36 in README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

README.md#L36

[list-item-indent] Incorrect list-item indent: add 1 space

Choose a reason for hiding this comment

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

Codacy found an issue: Expected: 2; Actual: 5; Style: 1/2/3

Choose a reason for hiding this comment

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

11 changes: 3 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-rabbitmq-client</artifactId>
<version>0.1.12-SNAPSHOT</version>
<version>0.1.12-SR2</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>OpenTracing Instrumentation for RabbitMQ Client</description>
Expand Down Expand Up @@ -192,14 +192,9 @@

<distributionManagement>
<repository>
<id>bintray</id>
<url>https://api.bintray.com/maven/opentracing/maven/opentracing-rabbitmq-client/;publish=1
</url>
<id>sr-nexus</id>
<url>{SR Nexus URL}/repository/releases/</url>
</repository>
<snapshotRepository>
<id>jfrog-snapshots</id>
<url>http://oss.jfrog.org/artifactory/oss-snapshot-local</url>
</snapshotRepository>
</distributionManagement>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,33 @@
*/
package io.opentracing.contrib.rabbitmq;

import io.opentracing.propagation.TextMap;
import java.util.Iterator;
import java.util.Map;

import io.opentracing.propagation.TextMap;


public class HeadersMapInjectAdapter implements TextMap {

private final Map<String, Object> headers;
private final Map<String, Object> headers;

public HeadersMapInjectAdapter(Map<String, Object> headers) {
this.headers = headers;
}
public HeadersMapInjectAdapter(Map<String, Object> headers) {
this.headers = headers;
}

@Override
public Iterator<Map.Entry<String, String>> iterator() {
throw new UnsupportedOperationException("iterator should never be used with Tracer.inject()");
}
@Override
public Iterator<Map.Entry<String, String>> iterator() {
throw new UnsupportedOperationException("iterator should never be used with Tracer.inject()");
}

@Override
public void put(String key, String value) {
headers.put(key, value);
}
}
@Override
public void put(String key, String value) {
// Version: opentracing-rabbitmq-client:0.1.12-SR2
try {
headers.put(key, value);
} catch (UnsupportedOperationException e) {
// Swallow the exception, headers are read only
// This code is most likely run on consumer side where rabbit mq headers are read only
}
}
}