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

Global tags #92

Closed
wants to merge 41 commits into from
Closed

Conversation

intelekshual
Copy link
Contributor

This PR adds the ability to set global tags on a Tracer instance. These tags are applied to every Span created by the Tracer. This is useful when instrumenting applications in different environments (ex. staging and production), which is why I also updated the Rails contrib to set the env tag to the Rails environment.

ufoot added 30 commits March 9, 2017 10:32
@ufoot ufoot added core Involves Datadog core libraries enhancement labels Mar 15, 2017
@ufoot
Copy link
Contributor

ufoot commented Mar 15, 2017

Thanks for the submission, will take a look, interesting!

@palazzem palazzem self-requested a review March 30, 2017 09:58
@palazzem palazzem self-assigned this Mar 30, 2017
@palazzem
Copy link
Contributor

Hello @intelekshual ! we're looking at your PR and I'm going to rebase / merge it soon. Will keep you updated when it will be part of the next release!

@palazzem palazzem changed the base branch from develop to master March 30, 2017 10:04
@ufoot ufoot added this to the 0.6.1 milestone Mar 30, 2017
Copy link
Contributor

@palazzem palazzem left a comment

Choose a reason for hiding this comment

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

Hey @intelekshual! your PR has been merged with #100 and we also have a follow-up #101! I'm going to close this one but as you can see all your commits are in the #100!

Thank you a lot for your contribution!

@palazzem palazzem closed this Mar 30, 2017
@@ -26,7 +26,8 @@ module Framework
tracer: Datadog.tracer,
debug: false,
trace_agent_hostname: Datadog::Writer::HOSTNAME,
trace_agent_port: Datadog::Writer::PORT
trace_agent_port: Datadog::Writer::PORT,
env: ::Rails.env
Copy link

Choose a reason for hiding this comment

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

It looks like this change has yielded unexpected results, at least for me. With this change, some spans from the app—and only some but not all, oddly—are getting env:production set.

I have a Rails application that we run in multiple named production-like environments, e.g. staging and production. Both systems' Rails.env is production per Rails conventions. I differentiate between them by setting the env: tag in the agent's datadog.conf.

At a minimum, I'd call this change backwards-incompatible: upgrading the gem results in data getting sent with an unexpected env: tag.

Was this change to handle deployments where a single Datadog agent on a host would be receiving and forwarding data from multiple applications (not just development/test/production) and so therefore the application needs a way to name its stuff (traces? spans? I'm new here.).

What do ya'll think of a more specific default as a combination of the Rails application name and the Rails environment?

> Rails.application.class.to_s.split("::").first.downcase + '-' + Rails.env
=> "myrailsapp-production"

I'm new to APMing with Datadog, so I fully admit I could be doing something wrong or could be doing something better.

Copy link

Choose a reason for hiding this comment

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

For what it's worth, env: nil in my initializer brings back previous behavior (env: tag applied by the DD agent config).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my particular case, yes, I'm using a single Datadog agent per host, with each host receiving and forwarding data from multiple applications (specifically via Docker/Kubernetes). The Rails convention is not to have your staging and production environments use the same environment name. Instead you should have environments with different names that share configuration.

With that being said, maybe the easiest solution to handle your use-case is to make it possible to set env: to nil on the Rails side, forcing it to inherit env from your agent config.

Copy link

Choose a reason for hiding this comment

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

The Rails convention is not to have your staging and production environments use the same environment name.

Hunh. Today I Learned ...

OK. I can set aside my philosophical differences with what turns out to be convention and make nil my default. Thanks!

Copy link

Choose a reason for hiding this comment

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

Do you think that Rails.application.class.to_s.split("::").first.downcase + '-' + Rails.env as the default is just too silly to look at? (It's pretty silly.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for all this detailed feedback, FYI, we're trying to address this issue in #106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants