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

Links API proposal #204

Merged
merged 3 commits into from Mar 21, 2023
Merged

Links API proposal #204

merged 3 commits into from Mar 21, 2023

Conversation

marcingrzejszczak
Copy link
Contributor

fixes gh-182

@marcingrzejszczak marcingrzejszczak added the enhancement New feature or request label Mar 16, 2023
@@ -160,4 +162,33 @@ default String getLocalIp() {
*/
FinishedSpan setRemoteServiceName(String remoteServiceName);

/**
* @return links
Copy link

Choose a reason for hiding this comment

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

20% of developers fix this issue

MissingSummary: A summary line is required on public/protected Javadocs.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

public Span.Builder addLink(TraceContext traceContext) {
brave.propagation.TraceContext braveContext = BraveTraceContext.toBrave(traceContext);
long nextId = LinkUtils.nextIndex(this.tags);
this.tags.put(LinkUtils.spanIdKey(nextId), braveContext.spanIdString());
Copy link

Choose a reason for hiding this comment

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

16% of developers fix this issue

NULL_DEREFERENCE: object braveContext last assigned on line 155 could be null and is dereferenced at line 157.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]


private static final String LINKS_PREFIX = "links[";

private static final String TRACE_ID = "links[%s].traceId";
Copy link

Choose a reason for hiding this comment

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

16% of developers fix this issue

InlineFormatString: Prefer to create format strings inline, instead of extracting them to a single-use constant

❗❗ 2 similar findings have been found in this PR

🔎 Expand here to view all instances of this finding
File Path Line Number
micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/LinkUtils.java 38
micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/LinkUtils.java 36

Visit the Lift Web Console to find more details in your report.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@sonatype-lift
Copy link

sonatype-lift bot commented Mar 16, 2023

🛠 Lift Auto-fix

Some of the Lift findings in this PR can be automatically fixed. You can download and apply these changes in your local project directory of your branch to review the suggestions before committing.1

# Download the patch
curl https://lift.sonatype.com/api/patch/github.com/micrometer-metrics/tracing/204.diff -o lift-autofixes.diff

# Apply the patch with git
git apply lift-autofixes.diff

# Review the changes
git diff

Want it all in a single command? Open a terminal in your project's directory and copy and paste the following command:

curl https://lift.sonatype.com/api/patch/github.com/micrometer-metrics/tracing/204.diff | git apply

Once you're satisfied, commit and push your changes in your project.

Footnotes

  1. You can preview the patch by opening the patch URL in the browser.

* @return this
* @since 1.1.0
*/
default Builder addLink(TraceContext traceContext) {
Copy link
Member

Choose a reason for hiding this comment

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

If links are used to link Spans, should not this receive a Span instead of the context? Internally it can fetch the context from the Span but the user could do:

span.addLink(otherSpan);

instead of

span.addLink(otherSpan.context());

WDYT?

}

@Override
public Map<TraceContext, Map<String, String>> getLinks() {
Copy link
Member

Choose a reason for hiding this comment

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

Should not we use a Link interface everywhere in our public APIs and convert Links to Map at the end when we need it?

* Creates a new instance of {@link SimpleLink}.
* @param traceContext trace context
*/
public SimpleLink(TraceContext traceContext) {
Copy link
Member

Choose a reason for hiding this comment

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

Should not we use Span in the parameter instead?

- created Link class instead of working with maps of contexts and tags
- Link now can accept different parameters (span, trace context, tags)
- adopted all methods to work with lists of links instead of maps
- test assertions got simplified thanks to this
public Span.Builder addLink(Link link) {
brave.propagation.TraceContext braveContext = BraveTraceContext.toBrave(link.getTraceContext());
long nextId = LinkUtils.nextIndex(this.tags);
this.tags.put(LinkUtils.spanIdKey(nextId), braveContext.spanIdString());
Copy link

Choose a reason for hiding this comment

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

16% of developers fix this issue

NULL_DEREFERENCE: object braveContext last assigned on line 156 could be null and is dereferenced at line 158.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@elisabeteaprcd
Copy link

Looks good to me. Thank you.

@marcingrzejszczak marcingrzejszczak merged commit 3fe98ee into main Mar 21, 2023
2 checks passed
@jonatan-ivanov jonatan-ivanov deleted the links branch March 21, 2023 20:43
@jonatan-ivanov jonatan-ivanov added this to the 1.1.0-M3 milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suport for create span with links
3 participants