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

Move oboe sampler and inbounds metrics to solarwinds-apm package #443

Merged
merged 8 commits into from
Sep 9, 2024

Conversation

raphael-theriault-swi
Copy link
Member

This moves the oboe-based sampler and inbound metrics span processors next to the rest of the new code. Most of their implementation is just lifted from the existing ones but it was simplified wherever possible by using some of the newly introduced code.

They are now pretty well tested (unlike previously) and I plan on including some more integration tests in future PRs along the reporter and exporters.

There were some improvements to the testing helpers too to make some of the tests less flaky.

@raphael-theriault-swi raphael-theriault-swi requested a review from a team as a code owner September 5, 2024 19:06
Comment on lines 184 to 190
beforeEach(async function () {
const CURRENT_RETRY = "currentRetry"
const currentRetry = this.currentTest?.[CURRENT_RETRY]()
if (currentRetry) {
await setTimeout(currentRetry * 1000)
}
})
Copy link
Member Author

Choose a reason for hiding this comment

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

Introduce a timeout between failed test retries (useful for sampler integration tests where we want to get a successful sampling decision but are hitting a rate limit)

Comment on lines +36 to 62
function withoutUndefinedProperties(
source: object,
deep: boolean,
copy = true,
): object {
const object = copy
? (Object.create(
Object.getPrototypeOf(source) as object | null,
Object.getOwnPropertyDescriptors(source),
) as object)
: source

for (const key of Reflect.ownKeys(object)) {
const descriptor = Reflect.getOwnPropertyDescriptor(object, key)!
if (
descriptor.enumerable &&
descriptor.configurable &&
descriptor.value === undefined
) {
Reflect.deleteProperty(copy, key)
Reflect.deleteProperty(object, key)
} else if (deep && isBasicObject(descriptor.value)) {
withoutUndefinedProperties(descriptor.value, true, false)
}
}

return copy
return object
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is pretty nasty code because it needs to be to deal with JS weirdness but essentially I just changed it to be recursive if desired.

Comment on lines +106 to +111
Assertion.overwriteMethod("equal", loosely)
Assertion.overwriteMethod("equals", loosely)
Assertion.overwriteChainableMethod("include", loosely, identity)
Assertion.overwriteChainableMethod("includes", loosely, identity)
Assertion.overwriteChainableMethod("contain", loosely, identity)
Assertion.overwriteChainableMethod("contains", loosely, identity)
Copy link
Member Author

Choose a reason for hiding this comment

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

Main change is supporting the loosely option for more types of tests

Copy link

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

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

Lgtm, yay more tests!!

Copy link
Contributor

@cheempz cheempz left a comment

Choose a reason for hiding this comment

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

Wow 💯 on the added tests, thanks @raphael-theriault-swi! I left a couple minor comments, feel free to address in follow-on PR.

BucketCapacity: 100,
BucketRate: 500,
"custom-foo": "custom-bar",
SWKeys: "sw",
Copy link
Contributor

Choose a reason for hiding this comment

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

Would the TriggeredTrace: true attribute also be set here and if so, can the test also check?

Also, pretty minor, the SampleRate and SampleSource ideally would be unset in the case of a triggered trace.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was not aware of the TriggeredTrace attribute, I think it was never implemented here woops. I'll add those changes, I also need to change some of the stable HTTP semconv handling because url.full isn't actually present on the spans

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to add the missing TriggeredTrace attribute and also SampleSource which was also missing. Also removed any logic related to local sample rate since that made implementing sample sources easier and it's not used anywhere anyway.

Copy link
Contributor

@cheempz cheempz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @raphael-theriault-swi!

@raphael-theriault-swi raphael-theriault-swi merged commit 630d9a0 into main Sep 9, 2024
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants