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-42458 set_transaction_name empty name case #162

Merged
merged 5 commits into from
Jun 6, 2023

Conversation

tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Jun 2, 2023

If customers call set_transaction_name("") with an empty string, there will now be a warning log and the method will return False. I've commented on the hijacked spec doc to confirm, and Java library is doing this too: https://github.com/appoptics/solarwinds-apm-java/pull/105/files

Before this change, Python relies on falsiness to not use empty string nor None as transaction name: https://github.com/solarwindscloud/solarwinds-apm-python/blob/main/solarwinds_apm/inbound_metrics_processor.py#L171 So what's exported to SWO doesn't change with this PR.

I've also adjusted log severity of other parts of the method, though I'm not sure what's best with the return of True vs False and if it's a simple "ignore" or pretty-bad-can't-find-InboundMetricsSpanProcessor.

Any suggestions welcome 😺

@tammy-baylis-swi tammy-baylis-swi marked this pull request as ready for review June 2, 2023 23:19
@tammy-baylis-swi tammy-baylis-swi requested a review from a team June 2, 2023 23:19
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.

Thanks @tammy-baylis-swi, and really appreciate the enhanced docstring :). I left my opinion on the log levels--in general we try to use error level very sparingly, only for cases where library functionality is impacted/unrecoverable.

if isinstance(get_tracer_provider(), NoOpTracerProvider):
logger.debug(
logger.warning(
Copy link
Contributor

Choose a reason for hiding this comment

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

Since there would already be a log message on startup if the agent is disabled, and it could actually be an intentional disabling, I think this message at the debug level makes more sense--esp. since in this scenario there would never be any trace data (thus transaction names) exported anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call! Don't need too much notification. Addressed in 32bf45e

@@ -68,7 +75,7 @@ def set_transaction_name(custom_name: str) -> bool:
entry_trace_id = baggage.get_baggage(INTL_SWO_CURRENT_TRACE_ID)
entry_span_id = baggage.get_baggage(INTL_SWO_CURRENT_SPAN_ID)
if not entry_trace_id or not entry_span_id:
logger.debug(
logger.error(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think warning might be more appropriate, similar to if the customer passed in an invalid transaction name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, make sense! Addressed in 32bf45e

@tammy-baylis-swi tammy-baylis-swi requested a review from cheempz June 5, 2023 17:43
@tammy-baylis-swi
Copy link
Contributor Author

Thank you @cheempz ! Please have another look when you have a moment.

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 @tammy-baylis-swi!

@tammy-baylis-swi tammy-baylis-swi merged commit 9337c8a into main Jun 6, 2023
@tammy-baylis-swi tammy-baylis-swi deleted the NH-42458-set-transaction-name-empty-name branch June 6, 2023 17:20
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