@@ -106,6 +106,11 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
106
106
107
107
return SpanExportResult .SUCCESS
108
108
except Exception :
109
+ # FIXME: I'm using this to catch bug during development.
110
+ # OTEL must disable logging capture during export to avoid data loops.
111
+ # At least during develpoment, we want to catch and report pure bugs.
112
+ # Perhaps this part needs to be removed before merge/release.
113
+ # Leaving here for now to decide how to test this code path.
109
114
logger .exception ('export' )
110
115
raise
111
116
@@ -225,6 +230,12 @@ def setup_tracing(charm_class_name: str) -> None:
225
230
span_processor = BatchSpanProcessor (_exporter )
226
231
provider .add_span_processor (span_processor )
227
232
set_tracer_provider (provider )
233
+ # FIXME: in testing with tracing, we need a hack.
234
+ # OpenTelemetry disallows setting the tracer provider twice,
235
+ # a waring is issued and new provider is ignored.
236
+ #
237
+ # For example, we could reset the resource instead:
238
+ # get_tracer_provider()._resource = resource
228
239
229
240
230
241
def set_tracing_destination (
@@ -240,6 +251,19 @@ def set_tracing_destination(
240
251
assert _exporter , 'tracing has not been set up'
241
252
_exporter .settings = (url , ca )
242
253
254
+ # FIXME: this is not right
255
+ # We recommend obsering the SetupTracingEvent unconditionally.
256
+ # This means that this function is called whenever there's a relation.
257
+ # That's regardless of deferred events being emitted or observed.
258
+ # And regardless of the dispatched event being observed.
259
+ #
260
+ # There needs to be a separate function to mark this dispatch invocation
261
+ # as observed. The logic would be somewhat complicated though.
262
+ # In essense:
263
+ # - any deferred event observed (perhaps simply emitted), or
264
+ # - the dispatched event observed
265
+ #
266
+ # Arguably if a defferred event is emitted, it's almost always observed.
243
267
_exporter .buffer .mark_observed ()
244
268
245
269
0 commit comments