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-68421 Adjust service name, key usage when lambda #309

Merged
merged 4 commits into from
Feb 9, 2024

Conversation

tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Feb 8, 2024

Adjusts service name and service key requirements/usage when in lambda.

SW_APM_SERVICE_KEY was already not required for APM Python to be enabled in lambda, but if not provided was causing IndexError at _update_service_key_name. So added a condition in 5d7ba8b to only update key if not lambda.

The precedence of OTEL_SERVICE_NAME > AWS_LAMBDA_FUNCTION_NAME was already being respected by APM Python in lambda because of the otel-instrument wrapper. I added new helper _calculate_service_name_lambda anyway in case the wrapper fails or is not used in a lambda environment. Service name setting in lambda does not take agent_enabled into consideration like for APM proto service name setting (I'm pretty sure there's no use case beyond using function name?)

I manually tested by publishing a test layer (see ticket for ARN), applying to a function, and playing with different environment variables. Summary of outcome:

  1. No OTEL_SERVICE_NAME --> exports to service with function name
  2. No OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES does have a service name --> Resource ignored and exports to service with function name
  3. OTEL_SERVICE_NAME set --> exports to service of that awesome name

Please let me know what you think!

@tammy-baylis-swi tammy-baylis-swi force-pushed the NH-68421-lambda-wo-service-key branch from 04699f7 to 5d7ba8b Compare February 8, 2024 21:55
@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review February 9, 2024 00:44
@tammy-baylis-swi tammy-baylis-swi requested a review from a team as a code owner February 9, 2024 00:44
@xuan-cao-swi
Copy link

No OTEL_SERVICE_NAME --> exports to service with function name
No OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES does have a service name --> Resource ignored and exports to service with function name
OTEL_SERVICE_NAME set --> exports to service of that awesome name

No sure if it's my browser problem, when I open the link, I got into the right service, but can't see the trace (Welcome to Observability by SolarWinds lands on my page)

@tammy-baylis-swi
Copy link
Contributor Author

No sure if it's my browser problem, when I open the link, I got into the right service, but can't see the trace (Welcome to Observability by SolarWinds lands on my page)

Weird! I just checked and you are part of that Org on NA-02 data centre. So yeah possibly browser problem. Maybe clearing cookies/cache will help but also log you out of things 🙃

@tammy-baylis-swi tammy-baylis-swi merged commit 20ffb4e into main Feb 9, 2024
11 checks passed
@tammy-baylis-swi tammy-baylis-swi deleted the NH-68421-lambda-wo-service-key branch February 9, 2024 18:41
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