Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

add in environment option #179

Merged
merged 2 commits into from
Jul 29, 2016
Merged

add in environment option #179

merged 2 commits into from
Jul 29, 2016

Conversation

jbaxleyiii
Copy link
Contributor

@jbaxleyiii jbaxleyiii commented Jul 29, 2016

@benvinegar
Copy link
Contributor

If you could add a cursory test for this I will merge pronto.

@jbaxleyiii
Copy link
Contributor Author

@benvinegar can do!

@@ -41,6 +41,7 @@ var Client = function Client(dsn, options) {
this.root = options.root || process.cwd();
this.transport = options.transport || transports[this.dsn.protocol];
this.release = options.release || process.env.SENTRY_RELEASE || '';
this.environment = options.environment || process.env.SENTRY_ENVIRONMENT || '';
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't we want to leverage NODE_ENV for this? Or is that not really a thing anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

I kind of agree, and was going to ping @dcramer whether SENTRY_ENVIRONMENT was a thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattrobenolt @benvinegar I thought about that but saw from the blog:

By default we automatically select the most production like environment

and I also saw this so I opted not too. I'm happy to add it in as a fallback!

fwiw, most people I know run node in 'production' for staging sites so I don't know how much value it would add

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove NODE_ENV entirely, fixes many issues since people have different opinions on wtf this means

lol, yeah, I remember this. Before, it was automatically enabling/disabling Raven as a whole if NODE_ENV wasn't production.

But yeah, you might be right. I don't think this is really used to mean an environment. I don't think someoen would say NODE_ENV=staging, etc.

@jbaxleyiii
Copy link
Contributor Author

@benvinegar tests added 👍

@benvinegar benvinegar merged commit 14401a2 into getsentry:master Jul 29, 2016
@benvinegar
Copy link
Contributor

Fantastic. Thanks!

@ghost
Copy link

ghost commented Aug 4, 2016

Did anybody "functionally tested" the thing because I cannot see the kwargs being set in the process function?

I'm using 0.22.0 right now solely for this new feature and I'm trying to figure why it doesn't work for me...

@ghost
Copy link

ghost commented Aug 4, 2016

Well, reading the Sentry documentation you can set the environment called context through the tags field.

Source https://docs.getsentry.com/hosted/clientdev/attributes/

What I'm saying is that, setting the environment worked prior to 0.22.0 and you only need to pass some extra options. For example, when initializing the Client,

var raven = require('raven');
var client = new raven.Client(
    '<url>',
    {
        tags: {
            environment: 'development'
        }
    });

And it works, I get the environment tag in Sentry... Or may I miss something?

@benvinegar
Copy link
Contributor

I cannot see the kwargs being set in the process function?

Hmm, yeah, looking back ... not sure why I thought this was functionally correct. I'll follow-up with a fix.

And it works, I get the environment tag in Sentry... Or may I miss something?

The environment tag is different from the explicit "environment" attribute. More here: https://docs.getsentry.com/hosted/clientdev/attributes/

@benvinegar
Copy link
Contributor

See #185

@ghost
Copy link

ghost commented Aug 5, 2016

It works now with #185.

But Sentry is quite weird with the Environment thing. I don't understand the difference between a tag and an attribute. Both are interpreted by Sentry but setting both produces some weird things, for example here on Slack,

screen shot 2016-08-05 at 09 01 22

@dcramer
Copy link
Member

dcramer commented Aug 5, 2016

If I had to guess I'd say you're sending "Environment" and "environment" and at this time tags are case sensitive.

@dcramer
Copy link
Member

dcramer commented Aug 5, 2016

Alternatively it might be that it's tagging it twice but most of our code doesn't support that. Either way you don't need to send the tag when you've sent the top level attribute.

@ghost
Copy link

ghost commented Aug 5, 2016

Don't worry, I used the very same strings ;)

Ok then, now waiting for 0.23.0 I guess.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants