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

Replace es-spanstore tracing instrumentation with OpenTelemetry #4596

Merged
merged 16 commits into from
Jul 30, 2023

Conversation

afzal442
Copy link
Contributor

@afzal442 afzal442 commented Jul 23, 2023

Which problem is this PR solving?

Short description of the changes

  • Replaces OT tracer with OTEL tracer to support jtracer pkg

@afzal442 afzal442 requested a review from a team as a code owner July 23, 2023 09:32
@afzal442 afzal442 requested a review from vprithvi July 23, 2023 09:32
@codecov
Copy link

codecov bot commented Jul 23, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01% ⚠️

Comparison is base (2c1bf07) 97.08% compared to head (a98a0ed) 97.07%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4596      +/-   ##
==========================================
- Coverage   97.08%   97.07%   -0.01%     
==========================================
  Files         301      301              
  Lines       17857    17870      +13     
==========================================
+ Hits        17336    17347      +11     
- Misses        418      419       +1     
- Partials      103      104       +1     
Flag Coverage Δ
unittests 97.07% <100.00%> (-0.01%) ⬇️

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

Files Changed Coverage Δ
plugin/storage/es/factory.go 97.65% <100.00%> (+0.03%) ⬆️
plugin/storage/es/spanstore/reader.go 100.00% <100.00%> (ø)

... and 4 files with indirect coverage changes

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

Signed-off-by: Afzal Ansari <[email protected]>
plugin/storage/es/spanstore/reader.go Outdated Show resolved Hide resolved
plugin/storage/es/spanstore/reader_test.go Outdated Show resolved Hide resolved
plugin/storage/es/spanstore/reader.go Outdated Show resolved Hide resolved
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
@afzal442 afzal442 changed the title [WIP] Add OTEL tracer to spanstore component [WIP] Add OTEL tracer to es-spanstore component Jul 26, 2023
Signed-off-by: Afzal Ansari <[email protected]>
plugin/storage/es/spanstore/reader_test.go Outdated Show resolved Hide resolved
plugin/storage/es/spanstore/reader_test.go Outdated Show resolved Hide resolved
plugin/storage/es/spanstore/reader_test.go Outdated Show resolved Hide resolved
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Comment on lines 142 to 144
if p.Tracer == nil {
p.Tracer = otel.Tracer("eSpanstore.SpanReader")
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if p.Tracer == nil {
p.Tracer = otel.Tracer("eSpanstore.SpanReader")
}

client: client,
logger: logger,
logBuffer: logBuffer,
exporter: exp,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
exporter: exp,
traceBuffer: exp,

@@ -307,6 +327,8 @@ func TestSpanReader_GetTrace(t *testing.T) {
}, nil)

trace, err := r.reader.GetTrace(context.Background(), model.NewTraceID(0, 1))
require.NotEmpty(t, r.exporter.GetSpans(), "Spans recorded")
require.NoError(t, r.tracerCloser())
Copy link
Member

@yurishkuro yurishkuro Jul 30, 2023

Choose a reason for hiding this comment

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

one of the nice things about doing tests in a functional style via withSpanReader is that withSpanReader can do both initialization and tear-down, since it's frame is lower in the stack than the actual test function and defers inside withSpanReader always get executed even if the test function panics.

   TestSomething()
       withSpanReader(testFn)
            d = initialize()
            defer d.teardown()
            testFn(d)

So I don't think we even need to expose traceCloser in the struct, we can just defer-call it inside withSpanReader.

This is very different from helper functions that simply return a tracer. They have no room to defer-schedule shutdown, and you have to do it manually in the caller.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's nit. Cherry picked. 😄

@@ -126,6 +124,7 @@ func withSpanReader(fn func(r *spanReaderTest)) {
MaxDocCount: defaultMaxDocCount,
}),
}
defer closer()
Copy link
Member

Choose a reason for hiding this comment

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

we talked about where defers should be placed

Copy link
Contributor

@afzalbin64 afzalbin64 Jul 30, 2023

Choose a reason for hiding this comment

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

sorry Yuri! I did it inside withSpanReader function call. but How can I defer it? I think I have to modify the closer to use func() and fmt.Errorf. Or if I mistaken here, will I have to place it inside Test Function(fn)?

Copy link
Member

Choose a reason for hiding this comment

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

you create the object in L110, so defer closer() should be L111. Always keep defer next to creation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did that. Just to re-commit.

r := NewSpanReader(testCase.params)

actualSpan := r.timeRangeIndices(r.spanIndexPrefix, r.spanIndexDateLayout, date, date, -1*time.Hour)
actualService := r.timeRangeIndices(r.serviceIndexPrefix, r.serviceIndexDateLayout, date, date, -24*time.Hour)
assert.Equal(t, testCase.indices, append(actualSpan, actualService...))
}
require.NoError(t, closer())
Copy link
Member

Choose a reason for hiding this comment

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

defer after creation

Copy link
Member

Choose a reason for hiding this comment

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

L198

@@ -160,6 +177,10 @@ func (s *ESStorageIntegration) initSpanstore(allTagsAsFields, archive bool) erro
MaxDocCount: defaultMaxDocCount,
})

if closer != nil {
return err
Copy link
Member

Choose a reason for hiding this comment

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

?

Signed-off-by: Afzal <[email protected]>
MaxSpanAge: 0,
IndexPrefix: "",
TagDotReplacement: "@",
Archive: true,
UseReadWriteAliases: readAlias,
}),
}
defer closer()
Copy link
Member

Choose a reason for hiding this comment

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

to L134

Signed-off-by: Afzal <[email protected]>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

lgtm

@yurishkuro yurishkuro changed the title [WIP] Add OTEL tracer to es-spanstore component Replace es-spanstore tracing instrumentation with OpenTelemetry Jul 30, 2023
@yurishkuro yurishkuro merged commit de3cf99 into jaegertracing:main Jul 30, 2023
31 checks passed
@yurishkuro
Copy link
Member

minor clean-up #4605

@afzalbin64 afzalbin64 deleted the replace-with-otel-spanstore branch July 31, 2023 05:40
@afzalbin64 afzalbin64 restored the replace-with-otel-spanstore branch August 14, 2023 07:20
@afzal442 afzal442 deleted the replace-with-otel-spanstore branch August 14, 2023 17:48
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.

3 participants