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

Support long, double and boolean for tags #234 #235

Conversation

nikoncode
Copy link

@nikoncode nikoncode commented Apr 18, 2023

This is only draft.

Brave doesn't support other types to be set as tags, so primitives will be converted into string (this is safe).

Will make it fancy, after some preliminary idea approval

Copy link
Contributor

@marcingrzejszczak marcingrzejszczak left a comment

Choose a reason for hiding this comment

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

That's a pretty straightforward change. Let's go with that!

@@ -71,6 +71,21 @@ public Span tag(String key, String value) {
return this;
}

@Override
public Span tag(String key, long value) {
return this;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the default could be just converting this to strings. return tag(key, String.valueOf(value)). WDYT?

Copy link
Author

Choose a reason for hiding this comment

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

This is good suggestion, I applied it for all Brave* classes because brave really don't support this. For noops I prefer to use shortest possible form

@Override
public Span tag(String key, long value) {
this.delegate.setAttribute(key, value);
return new OtelSpan(this.delegate);
Copy link
Contributor

Choose a reason for hiding this comment

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

Come to think of it I wonder why wasn't I consistent here in comparison to other tracers. I'm creating a new OtelSpan back instead of returning this. 🤔

Copy link
Author

Choose a reason for hiding this comment

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

I see this patter in multiple places, I don't think that it's really required, but hard to be sure.

@nikoncode nikoncode force-pushed the wip-234-other-types-for-tags branch from 3decdd8 to a88cd54 Compare April 19, 2023 13:38
@marcingrzejszczak
Copy link
Contributor

You need to run ./gradlew format to fix formatting issues

@nikoncode nikoncode force-pushed the wip-234-other-types-for-tags branch 3 times, most recently from 58ce909 to 6adb7d7 Compare April 19, 2023 13:47
* @param value tag value
* @return this span
*/
Span tag(String key, long value);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add default here and provide a default that converts to String cause otherwise we're making a breaking change

* @param value tag value
* @return this
*/
Builder tag(String key, long value);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be default and delegate to the String version. Otherwise, this is a breaking change

* @param value tag value
* @return this, for chaining
*/
SpanCustomizer tag(String key, long value);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be default and delegate to the String version. Otherwise, this is a breaking change

@nikoncode nikoncode force-pushed the wip-234-other-types-for-tags branch from 6adb7d7 to 8fc2f0d Compare April 19, 2023 13:52
@nikoncode
Copy link
Author

@marcingrzejszczak I see that the whole library built to support only string, string pairs.

My ultimate goal is to get support of these types from Convention layer, but I don't want to bloat this PR.

I want to ask your opinion about:

  • io.micrometer.tracing.Link - now supports only Map<String, String> as tags,
  • io.micrometer.tracing.otel.bridge.OtelFinishedSpan - his fromOtel and toOtel methods will erase attribute types (convert values to string), but it doesn't look like real problem because I don't use io.micrometer.tracing.otel.bridge.CompositeSpanExporter

@nikoncode nikoncode force-pushed the wip-234-other-types-for-tags branch from 8fc2f0d to 0faf66f Compare April 19, 2023 14:29
@marcingrzejszczak marcingrzejszczak merged commit 0faf66f into micrometer-metrics:main Apr 20, 2023
1 check passed
@marcingrzejszczak
Copy link
Contributor

Done via #239

@jonatan-ivanov jonatan-ivanov changed the title wip: support long, double and boolean for tags #234 Support long, double and boolean for tags #234 Apr 20, 2023
@jonatan-ivanov jonatan-ivanov added the superseded Superseded by another issue, e.g. PR supersedes original issue label Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
superseded Superseded by another issue, e.g. PR supersedes original issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants