Skip to content

Commit

Permalink
Made instance creation of KamonHttpContextPropagation even more flu…
Browse files Browse the repository at this point in the history
…ent.

Signed-off-by: Juergen Fickel <juergen.fickel@bosch.io>
  • Loading branch information
Juergen Fickel committed Nov 4, 2022
1 parent bed18e2 commit 4c5e9aa
Showing 1 changed file with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,15 @@ public static Result<KamonHttpContextPropagation, Throwable> newInstanceForChann
final CharSequence propagationChannelName
) {
checkNotNull(propagationChannelName, "propagationChannelName");
return getHttpPropagation(propagationChannelName.toString()).map(KamonHttpContextPropagation::new);
}

private static Result<Propagation<HttpPropagation.HeaderReader, HttpPropagation.HeaderWriter>, Throwable> getHttpPropagation(
final String propagationChannelName
) {
final Result<Propagation<HttpPropagation.HeaderReader, HttpPropagation.HeaderWriter>, Throwable> result;
final var contextPropagationOption = Kamon.httpPropagation(propagationChannelName);
if (contextPropagationOption.isDefined()) {
result = Result.ok(contextPropagationOption.get());
} else {
result = Result.err(new IllegalArgumentException(
return Kamon.httpPropagation(propagationChannelName.toString())
.map(KamonHttpContextPropagation::new)
.map(Result::ok)
.getOrElse(() -> Result.err(new IllegalArgumentException(
MessageFormat.format(
"HTTP propagation for channel name <{0}> is undefined.",
propagationChannelName
)
));
}
return result;
)));
}

/**
Expand Down

0 comments on commit 4c5e9aa

Please sign in to comment.