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

[v2][adjuster] Implement adjuster for correct timestamps for clockskew #6392

Merged
merged 11 commits into from
Dec 23, 2024

Conversation

mahadzaryab1
Copy link
Collaborator

@mahadzaryab1 mahadzaryab1 commented Dec 22, 2024

Which problem is this PR solving?

Description of the changes

  • Implemented an adjuster to correct timestamps for clockskew.

How was this change tested?

  • Added unit tests

Checklist

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Copy link

codecov bot commented Dec 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.23%. Comparing base (54ceda2) to head (8dba287).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #6392    +/-   ##
========================================
  Coverage   96.22%   96.23%            
========================================
  Files         363      364     +1     
  Lines       20748    20868   +120     
========================================
+ Hits        19965    20082   +117     
- Misses        599      601     +2     
- Partials      184      185     +1     
Flag Coverage Δ
badger_v1 9.04% <ø> (ø)
badger_v2 1.64% <ø> (ø)
cassandra-4.x-v1-manual 15.04% <ø> (ø)
cassandra-4.x-v2-auto 1.58% <ø> (ø)
cassandra-4.x-v2-manual 1.58% <ø> (ø)
cassandra-5.x-v1-manual 15.04% <ø> (ø)
cassandra-5.x-v2-auto 1.58% <ø> (ø)
cassandra-5.x-v2-manual 1.58% <ø> (ø)
elasticsearch-6.x-v1 18.76% <ø> (+<0.01%) ⬆️
elasticsearch-7.x-v1 18.84% <ø> (+<0.01%) ⬆️
elasticsearch-8.x-v1 18.99% <ø> (ø)
elasticsearch-8.x-v2 1.64% <ø> (+<0.01%) ⬆️
grpc_v1 10.72% <ø> (+<0.01%) ⬆️
grpc_v2 7.98% <ø> (ø)
kafka-v1 9.40% <ø> (ø)
kafka-v2 1.64% <ø> (ø)
memory_v2 1.64% <ø> (ø)
opensearch-1.x-v1 18.88% <ø> (ø)
opensearch-2.x-v1 18.89% <ø> (+<0.01%) ⬆️
opensearch-2.x-v2 1.63% <ø> (-0.01%) ⬇️
tailsampling-processor 0.47% <ø> (ø)
unittests 95.08% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yurishkuro
Copy link
Member

Let's make sure we reproduce the existing tests as close as possible

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
cmd/query/app/querysvc/adjuster/clockskew.go Show resolved Hide resolved
// hostKey derives a unique string representation of a host based on resource attributes.
// This is used to determine if two spans are from the same host.
func hostKey(resource ptrace.ResourceSpans) string {
if attr, ok := resource.Resource().Attributes().Get("ip"); ok {
Copy link
Member

Choose a reason for hiding this comment

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

We may need to reconsider this. Even in OpenTracing the tag "ip" was never standard, so why should we use it as a differentiator? In OTEL there are semantic conventions for host identity, we should be using those.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro I see these semantic conventions related to hosts: https://github.com/open-telemetry/opentelemetry-go/blob/main/semconv/v1.26.0/attribute_group.go#L3853-L3854. Do we want to replace this with HostIPKey?

Copy link
Member

Choose a reason for hiding this comment

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

I think we should try (in order):

  • host.id
  • host.ip
  • host.name

Copy link
Member

Choose a reason for hiding this comment

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

The host.ip is an array, I think it's ok to look at the first element only.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro Done. Let me know if this aligns with what you were thinking

cmd/query/app/querysvc/adjuster/clockskew.go Show resolved Hide resolved

const (
warningDuplicateSpanID = "duplicate span IDs; skipping clock skew adjustment"
warningFormatInvalidParentID = "invalid parent span IDs=%s; skipping clock skew adjustment"
Copy link
Member

Choose a reason for hiding this comment

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

Why does this have format in the name? Are we warning about id format? I'd also tweak the error to be more specific - invalid is not really descriptive. I think here we mean that parent span id is not in the trace.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@yurishkuro I think the "format" is there is because this is a format string. I removed the word format and changed the warning string per your suggestion.

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
@mahadzaryab1 mahadzaryab1 changed the title [WIP][v2][adjuster] Implement adjuster for correct timestamps for clockskew [v2][adjuster] Implement adjuster for correct timestamps for clockskew Dec 22, 2024
@mahadzaryab1 mahadzaryab1 marked this pull request as ready for review December 22, 2024 21:15
@mahadzaryab1 mahadzaryab1 requested a review from a team as a code owner December 22, 2024 21:15
@dosubot dosubot bot added the v2 label Dec 22, 2024
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
return attr.Str()
}
if attr, ok := resource.Resource().Attributes().Get(string(otelsemconv.HostIPKey)); ok {
ips := attr.Slice()
Copy link
Member

Choose a reason for hiding this comment

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

I suspect some people may ignore setting a slice and set just a plain string, so I would handle that use case too.

cmd/query/app/querysvc/adjuster/clockskew.go Outdated Show resolved Hide resolved
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
@mahadzaryab1 mahadzaryab1 enabled auto-merge (squash) December 23, 2024 02:39
@mahadzaryab1 mahadzaryab1 merged commit e39609e into jaegertracing:main Dec 23, 2024
54 checks passed
@mahadzaryab1 mahadzaryab1 deleted the clockskew branch December 23, 2024 02:49
ekefan pushed a commit to ekefan/jaeger that referenced this pull request Dec 23, 2024
jaegertracing#6392)

## Which problem is this PR solving?
- Towards jaegertracing#6344

## Description of the changes
- Implemented an adjuster to correct timestamps for clockskew. 

## How was this change tested?
- Added unit tests

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Manik2708 pushed a commit to Manik2708/jaeger that referenced this pull request Jan 5, 2025
jaegertracing#6392)

## Which problem is this PR solving?
- Towards jaegertracing#6344

## Description of the changes
- Implemented an adjuster to correct timestamps for clockskew. 

## How was this change tested?
- Added unit tests

## Checklist
- [x] I have read
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md
- [x] I have signed all commits
- [x] I have added unit tests for the new functionality
- [x] I have run lint and test steps successfully
  - for `jaeger`: `make lint test`
  - for `jaeger-ui`: `npm run lint` and `npm run test`

---------

Signed-off-by: Mahad Zaryab <mahadzaryab1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants