Skip to content

remove rx in entity span enricher resolution#439

Merged
kishansairam9 merged 37 commits intomainfrom
remove-rx
Nov 27, 2023
Merged

remove rx in entity span enricher resolution#439
kishansairam9 merged 37 commits intomainfrom
remove-rx

Conversation

@kishansairam9
Copy link
Copy Markdown

No description provided.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 16, 2023

Codecov Report

Attention: 32 lines in your changes are missing coverage. Please review.

Comparison is base (1aea26b) 79.93% compared to head (9cf9b34) 79.87%.

Files Patch % Lines
.../trace/reader/attributes/DefaultValueResolver.java 54.76% 15 Missing and 4 partials ⚠️
...cher/enrichment/clients/DefaultClientRegistry.java 0.00% 7 Missing ⚠️
.../accessor/entities/DefaultTraceEntityAccessor.java 92.10% 1 Missing and 2 partials ⚠️
...ace/accessor/entities/AttributeValueConverter.java 87.50% 1 Missing ⚠️
.../accessor/entities/TraceEntityAccessorBuilder.java 0.00% 1 Missing ⚠️
...reader/attributes/DefaultTraceAttributeReader.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #439      +/-   ##
============================================
- Coverage     79.93%   79.87%   -0.06%     
+ Complexity     1421     1413       -8     
============================================
  Files           128      127       -1     
  Lines          5566     5551      -15     
  Branches        509      515       +6     
============================================
- Hits           4449     4434      -15     
+ Misses          885      879       -6     
- Partials        232      238       +6     
Flag Coverage Δ
unit 79.87% <68.93%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kishansairam9 kishansairam9 marked this pull request as ready for review November 16, 2023 08:04
@kishansairam9 kishansairam9 requested a review from a team as a code owner November 16, 2023 08:04
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@kishansairam9 kishansairam9 changed the title remove rx in entity span enricher remove rx in entity span enricher resolution Nov 21, 2023
@kishansairam9
Copy link
Copy Markdown
Author

Blocked on fixing gradle issue on consuming attribute service which has ht bom. Looks like we need to migrate to gradle 8+ at least for fix if not complete bom, but if we're doing that might as well take care of bom

cc @mihirgt

@aaron-steinfeld
Copy link
Copy Markdown
Contributor

Blocked on fixing gradle issue on consuming attribute service which has ht bom. Looks like we need to migrate to gradle 8+ at least for fix if not complete bom, but if we're doing that might as well take care of bom

cc @mihirgt

Even if we want to the bom now, I'd do gradle 8 first anyway. That should only take a few min.

@github-actions

This comment has been minimized.

@kishansairam9 kishansairam9 changed the base branch from main to gradle November 22, 2023 15:29
@github-actions

This comment has been minimized.

Base automatically changed from gradle to main November 22, 2023 15:47
@github-actions

This comment has been minimized.

kishansairam9 added 2 commits November 22, 2023 22:01
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

private static final String ATTRIBUTE_SERVICE_HOST_KEY = "attribute.service.config.host";
private static final String ATTRIBUTE_SERVICE_PORT_KEY = "attribute.service.config.port";
private static final String ATTRIBUTE_SERVICE_CONFIG_KEY = "attribute.service.config";
private static final String ATTRIBUTE_SERVICE_HOST_KEY = ATTRIBUTE_SERVICE_CONFIG_KEY + ".host";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are host/port still used directly?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

They're used to build channel

this.attributeServiceChannel =
        this.buildChannel(
            config.getString(ATTRIBUTE_SERVICE_HOST_KEY),
            config.getInt(ATTRIBUTE_SERVICE_PORT_KEY));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah I thought that went away since you removed the getter and are passing in the raw config to the client. I wonder if passing in the registry would be better so it can read the channel config in the same way? Oh well, doesn't really matter - only thing I would suggest in this case would be to remove the instance variable for channel since now it's only used locally in creating the cached client.

Comment on lines +138 to +140
.filter(Optional::isPresent)
.findFirst()
.flatMap(Function.identity());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if I'm reading this correctly you've got a resolution that can return an optional and you're just trying to get the first value present, if it exists. If so, suggest:

Suggested change
.filter(Optional::isPresent)
.findFirst()
.flatMap(Function.identity());
.flatMap(Optional::stream)
.findFirst();

return new UnsupportedOperationException(String.format(message, args));
});
Stream<Optional<LiteralValue>> resolvedArguments =
arguments.stream().map(argument -> this.resolveProjection(valueSource, argument));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this is the only place we're using it and we don't support it return empty, why not just throw? You're eventually throwing anyway, you're just going through an extra level of indirection. If your goal is to completely avoid the throw, collect to list (use flatmap to optional stream) and just compare size before returning.

attributeMetadataList.stream()
.filter(this::isEntitySourced)
.map(attributeMetadata -> this.resolveAttribute(attributeMetadata, trace, span))
.filter(Optional::isPresent)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

optional stream again (there's always a better alternative for optional.get - even if it's just optional.orElseThrow - so always be wary when you find yourself pulled to it)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, wasn't aware of this neat trick with flatMap(Optional::stream)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

private static final String ATTRIBUTE_SERVICE_HOST_KEY = "attribute.service.config.host";
private static final String ATTRIBUTE_SERVICE_PORT_KEY = "attribute.service.config.port";
private static final String ATTRIBUTE_SERVICE_CONFIG_KEY = "attribute.service.config";
private static final String ATTRIBUTE_SERVICE_HOST_KEY = ATTRIBUTE_SERVICE_CONFIG_KEY + ".host";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah I thought that went away since you removed the getter and are passing in the raw config to the client. I wonder if passing in the registry would be better so it can read the channel config in the same way? Oh well, doesn't really matter - only thing I would suggest in this case would be to remove the instance variable for channel since now it's only used locally in creating the cached client.

@github-actions

This comment has been minimized.

@kishansairam9 kishansairam9 merged commit f33576d into main Nov 27, 2023
@kishansairam9 kishansairam9 deleted the remove-rx branch November 27, 2023 17:58
@github-actions
Copy link
Copy Markdown

Unit Test Results

  78 files  ±0    78 suites  ±0   1m 3s ⏱️ -5s
418 tests ±0  418 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f33576d. ± Comparison against base commit 1aea26b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants