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

Automatic tag table generation #1950

Closed
wants to merge 5 commits into from
Closed

Automatic tag table generation #1950

wants to merge 5 commits into from

Conversation

marcingrzejszczak
Copy link
Contributor

Without this change we don't even really know how many tags are created and what are their values.
With this change we want this information to be automatically rendered.

@marcingrzejszczak marcingrzejszczak added this to the 3.1.0 milestone May 14, 2021
@marcingrzejszczak marcingrzejszczak added this to In progress in 2021.0.0 via automation May 14, 2021

public void generate() {
Path path = this.projectRoot.toPath();
Pattern pattern = Pattern.compile(this.inclusionPattern);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think anyone would call this method multiple times on the same instance but what do you think about doing this in the ctor so that the class would look like:

private final File projectRoot;
private final Pattern pattern;
private final File outputDir;

Printing out the pattern in the next line should be ok, the toString of a Pattern is the string representation of it (inclusionPattern).

Files.write(output, stringBuilder.toString().getBytes());
}
catch (IOException e) {
throw new IllegalStateException(e);
Copy link
Member

Choose a reason for hiding this comment

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

I guess IOE is thrown from walkFileTree or from write, would not it be better to thrown an IllegalArgumentException (since the class is not in an illegal state) or throwing up the IOException?

/**
* @return allowed tag keys
*/
default TagKey[] getTagKeys() {
Copy link
Member

Choose a reason for hiding this comment

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

SpanEntry has

Collection<KeyValueEntry> tagKeys;
Collection<KeyValueEntry> events;

Shouldn't they be consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really cause SpanEntry is just a pojo that I'm using in the table. It's much easier to work with TagKey[] when enums in their .values() method return an array.

private static final Pattern SPECIAL_REGEX_CHARS = Pattern.compile("[{}()\\[\\].+*?^$\\\\|]");

private DocumentedSpanAssertions() {
throw new IllegalStateException("Can't instantiate utility class");
Copy link
Member

Choose a reason for hiding this comment

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

UnsupportedOperationException?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have those ISE everywhere else in such cases so I'll leave this one here too.

* @param tags array of tags
* @return a merged array of tags
*/
static TagKey[] merge(TagKey[]... tags) {
Copy link
Member

Choose a reason for hiding this comment

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

This is basically concat, right? If so I think I would rename it, also, if I understand this correctly, this should do the same in a simpler way:

return Arrays.stream(tags)
    .flatMap(Arrays::stream)
    .toArray(TagKey[]::new);

@marcingrzejszczak
Copy link
Contributor Author

Done via d2041cb

2021.0.0 automation moved this from In progress to Done May 18, 2021
@marcingrzejszczak marcingrzejszczak deleted the tags_table branch May 18, 2021 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
2021.0.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants