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

Resurrects duplicate handlers and explains all the bugs we can make #961

Merged
merged 2 commits into from
Aug 13, 2019

Conversation

codefromthecrypt
Copy link
Member

I really don't like this in any way.

@codefromthecrypt
Copy link
Member Author

here's the problem that can sneak up on the next change to add a list parameter.

  @Configuration
  static class ListBindingProblems {
    @Autowired List<A> as;
    @Autowired List<B> bs;

    @Bean A provideA() {
      return new AB();
    }
  }

  @Test public void listBindingProblems() {
    context.register(ListBindingProblems.class);
    context.refresh();

    ListBindingProblems problems = context.getBean(ListBindingProblems.class);
    assertThat(problems.as).hasSize(1);
    // eventhough the user declared their bean method provideA as returning A, spring will look at
    // all types and magically fill here. What that means is you have to be defensive about dupes,
    // or make it impossible to create dupes by type hierarchy.
    assertThat(problems.bs).hasSize(1);
  }

@codefromthecrypt
Copy link
Member Author

The concrete problem is we need to provide a means to affect propagation, and almost always people are adding tags only visible from finished span handler. For example, almost always if someone adds extra field "correlation-id" they are also adding it as a tag, and this has been asked for a lot (ex #577).

While incomplete, secondary sampling (#958) and secondary trace context (#693) have similar needs. Rather than create a new type that is the same as FinishedSpanHandler, accepts the same parameters etc, just to avoid dupes... or to make people using a plugin to have to register in two places to avoid implicit registration dupes, the easiest way out is to not allow dupes.

While it is very easy to come up with reasons for not allowing dupes, I've not heard any reason to allow dupes especially on object.equals. Optimizing towards allowing dupes opens up bugs and really complicates the ability to add features.

Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

I don't feel that strongly about allowing dupes ;) Just that it feels when calling an add method multiple times it wouldn't silently ignore some. I see that Spring makes it easier to mess something up.

Instead of dropping dupes, what do you think about throwing an exception for a dupe so it's not just silently dropped?

@codefromthecrypt
Copy link
Member Author

throwing an exception works for me. we could check the result of set.add for example

@codefromthecrypt
Copy link
Member Author

problem with throwing an exception though is that if the dupes are outside their control you crash the app for no good reason. I think logging would be better, don't you?

@codefromthecrypt
Copy link
Member Author

because the dupes still could arise from the same scenario described. many times people are not writing config directly rather inheriting it.

@codefromthecrypt
Copy link
Member Author

basically there is no use case for dupes and I hate having to always do emergency releases for preventable things.. it is hard to get behind crashing over this

@codefromthecrypt
Copy link
Member Author

merging as is because at least the work I am doing can avoid most of these bugs. also I want to reserve focus for more important code

@codefromthecrypt codefromthecrypt merged commit 595788d into master Aug 13, 2019
@codefromthecrypt codefromthecrypt deleted the dont-dedupe branch August 13, 2019 06:21
codefromthecrypt pushed a commit that referenced this pull request Oct 2, 2019
It is a worse bug to allow duplicate handlers than it is to allow
duplicate configuration. Duplicate handlers translate directly into
runtime overhead, particularly as there is special casing for one
handler.

Throwing an exception was suggested here #961, but that is not a good
choice as it would almost certainly lead to someone having to do an
emergency release to undo it. This changes to logging on dupe, so that
we don't propagate this problem into future work such as collector
handlers.

See openzipkin/zipkin#2807 (comment)
codefromthecrypt pushed a commit that referenced this pull request Oct 2, 2019
It is a worse bug to allow duplicate handlers than it is to allow
duplicate configuration. Duplicate handlers translate directly into
runtime overhead, particularly as there is special casing for one
handler.

Throwing an exception was suggested here #961, but that is not a good
choice as it would almost certainly lead to someone having to do an
emergency release to undo it. This changes to logging on dupe, so that
we don't propagate this problem into future work such as collector
handlers.

See openzipkin/zipkin#2807 (comment)
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.

2 participants