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

Avoid calculating _dd.hostname for Jenkins workers #184

Merged
merged 3 commits into from
Feb 22, 2021

Conversation

drodriguezhdez
Copy link
Collaborator

Requirements for Contributing to this repository

  • Fill out the template below. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • The pull request must only fix one issue at the time.
  • The pull request must update the test suite to demonstrate the changed functionality.
  • After you create the pull request, all status checks must be pass before a maintainer reviews your contribution. For more details, please see CONTRIBUTING.

What does this PR do?

This PR changes the logic of how we calculate the _dd.hostname for the traces:

  • If the node == master, we don't set _dd.hostname. It will be overridden by the Datadog Agent.
  • If the node != master, we set _dd.hostname to none explicitly, cause we cannot calculate the worker hostname.

This change is needed because we cannot always calculate the hostname of a Jenkins worker. For the main node, we will use the Datadog Agent logic to calculate the correct value.

Description of the Change

Alternate Designs

Possible Drawbacks

Verification Process

Additional Notes

Release Notes

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@drodriguezhdez drodriguezhdez added the changelog/Fixed Fixed features results into a bug fix version bump label Feb 22, 2021
// If the NodeName == master, we don't set _dd.hostname. It will be overridden by the Datadog Agent. (Traces are only available using Datadog Agent)
// If the NodeName != master, we set _dd.hostname to 'none' explicitly, cause we cannot calculate the worker hostname.
if(!"master".equalsIgnoreCase(nodeName)) {
buildSpan.setTag(CITags._DD_HOSTNAME, HOSTNAME_NONE);
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the impact of setting none here? This has a pretty big impact for metrics for instance (as it would create a new host with the "none" name), but this should be for traces only in that situation. Are we ok with setting a dummy value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As far as we know, APM doesn't create hosts based on the _dd.hostname tag. In this case, the value none is a special value for APM that is excluded from per-host billing. Additionally, if we don't set it and we let the agent put the master hostname, it'd be worse from a user perspective because we will be showing wrong information.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect, I didn't know about billing implications


final String nodeHostname = buildData.getHostname("").isEmpty() ? pipelineData.getHostname("") : buildData.getHostname("");
buildSpan.setTag(CITags._DD_HOSTNAME, nodeHostname);
// If the NodeName == master, we don't set _dd.hostname. It will be overridden by the Datadog Agent. (Traces are only available using Datadog Agent)
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not true when the plugin is configured in HTTP mode. In that case, no hostname will be reported.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, Jenkins traces collection is only available if the plugin is configured in a Datadog Agent mode: (link), so we can assume that's correct, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh right, completely forgot about that. Was there any plan to allow sending traces via HTTP? If yes we should add some additional logic here to fail if the plugin runs in http mode. That will help in the future

@drodriguezhdez drodriguezhdez merged commit c002ef6 into master Feb 22, 2021
@drodriguezhdez drodriguezhdez deleted the drodriguezhdez/fix_hostname branch February 22, 2021 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/Fixed Fixed features results into a bug fix version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants