Closed vj4iosdev closed 10 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Files | Coverage Δ | |
---|---|---|
...penTelemetryProtocolCommon/trace/SpanAdapter.swift | 99.00% <100.00%> (ø) |
|
...etryProtocolGrpc/trace/OtlpTraceJsonExporter.swift | 88.57% <100.00%> (ø) |
... and 2 files with indirect coverage changes
:loudspeaker: Thoughts on this report? Let us know!.
@nachoBonafonte @bryce-b @vvydier Please take a look whenever you get some time.
It looks good to me, I completely agree with the getExportedSpans()
being public, but I don't understand why you need the SpanAdapter utility functions to be public instead of modifying the SpanData
and calling the default toProtoSpan()
It looks good to me, I completely agree with the
getExportedSpans()
being public, but I don't understand why you need the SpanAdapter utility functions to be public instead of modifying theSpanData
and calling the defaulttoProtoSpan()
Ok. So here is our use case. When we receive spanData from web FCI to mobile FCI, we are required not to generate the spanID, traceID, parentSpanID and span attributes but override these as received from the web.
We need to override toProtoSpan(spanData: SpanData)
method in SpanAdapter in order to override the spanID, traceID, parentSpanID and span attributes but the SpanAdapter being struct we cannot mark the method toProtoSpan(spanData: SpanData)
as open
to enable it for the override.
So here is our code:
static func toProtoSpan(spanData: SpanData) -> Opentelemetry_Proto_Trace_V1_Span {
if OverrideProtoSpan.containsOverridenAttributes(spanData: spanData) {
// we override spanData here
return OverrideProtoSpan.toProtoSpan(spanData: spanData)
}
// then the rest of the code as is..
}
And in the OverrideProtoSpan.toProtoSpan(spanData: spanData)
we use the utility functions of SpanAdapter
to override the traceID, spanID, parentSpanID and span attributes received from the web FCI.
Hope this clarifies.
Thanks for the clarification it makes total sense now. If you think that making span adapter a class with the open method works better for you, fellow free to change it.
Thanks for the clarification it makes total sense now. If you think that making span adapter a class with the open method works better for you, fellow free to change it.
Thanks for the approval @nachoBonafonte . Static declarations are implicitly 'final' so may have to make changes in many places if I do that. So I will have this merged as of now and open a new one later. Please merge this PR whenever you happen to see this.
What's changed in this PR?
Changing the access control level for the below methods from
internal
topublic
inSpanAdapter
One more minor change done in
OtlpTraceJsonExporter
i,e changing the access control for the methodgetExportedSpans()
to public from internal. I had contributed to this earlier but we were using this file locally. Now we are upgrading to use this directly from this repo.Why is this change required?