blob: 4f9de4a17bedee0b8e2c36428069069b7fad9a16 [file]
// Copyright 2026 Google LLC
//
// 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
//
// https://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.
//
#ifndef THIRD_PARTY_CREDENTIO_TRACING_THREAD_CONTEXT_H_
#define THIRD_PARTY_CREDENTIO_TRACING_THREAD_CONTEXT_H_
#include "absl/base/nullability.h"
#include "tracing/span.h"
namespace credentio_tracing {
// Manages thread-local active span state across execution boundaries.
class ThreadContext {
public:
// Returns the currently active Span on the calling thread, or nullptr if
// none.
static Span* absl_nullable GetCurrentSpan();
// Sets the active Span for the calling thread.
//
// Does not take ownership of `span`. The caller is responsible for ensuring
// `span` remains valid while set as active on the calling thread, and is
// unset or restored before `span` is destroyed.
static void SetCurrentSpan(Span* absl_nullable span);
};
} // namespace credentio_tracing
#endif // THIRD_PARTY_CREDENTIO_TRACING_THREAD_CONTEXT_H_