/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include #include #include #include #include #include namespace smithy { namespace components { namespace tracing { /** * Experimental - This definition is a work in progress API * changes are expected. * * The basic unit of a "Trace". Represents a time period during which events * or metrics can take place such as counts, timers, statistics, and messages. * Additionally child "Traces" can exist in a parent trace that will have its * own unique events. Keeps track of where and when an event happened. */ class SMITHY_API TraceSpan : public std::enable_shared_from_this { public: TraceSpan(std::shared_ptr probe); TraceSpan(std::shared_ptr parentSpan); TraceSpan(const TraceSpan &) = delete; TraceSpan &operator=(const TraceSpan &) = delete; TraceSpan(TraceSpan &&) = delete; TraceSpan &operator=(TraceSpan &&) = delete; virtual ~TraceSpan(); TraceEvent newCountEvent(Aws::String &&eventName, const Aws::String &componentId, TraceEventLevel level, uint64_t count) const; TraceEvent newTimerEvent(Aws::String &&eventName, const Aws::String &componentId, TraceEventLevel level, std::chrono::milliseconds timeTaken) const; TraceEvent newStatEvent(Aws::String &&eventName, const Aws::String &componentId, TraceEventLevel level, TraceStatType statType, double value) const; TraceEvent newMessageEvent(Aws::String &&eventName, const Aws::String &componentId, TraceEventLevel level, Aws::String &&message) const; std::shared_ptr newChildSpan(); void emitTraceEvent(TraceEvent &&event); void emitTraceEvents(std::vector &&events); void flushEvents() noexcept; private: Aws::Vector spanEvents; std::shared_ptr probe; std::shared_ptr parentSpan; Aws::String spanId; std::mutex eventsLock; }; } } }