Skip to content

Commit

Permalink
Merge pull request #834 from typelevel/update/opentelemetry-api-1.44.1
Browse files Browse the repository at this point in the history
  • Loading branch information
iRevive authored Nov 10, 2024
2 parents d353515 + 444ab13 commit 4279d38
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ val MUnitScalaCheckVersion = "1.0.0-M11"
val MUnitCatsEffectVersion = "2.0.0"
val MUnitDisciplineVersion = "2.0.0-M3"
val MUnitScalaCheckEffectVersion = "2.0.0-M2"
val OpenTelemetryVersion = "1.43.0"
val OpenTelemetryVersion = "1.44.1"
val OpenTelemetryInstrumentationVersion = "2.9.0"
val OpenTelemetryInstrumentationAlphaVersion = "2.5.0-alpha"
val OpenTelemetrySemConvVersion = "1.28.0-alpha"
Expand Down
4 changes: 2 additions & 2 deletions examples/src/main/scala/PekkoHttpExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ import scala.concurrent.duration._
* "org.apache.pekko" %% "pekko-stream" % "1.1.2",
* "org.apache.pekko" %% "pekko-http" % "1.1.0",
* "io.opentelemetry.instrumentation" % "opentelemetry-instrumentation-annotations" % "2.9.0",
* "io.opentelemetry" % "opentelemetry-exporter-otlp" % "1.43.0" % Runtime,
* "io.opentelemetry" % "opentelemetry-sdk-extension-autoconfigure" % "1.43.0" % Runtime
* "io.opentelemetry" % "opentelemetry-exporter-otlp" % "1.44.1" % Runtime,
* "io.opentelemetry" % "opentelemetry-sdk-extension-autoconfigure" % "1.44.1" % Runtime
* )
* run / fork := true,
* javaOptions += "-Dotel.java.global-autoconfigure.enabled=true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ package org.typelevel.otel4s.oteljava.trace
import cats.effect.IO
import cats.effect.Resource
import cats.effect.testkit.TestControl
import io.opentelemetry.api.common.{Attributes => JAttributes}
import io.opentelemetry.api.common.{AttributeKey => JAttributeKey}
import io.opentelemetry.api.trace.StatusCode
import io.opentelemetry.api.trace.propagation.W3CTraceContextPropagator
import io.opentelemetry.sdk.common.InstrumentationScopeInfo
import io.opentelemetry.sdk.internal.AttributesMap
import io.opentelemetry.sdk.testing.time.TestClock
import io.opentelemetry.sdk.trace.SdkTracerProviderBuilder
import io.opentelemetry.sdk.trace.SpanLimits
import io.opentelemetry.sdk.trace.data.ExceptionEventData
import io.opentelemetry.sdk.trace.data.StatusData
import io.opentelemetry.sdk.trace.internal.data.ExceptionEventData
import org.typelevel.otel4s.Attributes
import org.typelevel.otel4s.context.propagation.TextMapPropagator
import org.typelevel.otel4s.oteljava.AttributeConverters._
Expand All @@ -38,6 +39,8 @@ import org.typelevel.otel4s.trace.BaseTracerSuite
import org.typelevel.otel4s.trace.SpanContext
import org.typelevel.otel4s.trace.TracerProvider

import java.io.PrintWriter
import java.io.StringWriter
import java.time.Instant
import scala.concurrent.duration._
import scala.jdk.CollectionConverters._
Expand Down Expand Up @@ -91,14 +94,27 @@ class TracerSuite extends BaseTracerSuite[Context, Context.Key] {
"set error status on abnormal termination (exception)",
_.setClock(TestClock.create(Instant.ofEpochMilli(1L)))
) { sdk =>
val limits = SpanLimits.getDefault
val exception = new RuntimeException("error") with NoStackTrace

val stringWriter = new StringWriter()
val printWriter = new PrintWriter(stringWriter)
exception.printStackTrace(printWriter)

val attributes = AttributesMap.create(
limits.getMaxNumberOfAttributes.toLong,
limits.getMaxAttributeValueLength
)

attributes.put(JAttributeKey.stringKey("exception.message"), exception.getMessage)
attributes.put(JAttributeKey.stringKey("exception.stacktrace"), stringWriter.toString)

def expected(epoch: Long) =
ExceptionEventData.create(
SpanLimits.getDefault,
epoch,
exception,
JAttributes.empty()
attributes,
attributes.size()
)

TestControl.executeEmbed {
Expand Down

0 comments on commit 4279d38

Please sign in to comment.