Skip to content

feat: add peer.service #337

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

Merged

Conversation

duncanista
Copy link
Contributor

@duncanista duncanista commented May 23, 2023

What does this PR do?

Adds the field peer.service to inferred spans.
The field is set to the current process environment variable DD_SERVICE.

Motivation

Add another dimension to services in APM.

Testing Guidelines

  • Integration tests with a service to check that inferred spans now have the tag.

Additional Notes

Refactoring in tracing.py is needed.

Types of Changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Check all that apply

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog
  • This PR passes the integration tests (ask a Datadog member to run the tests)

@duncanista duncanista requested a review from a team as a code owner May 23, 2023 19:48
@zARODz11z
Copy link
Contributor

@duncanista
Copy link
Contributor Author

What about adding peer.service on the function execution span?
https://github.com/DataDog/datadog-lambda-python/pull/337/files#diff-eb1f51efb218a7a829e913e4ff6b17ce27be8a777bc20c283e5b843e5db151efR1177

This would have to be handled by dd-trace-py since we are doing upstream only in this PR.

@zARODz11z
Copy link
Contributor

What about adding peer.service on the function execution span?
https://github.com/DataDog/datadog-lambda-python/pull/337/files#diff-eb1f51efb218a7a829e913e4ff6b17ce27be8a777bc20c283e5b843e5db151efR1177

This would have to be handled by dd-trace-py since we are doing upstream only in this PR.

Interesting, so you're saying in the tracer we'd add peer.service on the actual function execution span? Doing this in a different pr is fine with me but what you said doesn't make sense to me since the function execution span is created here so why would we want to add the peer.service tag in the tracer instead of here in dd lambda py? Unless it's because any downstream spans in relation to the function execution span are created in the tracer thus I'd have the appropriate value of what the peer.service tag should equal

I.e. if we have a function that makes an aws sdk request to sqs then because that aws sdk request span is created in the tracer we would add another tag to the function execution span pointing to the sqs queue???

@zARODz11z
Copy link
Contributor

I wonder how we would edit the function execution span in the tracer. For some reason that isn't clicking, I assume we start and finish it in dd lambda py so adding that peer.service span in the tracer after its been finished seems like it may be difficult but I've never done that. Lmk

@@ -801,6 +808,7 @@ def create_inferred_span_from_api_gateway_websocket_event(
"connection_id": request_context.get("connectionId"),
"event_type": request_context.get("eventType"),
"message_direction": request_context.get("messageDirection"),
"peer.service": service_env_var,
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 just a general comment and it doesn't have to be done in this pr: we should create a general_tags() method and save some repetition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, we should refactor this, but it's a really long file. We should follow a similar approach in Node.

Copy link
Contributor

@joeyzhao2018 joeyzhao2018 left a comment

Choose a reason for hiding this comment

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

lgtm

@duncanista duncanista requested a review from joeyzhao2018 June 5, 2023 15:13
@duncanista duncanista requested a review from zARODz11z June 6, 2023 15:31
@@ -315,6 +317,9 @@ def _after(self, event, context):
if status_code:
self.inferred_span.set_tag("http.status_code", status_code)

if self.service:
self.inferred_span.set_tag("peer.service", self.service)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

@duncanista duncanista merged commit c9209cb into main Jun 15, 2023
@duncanista duncanista deleted the jordan.gonzalez/support-peer-service-in-inferred-spans branch June 15, 2023 17:41
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.

3 participants