-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Replace es-spanstore tracing instrumentation with OpenTelemetry #4596
Conversation
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Codecov ReportPatch coverage:
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
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
Signed-off-by: Afzal Ansari <[email protected]>
15a8ccd
to
48f38ad
Compare
Signed-off-by: Afzal Ansari <[email protected]>
48f38ad
to
0d078fb
Compare
if p.Tracer == nil { | ||
p.Tracer = otel.Tracer("eSpanstore.SpanReader") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if p.Tracer == nil { | |
p.Tracer = otel.Tracer("eSpanstore.SpanReader") | |
} |
client: client, | ||
logger: logger, | ||
logBuffer: logBuffer, | ||
exporter: exp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()) |
There was a problem hiding this comment.
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 defer
s 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.
There was a problem hiding this comment.
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. 😄
Signed-off-by: Afzal <[email protected]>
0eab75b
to
f3e92fa
Compare
@@ -126,6 +124,7 @@ func withSpanReader(fn func(r *spanReaderTest)) { | |||
MaxDocCount: defaultMaxDocCount, | |||
}), | |||
} | |||
defer closer() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer after creation
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
minor clean-up #4605 |
Which problem is this PR solving?
Short description of the changes