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

Don't report 400 level as error for SERVER spans #4403

Merged
merged 13 commits into from
Oct 20, 2021

Conversation

breedx-splk
Copy link
Contributor

This resolves #4357

I am assuming that this will likely break some tests, but let's get it going and I'll address those as they arise.

@@ -15,7 +16,7 @@

@Override
public StatusCode extract(
REQUEST request, @Nullable RESPONSE response, @Nullable Throwable error) {
REQUEST request, @Nullable RESPONSE response, SpanKind kind, @Nullable Throwable error) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of introducing a kind param, how about deciding the behavior basing on the attributes extractor used? I.e. you could check extractor instanceof HttpServerAttributesExtractor and choose the behavior based on that

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to choosing right implementation ASAP. Although it does not make any difference performance-wise.

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 that mean that no one could provide their own attributes extractor and have this logic still work? Coupling this to a specific implementation class seems like a bad idea for what we consider to be an API to be used outside of this project.

Copy link
Member

Choose a reason for hiding this comment

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

HttpSpanStatusExtractor#create() already requires an HttpCommonAttributesExtractor (which cannot be extended directly; you can only extend HttpClientAttributesExtractor or HttpServerAttributesExtractor) so you can't really pass a completely custom attributes extractor.

Copy link
Contributor

Choose a reason for hiding this comment

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

But, that would mean that no one could build a kind-oriented attributes extractor (independent of this particular one for http server spans), which still seems like a limitation that might not be desirable.

Copy link
Member

Choose a reason for hiding this comment

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

would splitting into HttpClientSpanStatusExtractor and HttpServerSpanStatusExtractor work?

we've been finding it useful to split out other extractors based on client/server, e.g. Http(Client|Server)AttributesExtractor and Net(Client|Server)AttributesExtractor (though there's an open discussion on the latter in #4408)

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 considered it but was too concerned it might cause problems with frameworks (and consequently instrumentations) that aren't purely client/server, right? Isn't there instrumentation that can generate both SERVER and CLIENT spans? I'm thinking about messaging systems and http/2 server push, for example.

This was also the thinking behind the "late binding", if you will (I think this is what @iNikem was getting at with the "ASAP" comment).

If this isn't true and we don't think it'll be a problem, we could try that out.

Copy link
Contributor

Choose a reason for hiding this comment

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

I considered it but was too concerned it might cause problems with frameworks (and consequently instrumentations) that aren't purely client/server, right? Isn't there instrumentation that can generate both SERVER and CLIENT spans? I'm thinking about messaging systems and http/2 server push, for example.

They already will have to provide the correct SpanKindExtractor. Which means that they will most probably have separate instrumenters per kind. Thus separate SpanStatusExtractor will not be a problem either.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't there instrumentation that can generate both SERVER and CLIENT spans?

I think all of these are creating two instrumenters already, one to handle server spans and one to handle client spans.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, let me give that an attempt then.

Comment on lines 55 to 57
else if (!success && response.status().code() < 500) {
status UNSET
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: no need to check for that explicitly; SpanAssert will verify that the status is UNSET in case you haven't done that in your test code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How/where does SpanAssert enter in? I don't see it.

Copy link
Member

Choose a reason for hiding this comment

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

Groovy (< insert the Army of Darkness gif >)

Everything under the span(...) {} block executes in the context of SpanAssert (i.e. this is a SpanAssert instance), when the block exits the assertDefaults() function executes.

Copy link
Member

Choose a reason for hiding this comment

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

@breedx-splk is this another vote for converting groovy tests to java? 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mateuszrzeszutek Ah, cool, I see it now. It's not great that the status asserts are so far apart...and yeah, @trask I'd love for this not to be groovy...but it sounds like a pretty massive effort...

$ find instrumentation -name '*.groovy' | wc -l
     577
$ find instrumentation -name '*.groovy' | xargs cat | wc -l
   69566

😱

Copy link
Member

Choose a reason for hiding this comment

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

it sounds like a pretty massive effort

ya, maybe after instrumentation api stability...

@trask trask merged commit a50c133 into open-telemetry:main Oct 20, 2021
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
* don't report 400 level as error for server spans

* fix HttpServerTest base class

* fix JspInstrumentationForward test

* split HttpStatusConverter into client and server implementations, and create two HttpSpanStatusExtractor.create methods, one for server and one for client.

* rebase

* fix test

* spotless

* fix test

* remove unused

* use strongly typed attributes converters and rename to overloaded create()

* fix tests

* remove redundant assert

Co-authored-by: Trask Stalnaker <[email protected]>
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.

Don't set Span.Status for 4xx http status codes for SERVER spans
5 participants