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

NH-64716 First steps to integrate oboe settings API #223

Merged
merged 22 commits into from
Nov 17, 2023

Conversation

tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Nov 15, 2023

Summary

  1. Adds setting of ApmConfig.oboe_api as c-lib OboeAPI if is_lambda and agent_enabled.
  2. Else new no-op OboeAPI is used.
  3. Sampler uses the OboeAPI it's given for making decision, if is_lambda.
  4. Updates MeterManager to init 8 ObservableGauges for sampling metrics, using OboeAPI it's given.

Caveat

This works with c-lib 14 from staging i.e. 1034e69. If c-lib < 14 is used and is_lambda, agent will be disabled (see this message). Since I've reverted this commit, tox tests now fail. They last passed at 5069826 before the revert. Not sure if this is the correct way to proceed.

Manual testing

Contents can be packaged into a usable lambda layer that, with custom otel-collector layer, can instrument a function and export metrics (example) and traces (example).

Contents work the same as before for locally-instrumented app to export traces and metrics by apm-proto.

Please see doc for more details: https://swicloud.atlassian.net/wiki/spaces/NIT/pages/3881501305/2023-11-16+OboeAPI+integration

Housekeeping notes

I am adding Configurator tests separately in https://swicloud.atlassian.net/browse/NH-67051

Not sure what else I could do to make the MeterManager tests more meaningful.

Awaiting further input regarding use of sw.data.module

Still lots of stuff to do so I've added some Todos with tickies.


Please let me know what you think!

@tammy-baylis-swi tammy-baylis-swi changed the title NH-64716 Integrate oboe setting API NH-64716 Integrate oboe settings API Nov 15, 2023
import pytest

from solarwinds_apm import apm_config
import solarwinds_apm.apm_noop as NoopExtension

Check notice

Code scanning / CodeQL

Module is imported with 'import' and 'import from' Note test

Module 'solarwinds_apm.apm_noop' is imported with both 'import' and 'import from'.
tests/unit/test_apm_config/test_apm_config_get_extension.py Dismissed Show dismissed Hide dismissed
tests/unit/test_sampler/test_sampler.py Dismissed Show dismissed Hide dismissed
tests/unit/test_apm_meter_manager.py Fixed Show fixed Hide fixed
tests/unit/test_apm_meter_manager.py Fixed Show fixed Hide fixed
tests/unit/test_apm_meter_manager.py Fixed Show fixed Hide fixed
@tammy-baylis-swi tammy-baylis-swi force-pushed the NH-64716-integrate-oboe-api branch from c9f9a14 to 9aac496 Compare November 15, 2023 20:35
Comment on lines +197 to +205
logger.warning(
"Could not import API in lambda mode. Installed layer version not compatible. Tracing disabled: %s",
err,
)
return (
noop_extension,
noop_extension.Context,
noop_extension.OboeAPI,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what happens if APM Python is built using c-lib < 14.0.0

@@ -143,43 +140,8 @@ def calculate_liboboe_decision(
xtraceoptions: Optional[XTraceOptions] = None,
) -> dict:
"""Calculates oboe trace decision based on parent span context and APM config."""
tracestring = None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main changes of this function are (1) moving the if of the if-else for lambda to the top and (2) actually using OboeAPI now.

@tammy-baylis-swi tammy-baylis-swi changed the title NH-64716 Integrate oboe settings API NH-64716 First steps to integrate oboe settings API Nov 16, 2023
@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review November 17, 2023 00:11
@tammy-baylis-swi tammy-baylis-swi requested a review from a team as a code owner November 17, 2023 00:11
Copy link
Member

@raphael-theriault-swi raphael-theriault-swi left a comment

Choose a reason for hiding this comment

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

Looks good but I had a question

"",
0,
)
) = self.oboe_settings_api.getTracingDecision()

Choose a reason for hiding this comment

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

Do the arguments to this call not matter ? Actually curious if passing it the same thing as the non-lambda version vs passing it nothing makes any difference or if I should be doing it differently on my side of things

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good question. Tried it now and yes, this method does not explode if passed all the same non-lambda args (though it's a drop decision). Works if no args at all of course.

It does error out if I try other combinations of args:Wrong number or type of arguments for overloaded function

@tammy-baylis-swi tammy-baylis-swi merged commit 227dbdb into main Nov 17, 2023
3 of 11 checks passed
@tammy-baylis-swi tammy-baylis-swi deleted the NH-64716-integrate-oboe-api branch November 17, 2023 23:59
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.

2 participants