spring-cloud-sleuth icon indicating copy to clipboard operation
spring-cloud-sleuth copied to clipboard

1.3.2 trace id conflict problem

Open Jaware opened this issue 8 years ago • 12 comments

most of the times,the id is ok,but sometimes we can find conflict ids.

@Bean
@ConditionalOnMissingBean
public Random randomForSpanIds() {
	return new Random();
}

i doubt that Random can be unique in distributed areas.

Jaware avatar Apr 12 '18 04:04 Jaware

Can you describe what "most of the times really means?". Other people are not complaining so maybe you have introduced some wrong setup or there's a bug in sleuth. Since you haven't provided any details e.g. When the id gets duplicated, then i don't really know how i can help you

marcingrzejszczak avatar Apr 12 '18 05:04 marcingrzejszczak

it is random,i do not know the details.but i am sure the random can not guarantee unique id in distributed areas.Maybe our apps' tps is so large.maybe i shoud use zipkin v2 span,which traceId is string ,and i can use UUID to guarantee unique id

Jaware avatar Apr 12 '18 07:04 Jaware

You can consider using the spring.sleuth.traceId128=true property

FYI Twitter still uses 64-bit trace ID by default, but likely they will move to 128-bit trace IDs. I don't think you will have a problem in practice and if you do why would be an interesting question.

codefromthecrypt avatar Apr 12 '18 07:04 codefromthecrypt

I'll close this issue until you get a sample that can reproduce an issue. Until then i don't see an issue here

marcingrzejszczak avatar Apr 12 '18 08:04 marcingrzejszczak

can Random really guarantee unique id in distributed envs? @adriancole traceId128 can not be spanid accoring the DefaultTracer

Jaware avatar Apr 12 '18 09:04 Jaware

a trace ID is unique per operation.

So if your concern is about span ID, you believe there's a reasonable chance of collision within the same operation. If your random generator is working, I don't think most use cases this will be a problem. This approach is used at large scale sites including google.

Issues lists aren't for hypothetical problems, rather for changes need to the code. I hope some of the context helps, but this isn't a good place to explore nuance of random generators.

codefromthecrypt avatar Apr 12 '18 10:04 codefromthecrypt

maybe because of our methods tracing,the span counts are too large,so i think i have to use other techs like UUID to guarantee distributed unique ID

Jaware avatar Apr 13 '18 03:04 Jaware

Sometimes when there is conflict it isnt because of random, rather a propagation bug somewhere. For example a span id reused by accident due to thread local problem. Could this be possible?

codefromthecrypt avatar Apr 13 '18 03:04 codefromthecrypt

If you have custom code please ensure that you're not leaving any spans unclosed. If you can't provide an example we can replicate the problem with then i don't think we'll be able to help you

marcingrzejszczak avatar Apr 18 '18 07:04 marcingrzejszczak

No, above you have some snippet. I have no idea what it really does. AOP - AOP around what? What does tracer() do? What is CommonUtil? This snippet doesn't help solve the problem at all. Please upload a sample of the whole project.

marcingrzejszczak avatar Apr 18 '18 10:04 marcingrzejszczak

I have no idea what you're doing. Also when you paste the code, please format it cause it's difficult to read.

marcingrzejszczak avatar Apr 18 '18 11:04 marcingrzejszczak

our code is ok,we have found some span ids are same,so we will use es id(we use es to store spans) instead of the random span id.the parent id problem is because our validating function had a bug and it droped some spans

Jaware avatar Apr 20 '18 11:04 Jaware