-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add inject_context and current_context #78
Conversation
@@ -622,8 +646,10 @@ defmodule Spandex.Test.SpandexTest do | |||
|> Plug.Test.conn("/") | |||
|> Plug.Conn.put_req_header("x-test-trace-id", "1234") | |||
|> Plug.Conn.put_req_header("x-test-parent-id", "5678") | |||
|> Plug.Conn.put_req_header("x-test-sampling-priority", "10") |
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.
Nested modules could be aliased at the top of the invoking module.
opts = @base_opts ++ @span_opts | ||
assert {:ok, %Trace{id: trace_id}} = Spandex.start_trace("root_span", opts) | ||
assert {:ok, %Span{id: span_id}} = Spandex.start_span("span_name", @base_opts) | ||
assert {:ok, %SpanContext{trace_id: ^trace_id, parent_id: ^span_id}} = Spandex.current_context(@base_opts) |
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.
Line is too long (max is 100, was 112).
lib/spandex.ex
Outdated
def current_context(opts) do | ||
strategy = opts[:strategy] | ||
case strategy.get_trace(opts[:trace_key]) do | ||
{:ok, %Trace{id: trace_id, priority: priority, baggage: baggage, stack: [%Span{id: span_id} | _]}} -> |
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.
Line is too long (max is 100, was 107).
lib/spandex.ex
Outdated
strategy = opts[:strategy] | ||
case strategy.get_trace(opts[:trace_key]) do | ||
{:ok, %Trace{id: trace_id, priority: priority, baggage: baggage, stack: [%Span{id: span_id} | _]}} -> | ||
{:ok, %SpanContext{trace_id: trace_id, priority: priority, baggage: baggage, parent_id: span_id}} |
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.
Line is too long (max is 100, was 105).
@@ -6,6 +6,7 @@ defmodule Spandex.Adapter do | |||
@callback distributed_context(Plug.Conn.t(), Keyword.t()) :: | |||
{:ok, Spandex.SpanContext.t()} | |||
| {:error, atom()} | |||
@callback inject_context(Spandex.headers(), Spandex.SpanContext.t(), Keyword.t()) :: Spandex.headers() |
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.
Line is too long (max is 100, was 104).
Ebert has finished reviewing this Pull Request and has found:
You can see more details about this review at https://ebertapp.io/github/spandex-project/spandex/pulls/78. |
2805e52
to
bb1cf01
Compare
|
||
case strategy.get_trace(opts[:trace_key]) do | ||
{:ok, %Trace{id: trace_id, priority: priority, baggage: baggage, stack: [%Span{id: span_id} | _]}} -> | ||
{:ok, %SpanContext{trace_id: trace_id, priority: priority, baggage: baggage, parent_id: span_id}} |
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.
Line is too long (max is 100, was 105).
Pull Request Test Coverage Report for Build 348
💛 - Coveralls |
Ok, I think this PR is ready to merge. If you think these last commits are good, I can hit the button and then work on a release-prep PR for 2.3.0 so that I can bump the version requirement in |
Adds APIs for
current_context
(to allow people to get access to aSpanContext
based on the current span context) andinject_context
to simplify adding distributed tracing headers to HTTP calls.This somewhat-unfortunately also required an update to the
Adapter
behaviour, so I've also got a PR toSpandexDatadog
queued up (spandex-project/spandex_datadog#6).