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

feat: Allow configuring span name, and add :route_name #4

Merged
merged 1 commit into from
Jul 11, 2019
Merged

feat: Allow configuring span name, and add :route_name #4

merged 1 commit into from
Jul 11, 2019

Conversation

zachdaniel
Copy link
Contributor

@zachdaniel zachdaniel commented Jun 14, 2019

Chris Mccord messaged me recently to let me know of an awesome new thing in a recent version of phoenix that allows us to finally get the route template :D I'm working on getting things set up to write a spandex to opencensus guide, so I'm contributing this here, instead of on our end. Right now in spandex we get the route in a very hacky/ugly way, so I'm excited to have this.

I made it configurable to retain your current default, and added the ability to configure it as an MFA, but I'm open to any and all feedback here. I just threw this together quick, so we can make any changes necessary. If you like it, I can add documentation/tests to get it up to par.

lib/opencensus_phoenix/instrumenter.ex Outdated Show resolved Hide resolved
@tsloughter
Copy link
Member

I wouldn't bother with making it configurable. The http spec for OC is to use the route, so it should be just how it works.

Copy link
Member

@tsloughter tsloughter left a comment

Choose a reason for hiding this comment

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

Approving but I do think it shouldn't bother with the config option, I'll wait to merge until that is changed unless others feel strongly about keeping the option.

@zachdaniel
Copy link
Contributor Author

@tsloughter this code currently does method + route, like GET /foo/bar, but I'd be happy to just do the route instead.

@tsloughter
Copy link
Member

Ah, yea, the method should just be an attribute according to the spec https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/HTTP.md#spans

@zachdaniel
Copy link
Contributor Author

zachdaniel commented Jul 11, 2019

Yeah, I just found that when you mentioned the spec. I should get used to this not being the Wild West of Spandex where we just made things in the way that would render best in Datadog's proprietary systems. Not an insult to them, but a lot of atypical/unexpected things were required there.

@tsloughter
Copy link
Member

hehe, yea. It is nice having all that proprietary weirdness moved to the reporters.

defp route_info(%{method: method, request_path: request_path, host: host} = conn) do
router = conn.private[:phoenix_router]

apply(Phoenix.Router, :route_info, [router, method, request_path, host])
Copy link
Member

Choose a reason for hiding this comment

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

Why is this an apply instead of just Phoenix.Router.route_info(router, method, request_path, host)

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 guess it was because it was generating a compiler warning, but now it won't be compiled without that function available, so I'll make it a normal call.

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 haven't (and won't for a bit) have a chance to test these on a running phoenix application so if you have one on hand we should try it out before merging.

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok

Copy link
Member

Choose a reason for hiding this comment

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

oh, oops, hehe, I don't but I'm asking at work if anyone does.

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 can try it out tonight, so if you confirm that it works let me know but otherwise I'll check then (8-10 hours from now).

@tsloughter tsloughter merged commit 2714475 into opencensus-beam:master Jul 11, 2019
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.

4 participants