Skip to content

Commit

Permalink
Merge pull request #738 from iRevive/oteljava/wrapper-to-string
Browse files Browse the repository at this point in the history
  • Loading branch information
iRevive authored Aug 31, 2024
2 parents f36d7d2 + 6bd1367 commit 9f8c8b0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ private[propagation] object JavaPropagatorWrappers {
Option(carrier)
.fold(context)(underlying.extract(Context.wrap(context), _).underlying)
}

override def toString: String = s"TextMapPropagatorWrapper{$underlying}"
}

class JTextMapPropagatorWrapper(val underlying: JTextMapPropagator)
Expand Down Expand Up @@ -101,5 +103,7 @@ private[propagation] object JavaPropagatorWrappers {
)
res
}

override def toString: String = s"JTextMapPropagatorWrapper{$underlying}"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2022 Typelevel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.typelevel.otel4s.oteljava.context.propagation

import io.opentelemetry.api.incubator.propagation.{
PassThroughPropagator => JPassThroughPropagator
}
import munit.FunSuite
import org.typelevel.otel4s.context.propagation.PassThroughPropagator
import org.typelevel.otel4s.oteljava.context.Context
import org.typelevel.otel4s.oteljava.context.propagation.PropagatorConverters._

class PropagatorConvertersSuite extends FunSuite {

test("TextMapPropagatorWrapper - proper to string") {
assertEquals(
PassThroughPropagator[Context, Context.Key]("key").asJava.toString,
"TextMapPropagatorWrapper{PassThroughPropagator{fields=[key]}}"
)
}

test("JTextMapPropagatorWrapper - proper to string") {
assertEquals(
JPassThroughPropagator.create("key").asScala.toString,
"JTextMapPropagatorWrapper{PassThroughPropagator{fields=[key]}}"
)
}

}

0 comments on commit 9f8c8b0

Please sign in to comment.