oolong-dev / OpenTelemetry.jl

An unofficial implementation of OpenTelemetry in Julia.
https://oolong.dev/OpenTelemetry.jl/
Apache License 2.0
30 stars 9 forks source link

Enable manual management of Span lifecycle #97

Closed krynju closed 8 months ago

krynju commented 9 months ago

The rationale here is that I could not create Spans with predefined trace_id easily. This is to cover the distributed case where I get a trace_id from an external system

When I added the capability to create spans I had to add ways to actually use them, so modified with_span etc. a bit. Lots of things were already there, so just filling in the gaps.

Also fixes some redefinitions which appear after the schedule Task fix here https://github.com/oolong-dev/OpenTelemetry.jl/pull/97/commits/323fd55d84da28efca87ef6f12983221fa67c888 So it partially fixes https://github.com/oolong-dev/OpenTelemetry.jl/issues/93

Example:

# create a span with `trace_id` linked to a previous span with `span_id`
function otel_create_span(
    name::AbstractString,
    trace_id::UInt128,
    link_span_id::UInt64,
)
    link_sc = SpanContext(;
        span_id=link_span_id,
        trace_id,
        is_remote=true,
    )
    l1 = Link(link_sc, BoundedAttributes())
    s = create_span(
        name;
        trace_id,
        links=Link[l1],
    )
    return s::Span
end
codecov[bot] commented 9 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (f2f3c1c) 76.30% compared to head (323fd55) 76.71%.

Files Patch % Lines
src/api/src/trace/tracer_provider.jl 66.66% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #97 +/- ## ========================================== + Coverage 76.30% 76.71% +0.41% ========================================== Files 47 47 Lines 1422 1439 +17 ========================================== + Hits 1085 1104 +19 + Misses 337 335 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.