Skip to content

Commit

Permalink
Merge pull request #400 from iRevive/sdk-trace/trace-scope
Browse files Browse the repository at this point in the history
sdk-trace: add `SdkTraceScope`
  • Loading branch information
iRevive authored Dec 25, 2023
2 parents 4f41e3e + 55be98e commit e42ddbd
Show file tree
Hide file tree
Showing 3 changed files with 686 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2023 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.sdk.trace

import cats.effect.SyncIO
import org.typelevel.otel4s.sdk.context.Context
import org.typelevel.otel4s.trace.SpanContext

/** The keys that can be used by a third-party integrations.
*/
object SdkContextKeys {

/** The [[org.typelevel.otel4s.trace.SpanContext SpanContext]] is stored under
* this key in the [[org.typelevel.otel4s.sdk.context.Context Context]].
*
* To retrieve the context use:
* {{{
* val context: Context = ???
* val spanContext: Option[SpanContext] = context.get(SdkContextKeys.SpanContextKey)
* }}}
*/
val SpanContextKey: Context.Key[SpanContext] =
Context.Key
.unique[SyncIO, SpanContext]("otel4s-trace-span-context-key")
.unsafeRunSync()

}
Loading

0 comments on commit e42ddbd

Please sign in to comment.